Call Function WearGarment not running after wearing script

I have been writing a game with multiple scenes and between scenes (and in the initial start-up script) the game is currently set to remove items of clothing (using removegarment) and apply new ones (using weargarment), however, none of the after wearing item scripts work in regards to adding or subtracting values from an attribute.

For example, the attribute1 starts at 1
Weargarment (trousers1) - subscript to add 1 to attribute 1 on wear and subtract 1 on remove
Weargarment (shirt1) - subscript to add 2 to attribute 1 on wear and subtract 2 on remove

This should make attribute1 = 4 at the start of the game when the function calls both items (which are showing as worn in-game and work right otherwise), however, this does not work and it stays at 1 and is only affected by adding and remove clothes manually only which screws up the numbers since the initial value isn't set right.

Is there a way to force it to run the after wearing and after remove script upon using weargarment and removegarment.

Additionally, the difficulty is that I also need it to adjust attribute1 by a different amount based on attribute2's value which again works fine manually just not with the automatic scripts upon game load or scene change.

--

Alternatively, I know I can call the item to inventory and use Handlesinglecommand ("wear item1") which does make it run the after wearing/remove scripts but this puts the text "you it on" for all the items switched on screen which clutters up the display and looks like an error since it's out of place.


If anyone else is having this issue managed to get the solution from here to work for me.

It works by moving my after wear/remove scripts into an if statement such as and creating a new attribute on the item of clothing called changedwornto place this into as a script value.

if (this.worn) {
if (PLAYER.ATT1 < 5) {
  PLAYER.ATT2 = PLAYER.ATT2 + 1
}
else {
  PLAYER.ATT2 = PLAYER.ATT2 + 2
}
}
else {
if (PLAYER.ATT1 < 5) {
 PLAYER.ATT2 = PLAYER.ATT2 - 1
}
else {
  PLAYER.ATT2 = PLAYER.ATT2 - 2
}
}

Log in to post a reply.

Support

Forums