PDA

View Full Version : Hooking into the Delete of an item of Equipment, to remove the weapon actions



MadBeardMan
February 16th, 2019, 19:02
Greetings All,

I asked something similar to this a while ago, but never got to the bottom of it. Ideally I need it working now.

When you delete a weapon from the Inventory (in 5E) the Weapon Option is also removed.

In my manager_char.lua I have this script:


--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--
function onInit()
ItemManager.setCustomCharAdd(onCharItemAdd);
ItemManager.setCustomCharRemove(onCharItemDelete);
end

The 'onCharItemAdd' is called when an item is added, however the 'onCharItemDelete' is not called.

Now I think I could add the event manually by looking for item == 6 (from the wheel), but that wouldn't work for a manual delete (ie clicking the remove on the right of the item).

Can anyone point out what's wrong? This is for the Traveller ruleset.

Cheers,
MBM

Moon Wizard
February 18th, 2019, 03:09
As you say, it's working in 5E ruleset, so that function appears to be working. One thing to note is that their can only be one function registered here, and it will get overwritten if another one is registered. So, make sure you only have one call to ItemManager.setCustomCharAdd/setCustomCharRemove in your ruleset.

Regards,
JPG

MadBeardMan
February 23rd, 2019, 09:44
As you say, it's working in 5E ruleset, so that function appears to be working. One thing to note is that their can only be one function registered here, and it will get overwritten if another one is registered. So, make sure you only have one call to ItemManager.setCustomCharAdd/setCustomCharRemove in your ruleset.

Regards,
JPG

Morning Moon Wizard,

Thanks for the reply.

There is only 1 place where it calls the 'setCustomCharRemove', same place as it does the 'setCustomCharAdd', which is why I don't understand why it's not working, one does, one doesn't.

Cheers
Col

Moon Wizard
February 25th, 2019, 01:36
You can always unzip CoreRPG and add Debug statements to see where it's diverging from what you are expecting. It's working in 5E and 3.5E for weapon entry creation/removal on inventory addition/removal.

Regards,
JPG