• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

moving an existing item in the inventory to another slot

Status
Not open for further replies.
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:
  • Set u = YourUnit
  • Set iType = yourItemType
  • Custom script: call UnitAddItemToSlotById(udg_u, udg_iType, 0)
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)
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
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
 
Level 6
Joined
Jun 20, 2012
Messages
195
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

so I would need filler items? ..alright maybe I will try this ..

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:
  • Set u = YourUnit
  • Set iType = yourItemType
  • Custom script: call UnitAddItemToSlotById(udg_u, udg_iType, 0)
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)

exactly sir but I dont want to remove and recreate the same item ..I just want the existing item itself to be moved to an inventory slot i desire..
 
Last edited by a moderator:
Status
Not open for further replies.
Top