Events 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

Events with lunalua

Postby KnuckleChuckle » Wed Jan 15, 2020 7:04 pm

Another quick question on here. Is it possible to activate a lunalua script with events?

User avatar
FireyPaperMario
Peach
Peach
Posts: 5485
Joined: Sat Sep 27, 2014 1:39 pm
Flair: 90's kid born in late 1993 ^_^
Current Project: Too many things atm! Welp! :(
Chat Username: Shin FireyPaperMario
Contact:

Re: Events with lunalua

Postby FireyPaperMario » Wed Jan 15, 2020 7:19 pm

It is 100% possible to active events using Lunalua! But can you explain what events you were thinking of?
Custom Mega Drive playables (Mega Drive GFX Pack coming soon)
Mario RPG Goals (67% complete)
I have Autism & ADHD.
Pokémon Home: QRGBGBRYUKQD

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: Events with lunalua

Postby KnuckleChuckle » Wed Jan 15, 2020 8:20 pm

So i'm trying to activate a code that lets the player switch characters by the push of a button, and its supposed to activate once you talk to peach, because then talking to her would activate the event.

User avatar
8lue Storm
Volcano Lotus
Volcano Lotus
Posts: 519
Joined: Thu Jan 18, 2018 9:53 am
Flair: its pronounced bluestorm
Current Project: Many, MANY stuff
Chat Username: 8luestorm

Re: Events with lunalua

Postby 8lue Storm » Wed Jan 15, 2020 9:18 pm

KnuckleChuckle wrote:
Wed Jan 15, 2020 8:20 pm
So i'm trying to activate a code that lets the player switch characters by the push of a button, and its supposed to activate once you talk to peach, because then talking to her would activate the event.
Wait, so you gain the ability of switching characters after talking to Peach or do you switch characters right after talking to Peach?
Image

i never performed a shelljump and it's sad I did a grand total of 4 shelljumps in my life!

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: Events with lunalua

Postby KnuckleChuckle » Wed Jan 15, 2020 9:25 pm

You gain the ability

User avatar
Daring Tombstone
Bit
Bit
Posts: 141
Joined: Mon Aug 28, 2017 10:57 pm
Flair: What? Not 1000 posts? That means I suck right?
Current Project: Something Maybe
Chat Username: Chaperone

Re: Events with lunalua

Postby Daring Tombstone » Thu Jan 16, 2020 12:17 am

Assuming this what you're asking here's an example.

Image

Nevermind I'm a special kind of stupid.
Last edited by Daring Tombstone on Thu Jan 16, 2020 1:57 am, edited 1 time in total.
Happy Dance
Image
Check out my completed episode
Spoiler: show
Image
Check out my halloween level
Spoiler: show
Image

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

Re: Events with lunalua

Postby Enjl » Thu Jan 16, 2020 1:07 am

Daring Tombstone wrote:
Thu Jan 16, 2020 12:17 am
Assuming this what you're asking here's an example.

Image

Pretty simple yeah?
Not quite. The behaviour expected is an unlock, from what I gather. So, instead of putting all the code into onEvent, it would be better to use onEvent to toggle a boolean variable that otherwise gates off the code that runs in other events like onTick (for input checking and logic) and onDraw (if there are any components to draw to the screen).
Image
Setting "canSwitchCharacters" to true in onEvent would be emblematic of the action of "gaining the ability", since it allows the code inside the if statement in other events to execute.

In the spoiler below is a version that permanently sets the variable for the episode, even across levels (MAGLX3 build, PAL build and newer versions only):
Spoiler: show
Image
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: Events with lunalua

Postby KnuckleChuckle » Thu Jan 16, 2020 7:05 pm

hmmm. On event never seems to work for me. I keep getting the error end is expected(to close function at line 1) near <eof>. But when I add end it says <eof> expected near end.

User avatar
Hoeloe
Grinder
Grinder
Posts: 1132
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Events with lunalua

Postby Hoeloe » Thu Jan 16, 2020 8:14 pm

That suggests you're adding it in completely the wrong place. Copy the format shown above, and if it still doesn't work, post your code 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

Re: Events with lunalua

Postby KnuckleChuckle » Thu Jan 16, 2020 9:11 pm

SaveData.canSwitchCharacters = false
function onEvent(eventName)
if eventName == "Transformation" then
SaveData.canSwitchCharacters = true
end
end


function onTick()
if SaveData.canSwitchCharacters then
function onKeyboardPress(keycode)
if keycode == 0x31 then
player:transform(CHARACTER_MARIO)
elseif keycode == 0x32 then
player:transform(CHARACTER_PEACH)
elseif keycode == 0x33 then
player:transform(CHARACTER_TOAD)
end
end
end
end

User avatar
Daring Tombstone
Bit
Bit
Posts: 141
Joined: Mon Aug 28, 2017 10:57 pm
Flair: What? Not 1000 posts? That means I suck right?
Current Project: Something Maybe
Chat Username: Chaperone

Re: Events with lunalua

Postby Daring Tombstone » Thu Jan 16, 2020 9:31 pm

You can't have a function in a function I don't believe. You would need to end function ontick before starting function onkeyboardpress. But I would see what a lua expert says.
Happy Dance
Image
Check out my completed episode
Spoiler: show
Image
Check out my halloween level
Spoiler: show
Image

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: Events with lunalua

Postby KnuckleChuckle » Thu Jan 16, 2020 10:31 pm

Image

User avatar
Daring Tombstone
Bit
Bit
Posts: 141
Joined: Mon Aug 28, 2017 10:57 pm
Flair: What? Not 1000 posts? That means I suck right?
Current Project: Something Maybe
Chat Username: Chaperone

Re: Events with lunalua

Postby Daring Tombstone » Fri Jan 17, 2020 12:58 am

Would you need onTick here? Can't we just do something like.

function onKeyBoardPress(keycode)
if SaveData.canSwitchCharacters == true then
if keycode == 0x31 then
player:transform(CHARACTER_MARIO)
elseif keycode == 0x32 then
player:transform(CHARACTER_PEACH)
end
end
end

Or is this not the right way to do this? I'm a lua noob myself. Also in your script if SaveData.canSwitchCharacters needs a double ='s since it's checking the boolean.
Happy Dance
Image
Check out my completed episode
Spoiler: show
Image
Check out my halloween level
Spoiler: show
Image

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

Re: Events with lunalua

Postby Enjl » Fri Jan 17, 2020 1:18 am

OnKeyboardPress is inconvenient because it assumes players never change their control layout. Imagine setting the keys to Q and E just to find out someone plays your level with a controller. Whoops!
But if you really wanna do this, then Daring Tombstone's suggestion is right. In my prior post when I suggested onTick for input checking I assumed you wanted to make use of the inputs SMBX already recognizes.
ImageImageImageImage
ImageImageImageImageImageImage


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 4 guests

cron