×
Меню
Индекс

MSFD Detecting if an item has been equipped

 
[no fix] OnPCEquip          (is local short variable)
 
Short OnPCEquip
If ( OnPCEquip == 1 )
         
The PC has the object equipped (remains true while object is equipped)
This game variable (needs to be declared!) gets set to 1 if the player is equipping the calling object. It will remain "true" while the item is still equipped, but gets reset to 0 if the item is unequipped. So, in some cases you might want to manually reset it:
 
if ( OnPCEquip == 1 )      ; when the item is equipped
     [do something]
     set OnPCEquip to 0     ; do this once per equip event…
endif
 
The next time the item is unequipped and equipped again, the functions in [do something] will be performed again. You can also use a status variable to control when an effect will be executed. Note that this can also be processed while in Menu mode:
 
If ( MenuMode == 1 )
if ( OnPCEquip == 1 )      ; when the item is equipped
          [do something]
          set OnPCEquip to 0     ; do this once per equip event…
endif
endif
This script will execute while you are in the menu, as soon as the item is equipped, while the following will be executed only after you leave the menu:
If ( MenuMode == 1 )
     Return
Endif
 
if ( OnPCEquip == 1 )      ; when the item is equipped
     [do something]
     set OnPCEquip to 0     ; do this once per equip event…
endif
An additional Sample Script can be found above with the Equip function.
 
Notes: OnPCEquip was successfully tested with the following item types:
Clothing
Armor
Weapons
Books/Scrolls (see tips and tricks for correct use, though)
Miscellaneous items
Usable lights
Probes
 
Potions and Ingredients will only register with OnPCEquip when you use SkipEquip at the same time, otherwise the item is apparently "destroyed" before the function registers! Repair objects suffer from this too, and weirder still, apparatus (or alembics anyway) work the reverse way. They only seem to trigger OnPCEquip when PCSkipEquip is NOT set (Forum info / ManaUser).
Apparently books (and maybe some of the other item types that behave strangely?) set SkipEquip to 1 instead of OnPcEquip! See the tips and tricks section on this issue.