- Joined
- Jun 20, 2012
- Messages
- 195
I know that there is a GUI command for this but that interrupts the current order of the hero. so I ask is there a custom script or something to move an item that is already in the inventory to another slot? pls help
native UnitAddItemToSlotById takes unit whichUnit, integer itemId, integer itemSlot returns boolean
this seems to work good for me.
- Untitled Trigger 001
- Events
- Player - Player 1 (Red) skips a cinematic sequence
- Conditions
- Actions
- Set SlotThatYouWantToMoveTheItemTo = 6
- Set ItemSlotThatYouWantToMove = 1
- Set item = (Item-type of (Item carried by Paladin 0000 <gen> in slot ItemSlotThatYouWantToMove))
- Item - Remove (Item carried by Paladin 0000 <gen> in slot ItemSlotThatYouWantToMove)
- For each (Integer A) from 1 to (SlotThatYouWantToMoveTheItemTo - 1), do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Item carried by Paladin 0000 <gen> in slot (Integer A)) Equal to No item
- Then - Actions
- Hero - Create Potion of Greater Mana and give it to Paladin 0000 <gen>
- Set temp[(Integer A)] = False
- Else - Actions
- Set temp[(Integer A)] = True
- Hero - Create item and give it to Paladin 0000 <gen>
- For each (Integer A) from 1 to (SlotThatYouWantToMoveTheItemTo - 1), do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- temp[(Integer A)] Equal to False
- Then - Actions
- Item - Remove (Item carried by Paladin 0000 <gen> in slot (Integer A))
- Else - Actions
Remove the item and create a new one. To bring it in correct slot use this native function:
native UnitAddItemToSlotById takes unit whichUnit, integer itemId, integer itemSlot returns boolean
If you can't use this and want it more GUI friendly:
In custom script you can modify the slot number to your needs. In this case 0 would be slot 1. (in JASS slots are from 0-5, not from 1-6)
- Set u = YourUnit
- Set iType = yourItemType
- Custom script: call UnitAddItemToSlotById(udg_u, udg_iType, 0)
native UnitAddItemToSlotById takes unit whichUnit, integer itemId, integer itemSlot returns boolean