Page 1 of 1

onFunction Question

Posted: Sat Jun 27, 2020 9:49 pm
by tulipkapy
So I'm trying to make a level with a script that acts upon jumping.

??????????
if keycode == KEY_JUMP then
triggerEvent(string SWAP!);
end
end

what do I do for line 1 to make this script work?

Re: onFunction Question

Posted: Sun Jun 28, 2020 8:03 am
by MrDoubleA
Instead of detecting a key press you'd be better off using onJump, like this:

function onJump()
triggerEvent("a")
end

Re: onFunction Question

Posted: Sun Jun 28, 2020 8:31 am
by Emral
MrDoubleA wrote:
Sun Jun 28, 2020 8:03 am
Instead of detecting a key press you'd be better off using onJump, like this:

function onJump()
triggerEvent("a")
end
Is onJump reliable? Last I checked it doesn't work for short hops.

If you only want jumps that started on a solid ground surface, you could also try:

Code: Select all

function onTick()
   if player:isOnGround() and player.keys.jump == KEYS_PRESSED then
      -- do stuff
   end
end

Re: onFunction Question

Posted: Sun Jun 28, 2020 10:41 am
by MrDoubleA
Ah yeah, forgot about that. It seems to base it off of the offset that was thought to be "has jumped", but turns out it was if the player can do a purple yoshi ground pound.