iRonnie16 Posted August 28, 2014 Share Posted August 28, 2014 For simplicity sake Item1,2,3 etc represent different outfits and bonusitem represents and addon So I want to have it so when I equip item1 then bonusitem is auto-equipped. But there are also item2, item3 etc that I want to also have the game auto equip bonusitem for if I change outfit. The way I'm handling this is with setting states. Are these scripts conflicting one another? SCN Item1Equipint Statebegin Gamemode if player.GetEquipped Item1==0 set state to 0 EndIf if player.GetEquipped Item1 ==1 set state to 1 EndIf if state ==0 player.UnequipItem BonusItem EndIf if state ==1 player.EquipItem BonusItem EndIfEnd SCN Item2Equipint Statebegin Gamemode if player.GetEquipped Item2 ==0 set state to 0 EndIf if player.GetEquipped Item2 ==1 set state to 1 EndIf if state ==0 player.UnequipItem BonusItem EndIf if state ==1 player.EquipItem BonusItem EndIfEnd So on and so forth. Basically is it setting the state to 1 because I equip Item1 and then setting it back to 0 because I don't have Item2 equipped? Thanks in advance. Link to comment Share on other sites More sharing options...
Ladez Posted August 28, 2014 Share Posted August 28, 2014 (edited) Each script has its own variables, so they will not change each others state variable. However, if state is 1 in the first script and state is 0 in the second script, what they will do is cause you to endlessly unequip and reequip your bonusitem. That's not good. Why not escape the variable madness and just attach this script to all the items that you need to auto-equip your bonus item? ScriptName BonusItemEquip BEGIN OnEquip Player Player.EquipItem BonusItem END BEGIN OnUnEquip Player Player.UnequipItem BonusItem END Edited August 28, 2014 by Ladez Link to comment Share on other sites More sharing options...
iRonnie16 Posted August 28, 2014 Author Share Posted August 28, 2014 BEGIN OnEquip Player BEGIN OnUnEquip Player I was always curious as to whether this block fires if you don't have the item that you equipped mentioned. So it does? Link to comment Share on other sites More sharing options...
Ladez Posted August 28, 2014 Share Posted August 28, 2014 I was always curious as to whether this block fires if you don't have the item that you equipped mentioned. So it does? I'm sorry, I don't understand this question. These blocks fire if you equip/unequip the item the script is attached to. Obviously you need to have the item to be able to equip it, so as far as I know, it'll never fire if you don't have the item. Link to comment Share on other sites More sharing options...
iRonnie16 Posted August 28, 2014 Author Share Posted August 28, 2014 (edited) You answered my question but what I meant was is having ScriptName BonusItemEquipBEGIN OnEquip PlayerPlayer.EquipItem BonusItemENDBEGIN OnUnEquip PlayerPlayer.UnequipItem BonusItemEND the same as having ScriptName BonusItemEquipBEGIN OnEquip Player if player.GetEquipped Item1 Player.EquipItem BonusItem EndIfENDBEGIN OnUnEquip Player if player.UneQuipItem Item1 Player.UnequipItem BonusItem EndIfEND Edited August 28, 2014 by iRonnie16 Link to comment Share on other sites More sharing options...
Ladez Posted August 28, 2014 Share Posted August 28, 2014 (edited) If the script is only attached to item1, then the two scripts would behave exactly the same way. The GetEquipped would be redundant since you're guaranteed to have the item equipped when the OnEquip block runs. If you're going to have the script attached to multiple items, as I suggested, then the script would not work with GetEquipped, since it would only support whatever item you check on. That is unless you use GetEquipped on all the items, which would defeat the purpose of having a unified script for all the items. Edited August 28, 2014 by Ladez Link to comment Share on other sites More sharing options...
Recommended Posts