texashokies Posted August 6, 2018 Share Posted August 6, 2018 Here is the function that doesn't want to play nice: Function Enslave(Actor akTarget) Debug.MessageBox("Enslaving") akTarget.AddItem(SlaveCollar,1) Debug.MessageBox("Equipped: " + akTarget.IsEquipped(SlaveCollar)) While (!akTarget.IsEquipped(SlaveCollar)) akTarget.EquipItem(SlaveCollar, true) Debug.MessageBox("Equipped: " + akTarget.IsEquipped(SlaveCollar)) EndWhile Debug.MessageBox("Loop over") Game.GetPlayer().RemoveItem(SlaveCollar,1) EndFunction The akTarget variable given by the dialouge fragment that calls the function. When this function is run I get an infinite loop. What am I missing? Link to comment Share on other sites More sharing options...
scrivener07 Posted August 6, 2018 Share Posted August 6, 2018 I dont think you would need to loop at all for something like this. I slightly re-wrote it how I would have done. I took out the loop and added a few more debug messages. ScriptName SlaverTopicInfo extends TopicInfo Actor Player ; Events ;--------------------------------------------- Event OnInit() Player = Game.GetPlayer() EndEvent Event OnEnd(ObjectReference akSpeakerRef, bool abHasBeenSaid) Actor speaker = akSpeakerRef as Actor If (speaker) If (Enslave(speaker)) Debug.MessageBox("Enslaved\n" + speaker) Else Debug.MessageBox("Could not enslave " + speaker) EndIf Else Debug.MessageBox("The speaker was none or not of the Actor type.") EndIf EndEvent ; Functions ;--------------------------------------------- bool Function Enslave(Actor speaker) If (Player.GetItemCount(SlaveCollar) > 0) If (speaker.IsEquipped(SlaveCollar) == false) Player.RemoveItem(SlaveCollar, 1) speaker.EquipItem(SlaveCollar, true) return true Else Debug.MessageBox("The speaker already has a slave collar equipped.") return false EndIf Else Debug.MessageBox("The player does not have a slave collar in their inventory.") return false EndIf EndFunction ; Properties ;--------------------------------------------- Group Properties Armor Property SlaveCollar Auto Const Mandatory EndGroup Link to comment Share on other sites More sharing options...
Recommended Posts