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

About search of stairs and holes

Venoz

New Member
Joined
Jun 15, 2018
Messages
4
Reaction score
1
I need a help here.
I need to find in a area what is stairs and holes.
I made a list (n1, n2, n3 and n4) for the differents purposes of my script and also made this:

Lua:
for j = selfPosition.y - 6, selfPosition.y + 7 do
   
        for i = selfPosition.x - 8, selfPosition.x + 9 do
       
            if selfPosition.z < targetPosition.z then -- Andar Superior
       
                tile = Tile({x = i, y = j, z = selfPosition.z})
               
                if tile then
               
                    testground = tile:getGround()
                    if testground then
                        groundId = testground:getId()
                    else
                        groundId = nil
                    end
                   
                    tileitems = tile:getItems()
                    if not tileitems then
                        tileitems = nil
                    end
               
                end
               
                if groundId then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) and isInArray(n4,groundId) then
                        floorgo[c] = {4, {x = i, y = j, z = selfPosition.z}}
                        c = c + 1
                    end
               
                elseif tileitems then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) then
                        for l = 1, #tileitems do
                            if isInArray(n3, tileitems[l]:getId()) then
                                floorgo[c] = {3, {x = i, y = j, z = selfPosition.z}}
                                c = c + 1
                            end
                        end
                    end
                end               
               
            else
           
                tile = Tile({x = i, y = j, z = selfPosition.z})
               
                if tile then
               
                    testground = tile:getGround()
                    if testground then
                        groundId = testground:getId()
                    else
                        groundId = nil
                    end
                   
                    tileitems = tile:getItems()
                    if not tileitems then
                        tileitems = nil
                    end
               
                end
               
                if groundId then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) and isInArray(n1,groundId) then
                        floorgo[c] = {1, {x = i, y = j, z = selfPosition.z}}
                        c = c + 1
                    end
               
                elseif tileitems then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) then
                        for l = 1, #tileitems do
                            if isInArray(n2,tileitems[l]:getId()) then
                                floorgo[c] = {2, {x = i, y = j, z = selfPosition.z}}
                                c = c + 1
                            elseif isInArray(n1,tileitems[l]:getId()) then
                                floorgo[c] = {1, {x = i, y = j, z = selfPosition.z}}
                                c = c + 1
                            end
                        end
                    end
                end       
            end
        end
    end

The problem is: "tile:getItems()" do not get the static items. How can I do that?
Another thing, I tried to use "tile:hasFlag(flag)" too, but I'm stucked on the same thing, how can I find the stairs? (Usable and walkable)
 
I need a help here.
I need to find in a area what is stairs and holes.
I made a list (n1, n2, n3 and n4) for the differents purposes of my script and also made this:

Lua:
for j = selfPosition.y - 6, selfPosition.y + 7 do
 
        for i = selfPosition.x - 8, selfPosition.x + 9 do
     
            if selfPosition.z < targetPosition.z then -- Andar Superior
     
                tile = Tile({x = i, y = j, z = selfPosition.z})
             
                if tile then
             
                    testground = tile:getGround()
                    if testground then
                        groundId = testground:getId()
                    else
                        groundId = nil
                    end
                 
                    tileitems = tile:getItems()
                    if not tileitems then
                        tileitems = nil
                    end
             
                end
             
                if groundId then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) and isInArray(n4,groundId) then
                        floorgo[c] = {4, {x = i, y = j, z = selfPosition.z}}
                        c = c + 1
                    end
             
                elseif tileitems then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) then
                        for l = 1, #tileitems do
                            if isInArray(n3, tileitems[l]:getId()) then
                                floorgo[c] = {3, {x = i, y = j, z = selfPosition.z}}
                                c = c + 1
                            end
                        end
                    end
                end             
             
            else
         
                tile = Tile({x = i, y = j, z = selfPosition.z})
             
                if tile then
             
                    testground = tile:getGround()
                    if testground then
                        groundId = testground:getId()
                    else
                        groundId = nil
                    end
                 
                    tileitems = tile:getItems()
                    if not tileitems then
                        tileitems = nil
                    end
             
                end
             
                if groundId then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) and isInArray(n1,groundId) then
                        floorgo[c] = {1, {x = i, y = j, z = selfPosition.z}}
                        c = c + 1
                    end
             
                elseif tileitems then
                    if self:getPathTo({x = i, y = j, z = selfPosition.z}) then
                        for l = 1, #tileitems do
                            if isInArray(n2,tileitems[l]:getId()) then
                                floorgo[c] = {2, {x = i, y = j, z = selfPosition.z}}
                                c = c + 1
                            elseif isInArray(n1,tileitems[l]:getId()) then
                                floorgo[c] = {1, {x = i, y = j, z = selfPosition.z}}
                                c = c + 1
                            end
                        end
                    end
                end     
            end
        end
    end

The problem is: "tile:getItems()" do not get the static items. How can I do that?
Another thing, I tried to use "tile:hasFlag(flag)" too, but I'm stucked on the same thing, how can I find the stairs? (Usable and walkable)
You'd have to use these.

Lua:
    TILESTATE_FLOORCHANGE
    TILESTATE_FLOORCHANGE_DOWN
    TILESTATE_FLOORCHANGE_NORTH
    TILESTATE_FLOORCHANGE_SOUTH
    TILESTATE_FLOORCHANGE_EAST
    TILESTATE_FLOORCHANGE_WEST
    TILESTATE_FLOORCHANGE_SOUTH_ALT
    TILESTATE_FLOORCHANGE_EAST_ALT

Or you could create an array including all id's of stairs and holes.
 
Ok, but how?

tile:hasFlag(TILESTATE_FLOORCHANGE)?

And yes, I created an array (n1, n2, n3 and n4), the problem is, how can I get the ID of the stairs? Walkable and usable.
 
Ok, but how?

tile:hasFlag(TILESTATE_FLOORCHANGE)?

And yes, I created an array (n1, n2, n3 and n4), the problem is, how can I get the ID of the stairs? Walkable and usable.
If I'm understanding you right, you want to check a tile to see if it has a stairs or hole, right?

If so these options are what you need to be doing.

Lua:
local stairs = {1385, 1396}

for _, item in pairs(tile:getItems()) do
    if isInArray(stairs, item.itemid) then
        -- do your stuff
    end
end

or

Lua:
if tile:hasFlag(TILESTATE_FLOORCHANGE) then
    -- do your stuff
end
 
Back
Top