• 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 How to get item ID from tile and then remove it?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
626
Location
Estonia
I have a tile where i want to reSpawn bucket every hour.
but every time the script starts i want it to first remove the all items from that tile before.
then create bucket there.

working script
Code:
local pos1 = {x=558,y=654,z=7}

function onThink()
local items = Tile(pos1):getItems()

    for i = 1, #items do
        addEvent(function() items[i]:remove() end, 1000)
    end
    addEvent(doCreateItem, 2000, 2005, 0, pos1)
return true
end

sidenote*
you don't have to use addEvent, but my script actually continues, that is why you see them here.

Code:
local pos1 = {x=558,y=654,z=7}
This is the tile position i want to change.
Code:
function onThink()
you can use any function you like. I use onThink because i have a globalEvent.
You can make things clean and create items for onUse or whatever else function.
Code:
local items = Tile(pos1):getItems()
under items i collect all the items what are located in position
Code:
    for i = 1, #items do
        addEvent(function() items[i]:remove() end, 1000)
    end
for every item i found in that tile: remove them all 1 sec later
Code:
addEvent(doCreateItem, 2000, 2005, 0, pos1)
2 seconds after using script (and 1 seconds after deleting all items)
makes item in the position i defined earlier
2005 is bucket and 0 means its empty.
1 would mean its water in it, etc
 
Last edited:
Back
Top