roriscrave
Advanced OT User
- Joined
- Dec 7, 2011
- Messages
- 1,210
- Solutions
- 35
- Reaction score
- 206
My player is in pos: "Position: 360, 734, 7"
And i'm looking for the south: "360, 735, 7"
firt code:
this first code print incorrect newPos, look it:

and this second script, all prints correct, but why it occours??
i have only changed line 4.

resume:
if i use this form, the script dont work fine:
and if i use this form, all works fine
but i don't know why it happens, could someone explain to me?
And i'm looking for the south: "360, 735, 7"
firt code:
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPos = player:getPosition()
local direction = player:getDirection()
local newPos = playerPos:getNextPosition(direction)
print("You are in pos: "..playerPos.x..", "..playerPos.y..".")
print("You are looking pos: "..newPos.x..", "..newPos.y..".")
return true
end
this first code print incorrect newPos, look it:

and this second script, all prints correct, but why it occours??
i have only changed line 4.
LUA:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPos = player:getPosition()
local direction = player:getDirection()
local newPos = player:getPosition():getNextPosition(direction)
print("You are in pos: "..playerPos.x..", "..playerPos.y..".")
print("You are looking pos: "..newPos.x..", "..newPos.y..".")
return true
end

resume:
if i use this form, the script dont work fine:
LUA:
local direction = player:getDirection()
local playerPos = player:getPosition()
local newPos = playerPos:getNextPosition(direction)
and if i use this form, all works fine
LUA:
local direction = player:getDirection()
local newPos = player:getPosition():getNextPosition(direction)
but i don't know why it happens, could someone explain to me?