This is actually really close!
The only issue I can see that would cause it to not work is that "onloop" should have a capital "L" instead of a lowercase "l".
Code: Select all
local playerDirection = 0;
function onloop()
playerDirection = player:mem(0x106, FIELD_WORD)
end
function onKeyDown(keycode)
if keycode == KEY_JUMP then
a = NPC.spawn(1, player.x, player.y - 128,player.section)
a.speedY = -2;
a.speedX = 5 * playerDirection;
end
end
Just be wary of a few things though. (1) onLoop is deprecated and onTick should be used instead. (2) onKeyDown isn't needed here and should be onInputUpdate instead in which you can check player.jumpKeyPressing. (3) Make sure you declare a in a local scape, like you've done playerDirection.
Code: Select all
local playerDirection = 0;
function onTick()
playerDirection = player:mem(0x106, FIELD_WORD)
end
function onInputUpdate()
if player.jumpKeyPressing then
local a = NPC.spawn(1, player.x, player.y - 128,player.section)
a.speedY = -2;
a.speedX = 5 * playerDirection;
end
end