Adding an “Exit Level” Option

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

Moderator: Userbase Moderators

Lunar Chris
Tweeter
Tweeter
Posts: 134
Joined: Mon Jan 06, 2014 9:51 pm
Flair: Moon Lord's Servant
Contact:

Adding an “Exit Level” Option

Postby Lunar Chris » Tue Feb 01, 2022 7:42 am

Hi all. I feel many people are annoyed by this, myself included, but I really hate how the only way you can exit mid-level in an episode is by exiting the game itself. Does anyone know if there exists a script that adds in the option to exit the level, just so nobody has to exit the episode itself, or if there exists something similar?

deice
Rocky Wrench
Rocky Wrench
Posts: 638
Joined: Fri Jul 23, 2021 7:35 am

Re: Adding an “Exit Level” Option

Postby deice » Tue Feb 01, 2022 7:59 am

to exit a level without triggering any type of victory, use:

Code: Select all

Level.exit(LEVEL_WIN_TYPE_NONE)
where this is called is up to individual implementation. most likely either through a hotkey or through a custom pause menu. while there aren't any ready-made scripts that have been published here that provide such functionality (to my knowledge), some lua-heavy episodes (e.g. maglx3) likely have good examples.

Lunar Chris
Tweeter
Tweeter
Posts: 134
Joined: Mon Jan 06, 2014 9:51 pm
Flair: Moon Lord's Servant
Contact:

Re: Adding an “Exit Level” Option

Postby Lunar Chris » Fri Feb 11, 2022 1:29 pm

deice wrote:
Tue Feb 01, 2022 7:59 am
to exit a level without triggering any type of victory, use:

Code: Select all

Level.exit(LEVEL_WIN_TYPE_NONE)
where this is called is up to individual implementation. most likely either through a hotkey or through a custom pause menu. while there aren't any ready-made scripts that have been published here that provide such functionality (to my knowledge), some lua-heavy episodes (e.g. maglx3) likely have good examples.
So without changing this, all I have is an endless cycle of loading screens. How do I set up a hotkey for the function to work?

deice
Rocky Wrench
Rocky Wrench
Posts: 638
Joined: Fri Jul 23, 2021 7:35 am

Re: Adding an “Exit Level” Option

Postby deice » Fri Feb 11, 2022 5:25 pm

PikaChris wrote:
Fri Feb 11, 2022 1:29 pm
How do I set up a hotkey for the function to work?
something like this should work:

Code: Select all

local checkKey = VK_CONTROL  --which key to exit on

function onKeyboardPress(keyCode)
	if(checkKey == keyCode) then
		Level.exit(LEVEL_WIN_TYPE_NONE)
	end
end
the full list of usable keys to assign can be found here.
please note though that while this is the easier option when compared to making a custom pause menu, it has the potential to absolutely ruin people who use alternative control schemes, and making it configurable by the user is probably comparable in complexity to implementing your own navigatable pause menu, so for inexperienced lunalua users it's a bit of a "pick your poison" kind of situation.


Return to “LunaLua Help”

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari