I have a unit with an inventory ability that gives it 2 containers, 1 for equipped items and 1 for storage.
In one of the equipped slots is a targeted item. It can be one of many items, so I don't know which is in it at any point in time. So, I wanted a trigger to grab that item so I could find out what it is. But, the Inventory Slot of Item function isn't being nice to me.
First off, even when I only have one container, Inventory Slot of Item didn't work.
Trigger 1 Actions
Unit - Create one Item (Inventory) - Grenade item in the inventory of unit
Variable - Set var_slot = (Inventory Slot of (Last created inventory item))
UI - Display (Text(var_slot)) for (All players) to Subtitle area
Trigger 2 Action
Unit - Order (Triggering unit) to (Order Use Item Targeting Point( Use Item Targeted, (Item carried by
(Triggering unit) in var_slot), (Triggering ability target point))) (Replace Existing Orders)
The important part of trigger 2 is (Item carried by (Triggering unit) in var_slot)
Trigger 1 will always print out 1, i.e. first slot.
When I run the 2nd trigger, using the var_slot variable, nothing happens, because the item is apparently in the wrong slot. Debugging showed that var_slot is indeed still 1 when its running.
When I manually set var_slot to 2, however, the ability works just fine. I figured maybe it was just a +1 error all around, and if I adjusted for that I'd be fine.
But the moment I added another container, it all broke again, and I have no idea how to reference the item now at all.
Does anybody have any idea what I can do to solve this?
I have a unit with an inventory ability that gives it 2 containers, 1 for equipped items and 1 for storage. In one of the equipped slots is a targeted item. It can be one of many items, so I don't know which is in it at any point in time. So, I wanted a trigger to grab that item so I could find out what it is. But, the Inventory Slot of Item function isn't being nice to me.
First off, even when I only have one container, Inventory Slot of Item didn't work.
Trigger 1 Actions
Unit - Create one Item (Inventory) - Grenade item in the inventory of unit
Variable - Set var_slot = (Inventory Slot of (Last created inventory item))
UI - Display (Text(var_slot)) for (All players) to Subtitle area
Trigger 2 Action
Unit - Order (Triggering unit) to (Order Use Item Targeting Point( Use Item Targeted, (Item carried by (Triggering unit) in var_slot), (Triggering ability target point))) (Replace Existing Orders)
The important part of trigger 2 is (Item carried by (Triggering unit) in var_slot) Trigger 1 will always print out 1, i.e. first slot. When I run the 2nd trigger, using the var_slot variable, nothing happens, because the item is apparently in the wrong slot. Debugging showed that var_slot is indeed still 1 when its running. When I manually set var_slot to 2, however, the ability works just fine. I figured maybe it was just a +1 error all around, and if I adjusted for that I'd be fine. But the moment I added another container, it all broke again, and I have no idea how to reference the item now at all.
Does anybody have any idea what I can do to solve this?