• 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 check if player walks diagonally

Ahilphino

Excellent OT User
Joined
Jun 5, 2013
Messages
1,667
Solutions
1
Reaction score
726
Code:
function onStepIn(cid, item, position, fromPosition)
    local diagonalCheck = (fromPosition.y - position.y) - (fromPosition.x - position.x)
    if diagonalCheck == -1 or diagonalCheck == 1 then
        print("nice u are walking in straight line and not diagonal")
    end
    return true
end

ok so this is working and everything but my solution seems a bit messy.

I just want an easy way to check if the player is walking diagonally or not. Right now it works as it should, but maybe there's some better way to check it. Just wondering. Thanks !
 
Last edited:
One way to check it would be to intercept the packet sent and pass it through to the function, thus having just onStepIn(..., bool sideStep = (op == sideStepOp)) but unless you plan to use this in pretty much every aspect of your onStepIn codes it really wouldn't be the way to go, just playing with the thought :3
 
Back
Top