I know its name and ID.
I need the backpack slot number of this item to use it in the PickupItem(slotID) function.
Can i do it in rombot or ingame macro easily?
I didn't find any existing function that returns items slot.
So i wrote my own (edited some existing func)
I put it in the userfunctions folder and it works fine.
But is this userfunction neccessary?
Is there a simpler way?
Code: Select all
function CInventory:findItemSlot( itemNameOrId, range)
local first, last = getInventoryRange(range) -- get bag slot range
if first == nil then
first , last = 1, 240 -- default, search all
end
local smallestStack = nil
local itemslot = nil
self:update()
for slot = first, last do
item = inventory.BagSlot[slot]
if item.Available and (item.Name == itemNameOrId or item.Id == itemNameOrId) then
if item.ItemCount > 1 then
-- find smallest stack
if smallestStack == nil or smallestStack.ItemCount > item.ItemCount then
smallestStack = item
itemslot = slot
end
else
return slot
end
end;
end;
return itemslot
end