| 07-03-2006, 06:50 AM | #1 |
Yes, i did run a search first. Now, its probably been asked before and i probably missed it. But is it possible to move items around inside the heros inventory (Say i have "Boots of Speed" in slot 1, i want to use triggers to move it to slot 5.) If so, how? |
| 07-03-2006, 07:24 AM | #2 |
The crudest way would be to use RemoveItemFromSlot and AddItemToSlot. function swapitems takes unit u, integer s1, integer s2 returns nothing local item i1 = UnitRemoveItemFromSlot(u,s1 - 1) local item i2 = UnitRemoveItemFromSlot(u,s2 - 1) call UnitAddItemToSlot(u,GetItemTypeId(i2),s1 - 1) call UnitAddItemToSlot(u,GetItemTypeId(i1),s2 - 1) //Not sure if items are dropped when removed, but... call RemoveItem(i1) call RemoveItem(i2) set i1 = null set i2 = null endfunction |
| 07-03-2006, 07:39 AM | #3 | |
Quote:
|
| 07-03-2006, 08:13 AM | #4 |
Naakaloh is very right, the actual orders are much better than adding and removing. If you remove then add, things change, spells could be effected etc. But moving them never effects. I just made some lines of code which would work for this situation. Im not sure if works yet, im going to go and try it out. JASS:function MoveItemSlot takes unit MovingUnit, integer CurrentItemSlot, integer NewItemSlot returns nothing if(NewItemSlot == 1) then call IssueTargetOrderById(MovingUnit, 852002, UnitItemInSlot(MovingUnit, CurrentItemSlot)) elseif(NewItemSlot == 2) then call IssueTargetOrderById(MovingUnit, 852003, UnitItemInSlot(MovingUnit, CurrentItemSlot)) elseif(NewItemSlot == 3) then call IssueTargetOrderById(MovingUnit, 852004, UnitItemInSlot(MovingUnit, CurrentItemSlot)) elseif(NewItemSlot == 4) then call IssueTargetOrderById(MovingUnit, 852005, UnitItemInSlot(MovingUnit, CurrentItemSlot)) elseif(NewItemSlot == 5) then call IssueTargetOrderById(MovingUnit, 852006, UnitItemInSlot(MovingUnit, CurrentItemSlot)) elseif(NewItemSlot == 6) then call IssueTargetOrderById(MovingUnit, 852007, UnitItemInSlot(MovingUnit, CurrentItemSlot)) endif endfunction |
| 07-03-2006, 10:11 AM | #5 |
Double post FTW! This thread can be closed, it turns out what i was going to try and do won't work anyway. |
| 07-03-2006, 10:22 AM | #6 |
Double post deleted. Also, The)TideHunter(, that function can be made a lot simpler. JASS:function MoveItemSlot takes unit movingUnit, integer currentItemSlot, integer newItemSlot returns nothing call IssueTargetOrderById(MovingUnit, 852001+newItemSlot, UnitItemInSlot(movingUnit, currentItemSlot)) endfunction |
| 07-03-2006, 10:33 AM | #7 |
Usually we index slots from zero, too. |
| 07-03-2006, 11:32 AM | #8 | |
Quote:
Ah yea, that would be MUCH better. Good thinking. |
| 07-03-2006, 12:33 PM | #9 |
There's a native for that -.- JASS:native UnitDropItemSlot takes unit whichUnit,item whichItem,integer slot returns boolean |
| 07-03-2006, 12:44 PM | #10 |
That drops a item in a slow to the ground though, dosent it? If it does, hes asking how to change a item thats in 1 slot to another. If not, i stand corrected |
| 07-03-2006, 01:09 PM | #11 |
You stand corrected (as always), this function asks the slot AND the item, so it couldnt be what you said. There's a native that drops item from slot though, just like you said. JASS:native UnitRemoveItemFromSlot takes unit whichUnit,integer itemSlot returns item |
| 07-03-2006, 01:13 PM | #12 | |
Quote:
All lies! i swear! |
