- Joined
- Nov 17, 2010
- Messages
- 6,832
- Solutions
- 586
- Reaction score
- 5,414
Add into lib -> 050-function, or into specific scripts using 'local function bah blah'
Simple example to show functionality
Code:
function getItemCountFromPosition(item, pos)
local item_pos = {x = pos.x, y = pos.y, z = pos.z}
local item_count = 0
for i = 1, 255 do
local check_pos = {x = item_pos.x, y = item_pos.y, z = item_pos.z, stackpos = i}
if getThingFromPos(check_pos).itemid <= 0 then
break
elseif getThingFromPos(check_pos).itemid == item then
if isItemStackable(getThingFromPos(check_pos).itemid) == true then
item_count = item_count + getThingFromPos(check_pos).type
else
item_count = item_count + 1
end
end
end
return item_count
end
Code:
local item_id = 2544 -- standard arrow
local item_pos = {x = 1000, y = 1000, z = 7}
if getItemCountFromPosition(item_id, item_pos) >= 500 then
print(">= 500 or more items on position!")
else
print("< 500 items on position.")
end