Hello, I'm new to this forum and it's my first time messing with it (so much that my English is not the best), I'm kind of having problems with a code I'm making and would be grateful if they told me what I did wrong, it was supposed to this npc i'm creating, when colliding with a block or another npc change the direction, but it keeps walking even if it has already collided with a block and he was also supposed to change direction when a cliff appeared, but even with the "cliffturn = true" option, he still falls off cliffs
v.speedX = 1 * v.direction
if v.direction == -1 then
v.animationFrame = math.floor(lunatime.tick() / 4) % 2
else
v.animationFrame = (math.floor(lunatime.tick() / 4) % 2) + 2
end
if v.collidesBlockLeft or v.collidesBlockRight then
v.speedX = -1 * v.direction
if v.direction == 1 then
v.animationFrame = (math.floor(lunatime.tick() / 4) % 2) + 2
else
v.animationFrame = math.floor(lunatime.tick() / 4) % 2
end
end