| 06-05-2009, 02:47 AM | #1 |
JASS:private function SwapItemPosition takes backpack d, unit target,integer c returns nothing local item i = UnitItemInSlot(target,c) local integer id = GetItemTypeId(i) call RemoveItem(i) if d.ItemType[c] != 0 then call UnitAddItemById(target,d.ItemType[c]) endif set d.ItemType[c] = id set d.UserData[c] = GetItemUserData(i) set d.Charges[c] = GetItemCharges(i) set i = null endfunction private function SwapSlot takes nothing returns nothing local integer oid = GetIssuedOrderId() local unit u = GetTriggerUnit() local backpack d = backpack[u] if d == 0 then set d = backpack.create(u) endif if oid == SLOT0 then call SwapItemPosition(d,u,0) elseif oid == SLOT1 then call SwapItemPosition(d,u,1) elseif oid == SLOT2 then call SwapItemPosition(d,u,2) elseif oid == SLOT3 then call SwapItemPosition(d,u,3) elseif oid == SLOT4 then call SwapItemPosition(d,u,4) elseif oid == SLOT5 then call SwapItemPosition(d,u,5) endif set backpack[u] = d set u = null endfunction It seems that whenever the first time the unit swaps the item to his "backpack" it does nothing but for the 2nd cast onwards it works well. |
| 06-06-2009, 04:38 AM | #2 |
it seems the backpack doesnt actually hold items; rather, it is just a record of them that has some interface with which a player can interact (swap items)? well if by "the first time" you mean "the first time you operated on that interface (above)" and if by "it does nothing" you mean "the unti doesnt receive any item from the backpack" thats because the backpack doesnt 'contain' (describe) any items, initially. (d.ItemType[c] == 0) |
