Auto-loading next level after winning • levellist.lua

Share and discuss custom LunaLua code and content packs for SMBX2.
LooKiCH
Tweeter
Tweeter
Posts: 159
Joined: Tue Jun 13, 2017 11:28 am
Pronouns: he/him
Contact:

Auto-loading next level after winning • levellist.lua

Postby LooKiCH » Sun Oct 30, 2022 11:47 am

A script that allows you to immediately load next level after winning

gifs: show

ImageImage
(Episode: Project RW by Doki)

DOWNLOAD v.1.1
(currently, it works even when Level.exit(w) runs and when game is paused and fixed some bugs)

how to use: show
In file "luna.lua" (and "map.lua" if worldmap in episode is enabled) paste the code:

Code: Select all

require("levellist").levels = {"level1.lvlx","level2.lvlx","level3.lvlx"}
-- in {} paste the filenames of your levels in ascending order
-- BOTH MAP.LUA AND LUNA.LUA MUST HAVE THE SAME LEVEL LIST VALUE!
Last edited by LooKiCH on Sun Jan 21, 2024 6:36 am, edited 6 times in total.

Wiimeiser
Snifit
Snifit
Posts: 215
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: Auto-loading next level after winning • levellist.lua

Postby Wiimeiser » Fri Nov 04, 2022 9:20 pm

I wonder if skips/Warp Zones are possible...

HAK0TA538
Bob-Omb
Bob-Omb
Posts: 22
Joined: Wed Oct 18, 2023 11:57 pm
Flair: Lua is cool
Pronouns: He/Him

Re: Auto-loading next level after winning • levellist.lua

Postby HAK0TA538 » Thu Nov 09, 2023 10:30 am

Does this work for cutscenes? As in can i get a specific level, and make another level play after it. But not the level after that one

Just_Thomas
Spike
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: Auto-loading next level after winning • levellist.lua

Postby Just_Thomas » Sun Dec 17, 2023 6:18 am

I want to report a bug: If you play a couple of levels and you "save and quit" and then trying to restart from a "saved game" (menu) and does load the first level again - as like it should. HOWEVER: Everything is rendered black on the screen, the level is loaded through, I checked that based on collision, played npcs, music etc. but for some strange reason, it is just ... black on the screen.
By deleting the save game data it works again... until next time that is.
Some background information: I want to create a level pack in the old NES Super Mario Bros. or Super Mario Land style on Gameboy.
That means: Play everything in one go or until you go gameover. Apart from this bug it does work.

Could you please fix that somehow?

Just_Thomas
Spike
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: Auto-loading next level after winning • levellist.lua

Postby Just_Thomas » Sat Jan 20, 2024 2:56 pm

LooKiCH wrote:
Sun Oct 30, 2022 11:47 am

A script that allows you to immediately load next level after winning

gifs: show

ImageImage
(Episode: Project RW by Doki)

DOWNLOAD

how to use: show
In file "luna.lua" (and "map.lua" if worldmap in episode is enabled) paste the code:

Code: Select all

require("levellist").levels = {"level1.lvlx","level2.lvlx","level3.lvlx"}
-- in {} paste the filenames of your levels in ascending order
-- BOTH MAP.LUA AND LUNA.LUA MUST HAVE THE SAME LEVEL LIST VALUE!
Apart from the bug mentioned above: For my SMB1-like project, I have been able to largely eliminate various problems and thanks to "hearts for all" from AppleTheTomato, Emral for his patience in many cases and of course you, the technical basis is now finally in place. Yes, the project is supposed to be reminiscent of the old days, no save point, (extra) lives still play a role etc..
So I really had to hope that the right missing components would finally come together.
And then there's the SMB1 flagpole from Murphmario.
viewtopic.php?t=28020

Well, unfortunately it doesn't work with your script here. I don't know whether he has somehow programmed a new type of goal or whether it isn't one in the sense of the word. Your script works with the standard SMBX goals, but unfortunately not with his flagpole.
Could you find out what the problem is? Is it possible to add new NPCs or something similar to your script? I can also show you what I've worked out so far. The SMB3 goal or something similar literally ruins the atmosphere.

Could you please take a look?

LooKiCH
Tweeter
Tweeter
Posts: 159
Joined: Tue Jun 13, 2017 11:28 am
Pronouns: he/him
Contact:

Re: Auto-loading next level after winning • levellist.lua

Postby LooKiCH » Sun Jan 21, 2024 5:01 am

because when running the Level.exit(w) function (that’s how it’s written in the flagpole script), the onLevelExit(w) function, created in my file will not run, but in other cases (in cases with vanilla exits or the Level.winState(w) function, Level.finish(w) or other) will run. But the solution is recreating the Level.exit(w) function (copy from ffi_level.lua), which is what I did:
Download
Just_Thomas wrote:
Sat Jan 20, 2024 2:56 pm
LooKiCH wrote:
Sun Oct 30, 2022 11:47 am

