• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

how to store 6 item type and then some swapping item and then restore position of those 6 item

Level 24
Joined
Jun 26, 2020
Messages
1,928
in this case you would need to save the items in a hashtable since I assume you wanna make it MUI, so the first index is the handle id of the hero and the second index will be the position of the item (from 1 to 6), and then you can re-add the items and use the function "Order unit to move item to slot x".
Maybe you will have an issue with this because that order interrumpts the current order of the unit, something I do to avoid using that order and ensuring that the items will be in their original slot is just add the items in order and then fill the empty slots with "Dummy items" and then removing them afterwards.
 
Level 24
Joined
Feb 27, 2019
Messages
833
Theres also this native to add/create item to slot which specifies which slot the item is added/created in but then you have to remove the item and re-create it in that specific slot.
Code:
UnitAddItemToSlotById takes unit whichUnit,integer itemId,integer itemSlot returns boolean

This I dont know if it affects the native. If the hero has stackable items they will end up in the same slot. To avoid that one can change a stat on the item so it doesnt stack. I dont know how I did it exactly but it aint hard. Probably storing max stack of item, setting max stack of item to current stack and after theyre re-added, set the max stack back to original value.
 
Top