antstubell Posted June 17, 2019 Share Posted June 17, 2019 I have made a triggerbox base that I can place anywhere that if the player enters it (water will be falling or player will be submerged) and has a torch EQUIPPED, not important if player has x amount in inventory, that I want to dowse the torch i.e. remove the torch the player has equipped. I don't know how to add this to the script. There is no RemoveEquippedItem or similar that I know of.Help please. import soundActor Property PlayerREF AutoMessage Property MyMSG AutoSound Property FireOut AutoGlobalVariable Property MyGV Autoint instanceID ;used to store sound refauto state waitingEvent OnTriggerEnter(ObjectReference akActionRef)if akActionRef == PlayerRefif (PlayerRef.GetEquippedItemType(0) == 11)FireOut.Play(self)if MyGV.GetValue() == 0.0MyMSG.show()MyGV.SetValue(1.0)GoToState("Done")else; Do nothingEndIfEndIfEndIfENDEVENTENDSTATE Link to comment Share on other sites More sharing options...
Evangela Posted June 18, 2019 Share Posted June 18, 2019 (edited) I found this to be very difficult to for different purposes. You can unequip items obviously through UnequipItem, but removing them is a different story. You can check if there is more than one of the equipped item in the inventory, through GetItemCount and then use RemoveItem(as it has a frustrating preference for removing the first instance of an item, which happens to be the equipped one.) Edited June 18, 2019 by Rasikko Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 18, 2019 Share Posted June 18, 2019 If player has torch equipped, it is usually lit. You want the torch to be removed as if it were to have been put out by the water. But you do not want to screw up how many additional torches the player may be carrying. Hmm... You might need to use a "pass back method" (not an official term, I just made it up LOL ). Something like this: Light Property myTorch Auto ObjectReference Property myHiddenContainer Auto Event OnTriggerEnter(ObjectReference akActivator) If akActivator == Game.GetPlayer() ; --- make sure it is the player Int Num = akActivator.GetItemCount(myTorch) ; --- get number of torches akActivator.RemoveItem(myTorch,Num,true,myHiddenContainer) ; --- remove all torches to the container myHiddenContainer.RemoveItem(myTorch,(Num - 1),true, akActivator) ; --- return all torches but one to the player EndIf EndEventThis uses a container that you have hidden somewhere out of the player's reach. I prefer an unlinked empty interior cell for this sort of thing.Eventually the container may get loaded with a lot of torches if this is intended to happen a lot. Should that be the case, adding an additional RemoveItem call to send the remaining torch from the container into the void (and effectively removing it from the game) may be desired. To send an item to the void, do not designate a target container in the RemoveItem function call. The only downside to this method is that there is no visible torch dropped at the player's feet. DropObject can be used but there is no way to determine definitively if the dropped object will be the equipped one or one that is not. Furthermore, if the torch is lit when dropped it tends to remain lit. Probably best not to worry about having a visual reference to the torch that was put out. Or just take the torches away and return them without reducing by one. After all the player could be considered "smart enough" to hold on to the torch while it goes out and saves it for later use. Link to comment Share on other sites More sharing options...
antstubell Posted June 18, 2019 Author Share Posted June 18, 2019 @IsharaMeradinThat works perfect. Made a small interior cell with a chest for dumping purposes.What I discovered if I don't designate a target container in the RemoveItem function call, the script still works and the torch goes to 'the void' but so do all torches in player's inventory.Thanks. EDIT: Duh! I've just understood why. Link to comment Share on other sites More sharing options...
Recommended Posts