• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Function to remove item from position?

viniciusturko

New Member
Joined
Jun 23, 2009
Messages
94
Reaction score
2
Location
Brasil
Where is the error in this function?

LUA:
function doRemoveItemByPosition(pos, item) -- Function by CyberM
    for j = 1, 255 do
        pos.stackpos = j
        local thing = getTileThingByPos(pos).itemid
        if thing == 0 then
            break
        elseif thing == item then
            doRemoveItem(thing, 1)    
        end
    end
    return i
end

XML:
Lua doRemoveItem : Item not found

Can someone solve it?
 
Last edited:
LUA:
function doRemoveItemByPosition(pos, item)
    for j = 1, 255 do
        pos.stackpos = j
        local thing = getTileThingByPos(pos)
        if thing.itemid == item then
            return doRemoveItem(thing.uid)
		elseif thing.itemid == 0 or thing.itemid == nil then
			break
        end
    end
end
 
Why don't you just do it like this:

LUA:
local item = getTileItemById(pos, id)
while item.uid > 0 do
doRemoveItem(item.uid)
item = getTileItemById(pos, id)
end
 
LUA:
function doRemoveItemByPosition(pos, item)
    for j = 1, 255 do
        pos.stackpos = j
        local thing = getTileThingByPos(pos)
        if thing.itemid == item then
            return doRemoveItem(thing.uid)
		elseif thing.itemid == 0 or thing.itemid == nil then
			break
        end
    end
end


you fucking noob

LUA:
function doRemoveItemByPosition(pos, item)
    local this = getTileItemById(pos, item).uid
    if (this > 0) then
        return doRemoveItem(this) and doRemoveItemByPosition(pos, item)
    end
    return true
end
 
No, that function to count the item stack work very nice, but yesterday, I had to create an other but to remove a certain "item" from a certain "position", and I was thinking that if I just change that your function, it would work well x_x
But sorry...
 
Back
Top