A script that allows you to immediately load next level after winning

gifs: show

ImageImage
(Episode: Project RW by Doki)

DOWNLOAD

how to use: show
In file "luna.lua" (and "map.lua" if worldmap in episode is enabled) paste the code:

Code: Select all

require("levellist").levels = {"level1.lvlx","level2.lvlx","level3.lvlx"}
-- in {} paste the filenames of your levels in ascending order
-- BOTH MAP.LUA AND LUNA.LUA MUST HAVE THE SAME LEVEL LIST VALUE!
Apart from the bug mentioned above: For my SMB1-like project, I have been able to largely eliminate various problems and thanks to "hearts for all" from AppleTheTomato, Emral for his patience in many cases and of course you, the technical basis is now finally in place. Yes, the project is supposed to be reminiscent of the old days, no save point, (extra) lives still play a role etc..
So I really had to hope that the right missing components would finally come together.
And then there's the SMB1 flagpole from Murphmario.
viewtopic.php?t=28020

Well, unfortunately it doesn't work with your script here. I don't know whether he has somehow programmed a new type of goal or whether it isn't one in the sense of the word. Your script works with the standard SMBX goals, but unfortunately not with his flagpole.
Could you find out what the problem is? Is it possible to add new NPCs or something similar to your script? I can also show you what I've worked out so far. The SMB3 goal or something similar literally ruins the atmosphere.

Could you please take a look?
Added in 15 minutes 3 seconds:
fixed
Just_Thomas wrote:
Sun Dec 17, 2023 6:18 am
I want to report a bug: If you play a couple of levels and you "save and quit" and then trying to restart from a "saved game" (menu) and does load the first level again - as like it should. HOWEVER: Everything is rendered black on the screen, the level is loaded through, I checked that based on collision, played npcs, music etc. but for some strange reason, it is just ... black on the screen.
By deleting the save game data it works again... until next time that is.
Some background information: I want to create a level pack in the old NES Super Mario Bros. or Super Mario Land style on Gameboy.
That means: Play everything in one go or until you go gameover. Apart from this bug it does work.

Could you please fix that somehow?

Just_Thomas
Spike
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: Auto-loading next level after winning • levellist.lua

Postby Just_Thomas » Sun Jan 21, 2024 5:27 am

LooKiCH wrote:
Sun Jan 21, 2024 5:16 am
because when running the Level.exit(w) function (that’s how it’s written in the flagpole script), the onLevelExit(w) function, created in my file will not run, but in other cases (in cases with vanilla exits or the Level.winState(w) function, Level.finish(w) or other) will run. But the solution is recreating the Level.exit(w) function (copy from ffi_level.lua), which is what I did:
Download
Thanks for providing fixes and support. The flagpole thing is unfortunately still the same issue.
After completing the level the actual completed level loads again and I start from the last checkpoint. Have I done something wrong on my side?
I don't want to rule out human error for my own sake. At the end it is so easy to forget simple things sometimes.

This is BOTH in the luna of each level and the main project itself and it did work with the SMB3 roulette card goal.
require("levellist").levels = {"level01.lvlx","level02.lvlx"}
And your levellist.lua is in the project folder of course.

It really is unfortunate the SMB1 flagpole goal is not part of the default assets in SMBX, while nearly any other thinkable exit is for decades.

LooKiCH
Tweeter
Tweeter
Posts: 159
Joined: Tue Jun 13, 2017 11:28 am
Pronouns: he/him
Contact:

Re: Auto-loading next level after winning • levellist.lua

Postby LooKiCH » Sun Jan 21, 2024 5:56 am

try this version https://www.dropbox.com/s/10718li0e414u ... t.lua?dl=0
Just_Thomas wrote:
Sun Jan 21, 2024 5:27 am
LooKiCH wrote:
Sun Jan 21, 2024 5:16 am
because when running the Level.exit(w) function (that’s how it’s written in the flagpole script), the onLevelExit(w) function, created in my file will not run, but in other cases (in cases with vanilla exits or the Level.winState(w) function, Level.finish(w) or other) will run. But the solution is recreating the Level.exit(w) function (copy from ffi_level.lua), which is what I did:
Download
Thanks for providing fixes and support. The flagpole thing is unfortunately still the same issue.
After completing the level the actual completed level loads again and I start from the last checkpoint. Have I done something wrong on my side?
I don't want to rule out human error for my own sake. At the end it is so easy to forget simple things sometimes.

This is BOTH in the luna of each level and the main project itself and it did work with the SMB3 roulette card goal.
require("levellist").levels = {"level01.lvlx","level02.lvlx"}
And your levellist.lua is in the project folder of course.

It really is unfortunate the SMB1 flagpole goal is not part of the default assets in SMBX, while nearly any other thinkable exit is for decades.
Added in 2 minutes 37 seconds:
at the moment yes
Wiimeiser wrote:
Fri Nov 04, 2022 9:20 pm
I wonder if skips/Warp Zones are possible...
Added in 45 seconds:
use Level.exit()
HAK0TA538 wrote:
Thu Nov 09, 2023 10:30 am
Does this work for cutscenes? As in can i get a specific level, and make another level play after it. But not the level after that one

