[BUG] party:onMove hook
Posted: Sat Oct 13, 2012 11:40 pm
I spend a lot of time with polishing events based on "party:onMove". Results were tragic, so I did some console logs to track the problem. Now I have a simple code:
Testcase:
Start with
party.x = 0
party.x = 0
dir = 1 (east)
Try to move 4 steps in dir = 1 (loking east) and after that do one step west (keep dir=1 - looking east).
Console shows X = 5 but but your real location is party.x = 3
turning updates party.x and party.y into correct numbers
hitting obstacle updates party.x and party.y into correct numbers as well
Question:
What is wrong in my code
or
How to get party position, when movement is finished without spawning timer (0.5 sec is minimum) and asking Lua script for party pos etc...
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onMove = function(self, dir)
print("party location: ", "L=", self.level, "X=", self.x, "Y=", self.y, "MoveDir=", dir)
end,
onTurn = function(self, dir)
print("party location: ", "L=", self.level, "X=", self.x, "Y=", self.y, "TirnDir=", dir)
end,
}Start with
party.x = 0
party.x = 0
dir = 1 (east)
Try to move 4 steps in dir = 1 (loking east) and after that do one step west (keep dir=1 - looking east).
Console shows X = 5 but but your real location is party.x = 3
turning updates party.x and party.y into correct numbers
hitting obstacle updates party.x and party.y into correct numbers as well
Question:
What is wrong in my code
or
How to get party position, when movement is finished without spawning timer (0.5 sec is minimum) and asking Lua script for party pos etc...