Jump to content

Are these scripts conflicting?


iRonnie16

Recommended Posts

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 Item1Equip

int State

begin 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
EndIf
End

SCN Item2Equip

int State

begin 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
EndIf
End
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

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 by Ladez
Link to comment
Share on other sites

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

You answered my question but what I meant was is having

 

ScriptName BonusItemEquip

BEGIN OnEquip Player

Player.EquipItem BonusItem
END

BEGIN OnUnEquip Player
Player.UnequipItem BonusItem

END

the same as having

ScriptName BonusItemEquip

BEGIN OnEquip Player

if player.GetEquipped Item1
Player.EquipItem BonusItem

EndIf
END


BEGIN OnUnEquip Player

if player.UneQuipItem Item1
Player.UnequipItem BonusItem

EndIf
END


Edited by iRonnie16
Link to comment
Share on other sites

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 by Ladez
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...