• 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!

Solved remove items function

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
211
hello folks, I need make it work for a big script, I want that the function remove all items from determined area to me load a map ...
the function..
Code:
local function removeItems()
    for x = config.position.fromPosition.x, config.position.toPosition.x do
        for y = config.position.fromPosition.y, config.position.toPosition.y do
            for z = config.position.fromPosition.z, config.position.toPosition.z do
                local tile = Tile(Position(x, y, z))
                if not tile then
                    break
                end
                -- HERE I NEED THAT CODE
            end
        end
    end
end
also, it need remove ground items aswell, also some tile positions have more than 1 item
 
I know that function but I'm not sure how it work or how use it :oops:

edit: found something
Code:
iterateArea(
                function(position)
                    local tile = Tile(position)
                    if tile then
                        local items = tile:getItems()
                        if items then
                            for i = 1, #items do
                                items[i]:remove()
                            end
                        end

                        local ground = tile:getGround()
                        if ground then
                            ground:remove()
                        end
                    end
                end,
                config.fromPosition,
                config.toPosition
            )
 
Last edited:
Code:
iterateArea(
            function(position)
                local item = Tile(position):getItemById(itemid)
                if item then
                    item:remove()
                end
            end,
            Position(x, y, z),
            Position(x, y, z)
        )
 
solved with the first function :)
just create a new variable items = tile:getItems() and create a loop to remove each item of the tile
thanks for the support.
 
Back
Top