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

How to check?

ziomekzlasu

New Member
Joined
Sep 16, 2010
Messages
24
Reaction score
0
Hi everyone. Sorry for english. I don't have idea how to make function, that will check if on tile is item. For example - i have tile with id 190. If on this tile its ANY item (border, moutain, tree), funciton will return false.
Something like that :
if checkTile(x,y,z) == true (free) then
bla bla bla tile is free
else
bla bla bla tile is blocked

Can you make it for me? :)
 
Lua:
function isPosClear(pos)
    local tile = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})
    return (tile.uid ~= 0) and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not getTileInfo(pos).protection and not getTileInfo(pos).house
end

That should work...
 
Almost it works. When blocking item is on pos it returns false but i need function which return false when any item is on pos (no blocking too ;P ). So how to fix it? But thanks so much you get rep++. That function made my system much better.
 
Try this:

Lua:
function isPosClear(pos)
    local tile = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})
    local item = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})
    return (tile.uid ~= 0) and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not getTileInfo(pos).protection and not getTileInfo(pos).house and not item.itemid
end

Maybe that works... :S
 
Yes, thanks a lot - it works correctly. Can you help me with next problem? My script random draw a position from whole map. If on this position is blocking item, it will draw again. (thanks to you) But there are tiles wichout items/ground - just blank. When script draw blank position it makes error in engine log - i really dont like it. What condition i should do? I tried something like (its repeat loop) repeat .... until getThingFromPos ~= 0 and isPosClear == true. But i really thank you for that what you do :p
 
Back
Top