Proposal: return value of equipscript should not be checked

Here you can post threads specific to the current release of the core (099)

Moderator: POL Developer

Post Reply
bodom
Former Developer
Posts: 140
Joined: Sat Feb 21, 2015 7:52 pm
Location: Italy

Proposal: return value of equipscript should not be checked

Post by bodom »

Brief: I am proposing to remove the return value checking on Item's equip/unequip script because it is redundant and misleading.

The problem:
Actually every equippable item can have 4 relevant scripts:
- an equipTest script
- an equip script
- an unequipTest script
- an unequip script

The general assumption is the following: when the core wants to (un)equip and item it calls the test script, checks its return value, then calls the (un)equip script, checks its return value and finally (un)equips the item.

This is overly complicated and not always true, since on death, the unequiptest script it not called and the unequip script return value is ignored. I would bet there are more similar situations.

A typical equip script will stop its processing when returning 0 and will not perform the required (un)equip actions, assuming the core will not (un)equip the item. When the core (un)equips the item anyway, this could lead to bugs.
Since the only reason for an (un)equiptest script to exis is to check whether an item can be unequipped or not, I see no reason to have this redundant feature also in the (un)equip script.

The proposed solution:
What I have in mind is a straightforward simplification and division of roles.
- The core will call the (un)equip test script only when it intends to obey its returns value. A scripter can assume that when the script is called and 0 is returned, the item will not be (un)equipped and the (un)equip script will not be called at all. The "test" script will be only responsible to check for item (un)equippability.
- The (un)equip script will be called when the item is about to be (un)equipped, regardless of the fact that the "test" script has been called or not. Its return value will be ignored and it will only be responsible to perform needed (un)equip actions.


Do you think that's a good idea/improvement?
Post Reply