Help with lunalua!

Need help with any SMBX game-related issues? Ask your questions here.
User avatar
KnuckleChuckle
Cheep-Cheep
Cheep-Cheep
Posts: 11
Joined: Mon Jul 23, 2018 10:06 pm
Current Project: Super Mario Metroidvania
Chat Username: notsafeforchuckles

Help with lunalua!

Postby KnuckleChuckle » Sat Jan 04, 2020 10:53 pm

This is my first post here, so I'm kind of a beginner, but I've been trying to make a code that lets you switch to peach by pressing 2 on the keyboard. Here's the code i tried:
function onStart()
if onKeyboardPress(0x32)
then Misc.cheatBuffer("ibakedacakeforyou")
end
end


However, i keep getting errors in which I don't understand. If any one could fix the code up, or provide me with a different code, that would be much appreciated!

MarioLover64
Hoopster
Hoopster
Posts: 150
Joined: Fri Apr 26, 2019 6:09 pm

Re: Help with lunalua!

Postby MarioLover64 » Sun Jan 05, 2020 1:01 am

Could you provide the error?

User avatar
KnuckleChuckle
Cheep-Cheep
Cheep-Cheep
Posts: 11
Joined: Mon Jul 23, 2018 10:06 pm
Current Project: Super Mario Metroidvania
Chat Username: notsafeforchuckles

Re: Help with lunalua!

Postby KnuckleChuckle » Sun Jan 05, 2020 2:12 am

==> worlds/Testing/Take 3./luna.lua:7: attempt to call global
'onKeyboardPress'(a nil value)
=============
stack traceback:
scripts/base/engine/main_events.lua:124:in function
'callEventInternal'
scripts/base/engine/main_events.lua180: in function
<scripts/base/engine/main_events.lua:158>
[C]: in function'_xpcall'
main.lua:508: in function <main.lua:507

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 7934
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Help with lunalua!

Postby Enjl » Sun Jan 05, 2020 3:35 am

onKeyboardPress is an event, just like onStart. It takes one argument, that being the keycode. All keycodes route into the same event.
function onKeyboardPress(keycode)
if keycode == 0x32 then
player:transform(CHARACTER_PEACH)
end
end
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
KnuckleChuckle
Cheep-Cheep
Cheep-Cheep
Posts: 11
Joined: Mon Jul 23, 2018 10:06 pm
Current Project: Super Mario Metroidvania
Chat Username: notsafeforchuckles

Re: Help with lunalua!

Postby KnuckleChuckle » Sun Jan 05, 2020 1:25 pm

Thank you!

Added in 5 minutes 45 seconds:
Can I do the same thing but for Mario on the same script?

MarioLover64
Hoopster
Hoopster
Posts: 150
Joined: Fri Apr 26, 2019 6:09 pm

Re: Help with lunalua!

Postby MarioLover64 » Sun Jan 05, 2020 1:33 pm

elseif would work


Return to “Help and Support”

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 3 guests