onFunction Question

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

tulipkapy
Goomba
Goomba
Posts: 1
Joined: Sat Jun 27, 2020 9:47 pm

onFunction Question

Postby tulipkapy » Sat Jun 27, 2020 9:49 pm

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?

MrDoubleA
Edward
Edward
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: onFunction Question

Postby MrDoubleA » 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

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: onFunction Question

Postby Emral » Sun Jun 28, 2020 8:31 am

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

MrDoubleA
Edward
Edward
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: onFunction Question

Postby MrDoubleA » Sun Jun 28, 2020 10:41 am

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.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari