Hook Actor:move - working as intended?
Posted: Tue Nov 05, 2013 2:55 pm
Hey,
I was using the the hook to check if the player is still in a zone of an effect:
data.ox and data.oy are the coordinates from where the char starts his movement and not the ones where he finally arrives, am I right? If so, does it work as intended?
I assumed, the hook is used to do stuff after the movement so the new position coordinates would be more helpful.
Cheers:)
I was using the the hook
Code: Select all
self:triggerHook{"Actor:move", moved=moved, force=force, ox=ox, oy=oy}
Code: Select all
class:bindHook("Actor:move", function(self, data)
if data.moved and self:hasEffect(self.EFF_CRIMSON_FOG) then
local isInCrimsonFog = 0
game.logPlayer(self, "data.x: %s, data.y: %s",data.ox,data.oy)
for i, e in ipairs(game.level.map.effects) do
if e.damtype == DamageType.CRIMSON_FOG and e.grids[data.ox] and e.grids[data.ox][data.oy]
then isInCrimsonFog = 1 end
end
game.logPlayer(self, "isInCrimsonFog: %s",isInCrimsonFog)
if isInCrimsonFog == 0 then
self:removeEffect(self.EFF_CRIMSON_FOG)
game.logPlayer(self, "EFF_CRIMSON_FOG removed")
end
end
end)
I assumed, the hook is used to do stuff after the movement so the new position coordinates would be more helpful.
Cheers:)