#item OnEquip() and OnUnequip() don't work
1 messages · Page 1 of 1 (latest)
what I mean by it "not doing anything" is I cannot get any of the functions to be called, no matter what I do with my inventory
I also tried OnInventoryContentsChanged() to no avail
has this stuff been deprecated?
i know they worked in the past, no idea about currently.
i see specifically a OnItemEquipped(item) function for lua items/abilities in the api but no unequip equivalent.
doesn't work
tried it before
I'm simulating it using the intrinsic modifiers creation / destroy function atm, but it feels super jank
it works
but I don't like it
that sounds fine tbh.
Found 1 function for onequip
🇸 CDOTA_Item:OnEquip(): nil
Found 2 functions for onitemequipped
🇸 CDOTA_Ability_Lua:OnItemEquipped(item: CDOTA_Item): nil
Caster equipped item.
🇸 CDOTA_Item_Lua:OnItemEquipped(item: CDOTA_Item): nil
Caster equipped item.
Hm, so you're saying it doesn't work for abilities as well?
Because I remember doing that for controlling scepter behavior on custom abilities
can't say for abilities, I'm specifically using it on an item
but as far as I can tell, none of the functions are called
Is the item custom? (Sounds obvious but I got to ask)
Can you show relevant code for your tests?
How to use OnEquip() and OnUnequip(): https://github.com/SteamDatabase/GameTracking-Dota2/blob/master/game/dota_addons/dungeon/scripts/vscripts/items/item_gravel_foot.lua#L21-L22. As you can see these are not events but you manually call them in succession like in the example to 'refresh' or 'reequip' the item. This comment explains it the best: #helpdesk-old message
OnInventoryContentsChanged() is ability only
useful for scepter abilities like Shush mentioned
To actually detect item equiping, unequiping or dropping items use some of these: https://moddota.com/api/#!/events?search=item or Inventory filter. But you dont want that so nvm
So in other words it's just a broken event lol