Just_Thomas
Spike
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: Auto-loading next level after winning • levellist.lua

Postby Just_Thomas » Sun Jan 21, 2024 6:19 am

LooKiCH wrote:
Sun Jan 21, 2024 6:00 am
try this version https://www.dropbox.com/s/10718li0e414u ... t.lua?dl=0
I did replace it and ... still not working. I see no change in this matter.

BUT the "black screen bug" with the save file I mentioned, that one is actually really gone.

LooKiCH
Tweeter
Tweeter
Posts: 159
Joined: Tue Jun 13, 2017 11:28 am
Pronouns: he/him
Contact:

Re: Auto-loading next level after winning • levellist.lua

Postby LooKiCH » Sun Jan 21, 2024 6:33 am

i have updated again https://www.dropbox.com/scl/fi/tdahpfim ... lmlwh&dl=0
Just_Thomas wrote:
Sun Jan 21, 2024 6:19 am
LooKiCH wrote:
Sun Jan 21, 2024 6:00 am
try this version https://www.dropbox.com/s/10718li0e414u ... t.lua?dl=0
I did replace it and ... still not working. I see no change in this matter.

BUT the "black screen bug" with the save file I mentioned, that one is actually really gone.

Just_Thomas
Spike
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: Auto-loading next level after winning • levellist.lua

Postby Just_Thomas » Sun Jan 21, 2024 6:49 am

LooKiCH wrote:
Sun Jan 21, 2024 6:33 am
i have updated again https://www.dropbox.com/scl/fi/tdahpfim ... lmlwh&dl=0
Just_Thomas wrote:
Sun Jan 21, 2024 6:19 am
LooKiCH wrote:
Sun Jan 21, 2024 6:00 am
try this version https://www.dropbox.com/s/10718li0e414u ... t.lua?dl=0
I did replace it and ... still not working. I see no change in this matter.

BUT the "black screen bug" with the save file I mentioned, that one is actually really gone.
YES! :D
Nice job! Really wonderful.
At the moment I can not say anything about the SMB1 bowser (from same npc pack), as I have not tested him yet. But maybe this will work straight from the start with your new version as well.

(forgot to quote)

Just_Thomas
Spike
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: Auto-loading next level after winning • levellist.lua

Postby Just_Thomas » Mon Jan 22, 2024 12:16 pm

LooKiCH wrote:
Sun Oct 30, 2022 11:47 am
I got that idea indirectly from Emrals checkpoint-gameover "fix". I would be interested to know what you - however - think about it.
Doable? BS? Good idea?

So I wondered if it is possible for you or in general to include some kind of "fallback level" into your script?!

This should be an example of what I mean:
("levellist").levels = {"world1-1.lvlx","world1-2.lvlx","world1-3.lvlx","world1-4.lvlx","world2-1.lvlx","world2-2.lvlx","world2-3.lvlx","world2-4.lvlx","world3-1.lvlx", "...} etc
then a second list, which could be optional
("fallbacklevels").levels = {"world1-1.lvlx","world2-1.lvlx","world3-1.lvlx", "...} etc. which however would build up upon the levellist itself.
MAYBE as support also this:
("fallback-IDs").levels = {1,5,9..}

Let`s say there is some kind of "global variable" there (dunno if this is the right term, however it must be something like that which can be called from any level within the same project/mappack etc.)

On start the value is 0, as the player has not completed any level.
after completing "world1-1" it is 1
after completing "world1-2" it is 2
after completing "world1-3" it is 3
etc.

let`s also say the player goes gameover here, in "world1-3": He has to start over from "world1-1" because 2 < 5 ("world2-1" would be the real first or next fallback level with a value of 5, "world3-1" the next one after that with a value of 9) etc. so, if a player goes gameover within "world2-4" (from previous completed levels the variable would be set at 7, because player complted "world2-3"), the fallback level would be "world2-1", or rather value 5.

Like I said: I don`t know if this is really possible, however, as you were able to "manipulate" the system to create an order of levels, which were about to get loaded, once a previous was completed (instead of returning to the world map), I just thought that you could still manage something like that, as long as it's within luna's capabilities.

AFAIK in SMB on NES when you go gameover you have to start all over, while in the SNES Allstar version you restart from the current world, but this should just support that idea. What do you think about that?

Edit: Here is one more point why I had this idea.

Code: Select all

function onExitLevel()
	if player.deathTimer > 0 and mem(0x00B2C5AC,FIELD_FLOAT) == 0 then
	GameData = {}
	end
end
Let`s say, before this piece of code would be executed, the script would check for the last fallback-level and would store it in the current save file, would that work, or wouldn`t it?


Return to “LunaLua”

Who is online

Users browsing this forum: DRACalgar Law and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari