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

Lua Teleport all players and monsters to + 1 Z and stay their positions

  • Thread starter Thread starter Deleted member 141899
  • Start date Start date
D

Deleted member 141899

Guest
Hi, can someone help me to optimize this function?

Code:
function teleportArea(fromPos, toPos)
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = toPos.z, toPos.z do
                if(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                        teleport all from this area to + 1 Z position, and stay their positions
                end
            end
        end
    end
    return true
end
 
Hi, can someone help me to optimize this function?

Code:
function teleportArea(fromPos, toPos)
    for x = fromPos.x, toPos.x do
        for y = fromPos.y, toPos.y do
            for z = toPos.z, toPos.z do
                if(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                        teleport all from this area to + 1 Z position, and stay their positions
                end
            end
        end
    end
    return true
end
There is not much to optmize, if you want it to be faster you will need to do it in C++, however what you can do is use getSpectators instead of iterating through every position, that will be faster.
 
Back
Top