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

[Need Function] gettileItems

perdigs

New Member
Joined
Aug 22, 2010
Messages
114
Reaction score
1
I need one function to check the items in tile, my ideia is use object in one tile and this fucntion check all items in this tile when i used my item and get the top item and get this item id to compare with my script
example

my table is

checkItem = {
["1998"] = {to= 6666}
}

if checkItem[getTileItems] then....

thks for the attention....
 
Something like this?

LUA:
function getItemsOnTile(pos) {

	local tileItems = {}

	for stackpos = 1, 253 do
		local titem = getThingFromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = stackpos})
		if ((titem) and not(isCreature(titem.uid))) then
			table.insert(tileItems, titem.uid)
		end
	end

	return tileItems
end
 
checkItem = {
["1998"] = {to= 6666}
}

if checkItem[getTileItems] then....
It can't work the way you... imagined.

anyways:
LUA:
function getTileItems(p)
	local r, v = {}

	p.stackpos = 1
	v = getThingfromPos(p).uid
	while v ~= 0 do
		if not isCreature(v) then
			table.insert(r, v)
		end
		p.stackpos = p.stackpos + 1
		v = getThingfromPos(p).uid
	end

	return t
end
 
Last edited:
dont work ciko but tks...
i need one function to get the itemid of the topo item in the selected ground, but
if a player is uder this item the function item2.itemid dont work...
 
LUA:
function getTopItem(p)
	p.stackpos = 1
	local v = getThingfromPos(p)
	while v.uid ~= 0 do
		if not isCreature(v.uid) then
			return v
		end
		p.stackpos = p.stackpos + 1
		v = getThingfromPos(p)
	end
end
usage:
LUA:
local it = getTopItem(position)
if it.itemid == 1234 then
	doRemoveItem(it.uid)
end
 
Back
Top