Share and discuss custom LunaLua code and content packs for SMBX2.
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Fri Feb 21, 2020 9:54 am
This is a library which lets you have quick respawn and Celeste-styled rooms. You can even have no rooms for only quick respawn, if you so please.
NPC reset
Room transition + block reset
Event timer reset + star coins reset + "diamond sweep" respawn effect
In PGE
Options
Download & Installation: show
You can download it here.
To load it in, put this in your luna.lua file:
To create a room in the editor, make a layer named "Rooms" and put some bits of quicksand liquid which are the size of the rooms you want. In-game, they'll act as the actual rooms.
At the bottom of the rooms.lua file, there are a bunch of settings for you to tweak.
There are also some global lua events that you can use with it: onRoomEnter(roomIdx), and onReset(fromRespawn) (and the nicher variant, onBeforeReset(fromRespawn)).
Have fun, but please give credit if you use it!
Last edited by MrDoubleA on Fri Dec 11, 2020 5:02 pm, edited 6 times in total.
|
|
|
|
|
|
|
|
|
-
Enjl
- Cute Yoshi Egg

- Posts: 9017
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Orphion Egamalenitar Osmos IV, Esq.
Postby Enjl » Fri Feb 21, 2020 10:11 am
Does it invoke a custom lua event when a reset occurs or a room is entered? Would be helpful if people wanna reset their lua routines too. Sadly moving layers will always be a NIGHTMARE.
Look into registerCustomEvent if you wanna provide onEnter and onReset events.
Ideas are useless if you can't make them real.
All my assets from packs and episodes are free to use for non-Novaverse levels and projects, as long as proper credit is given.
Mirror of all my content and collaborations on IPFS: QmZKzVJAsD6dE2tTHEb58XEmsNLzrW2MVsTtW7HWLAAcCC
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Fri Feb 21, 2020 10:14 am
Enjl wrote: ↑Fri Feb 21, 2020 10:11 am
Does it invoke a custom lua event when a reset occurs or a room is entered? Would be helpful if people wanna reset their lua routines too. Sadly moving layers will always be a NIGHTMARE.
Look into registerCustomEvent if you wanna provide onEnter and onReset events.
I didn't know about registerCustomEvent, thanks! The makeshift solution I used is that there's a bunch of tables that you can put your functions in. I'll update it soon.
Edit: The download link's been updated. Adds two events (onRoomEnter(roomIdx) and onRespawnReset()), adds a new option, and fixes the transition between rooms that are in different sections.
|
|
|
|
|
|
|
|
|
-
Locus
- Bob-Omb

- Posts: 22
- Joined: Sun Mar 17, 2019 12:47 pm
Postby Locus » Fri Feb 21, 2020 3:02 pm
If I define the rooms with quicksand regions the quicksand physics still work and don't actually make me move as I would when I'm not stuck in it.
edit: I apologize I wasn't paying careful attention and forgot to name the layer
edit 2: I don't know if this happens for others but once you respawn the music stops. If a P-switch is pressed though it resets.
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Mon Mar 02, 2020 3:35 pm
Locus wrote: ↑Fri Feb 21, 2020 3:02 pm
If I define the rooms with quicksand regions the quicksand physics still work and don't actually make me move as I would when I'm not stuck in it.
edit: I apologize I wasn't paying careful attention and forgot to name the layer
edit 2: I don't know if this happens for others but once you respawn the music stops. If a P-switch is pressed though it resets.
About the last bit: you need to play music through lua if you want it not to stop after dying. Here's a bit of code to play the section music through lua. I may include a built-in fix in the next version, though!
|
|
|
|
|
|
|
|
|
-
thegameseum
- Spike

- Posts: 292
- Joined: Fri Aug 10, 2018 11:26 am
- Pronouns: they/them
-
Contact:
Postby thegameseum » Mon Mar 02, 2020 10:03 pm
Don't have my pc with me now, but if you collect a checkpoint, will it automatically start respawning you there?

walker guy
I believe and I accept Jesus Christ as my Lord and Savior. If you do, put this in your signature.
(GENERATION 30: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.)
I support:
|
|
|
|
|
|
|
|
|
-
Chipss
- Dolphin

- Posts: 84
- Joined: Fri Jul 25, 2014 9:47 pm
- Pronouns: he/him
-
Contact:
Postby Chipss » Tue Mar 03, 2020 12:58 am
thegameseum wrote: ↑Mon Mar 02, 2020 10:03 pm
Don't have my pc with me now, but if you collect a checkpoint, will it automatically start respawning you there?
Yes
|
|
|
|
|
|
|
|
|
-
Wiimeiser
- Tweeter

- Posts: 165
- Joined: Mon Jun 24, 2019 4:36 am
- Flair: What?
Postby Wiimeiser » Thu Mar 05, 2020 7:49 am
Transitions don't work, the game spams nil value errors and the camera doesn't respect the room boundaries. The respawning does work, but rooms are inoperable unless I set rooms.transitionType = rooms.TRANSITION_TYPE_NONE. It appears to be a conflict, but this is the only custom LUA I'm using in this test episode, so if that's true, then it's with something in the base game.
This is the line the error points to:
if rooms.transitionType ~= rooms.TRANSITION_TYPE_NONE and rooms.rooms[collided].section == rooms.rooms[rooms.currentRoomIndex].section then
It's probably just me but that's very weirdly worded. What exactly is it trying to do? To me it looks like it's redirecting the other two transition types to a conditional branch that tries to pull the room ID out of thin air and since non-integers can't be converted to integers it throws an error. Also, if I try to put a function involving onRoomEnter() and don't have it exactly as I posted, it errors on startup and completely breaks all custom LUA. If I put a number there it expects <name> or ... near the number, if I put a ... there it says the number is malformed.
Also, function onRespawnReset is also broken. If I use the following code:
function onRespawnReset
player:transform(CHARACTER_BOWSER);
player.speedX = -1
end
it expects a colon between "player" and the colon, but if I do that, it says "unexpected symbol". So I have to conclude that this code is incompatible with LunaLUA itself. Someone please send me a sample level so I can see what I'm dong wrong...
|
|
|
|
|
|
|
|
|
-
Enjl
- Cute Yoshi Egg

- Posts: 9017
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Orphion Egamalenitar Osmos IV, Esq.
Postby Enjl » Thu Mar 05, 2020 8:55 am
Of course that code is incompatible with lua. You haven't written proper lua, after all. Remember that, to define a function, you need to put the parentheses afterwards. Some examples:
function onTick()
function onRespawnReset()
Your other issues also sound like syntax errors on your end. It would help greatly if you could post your entire code instead of snippits.
Ideas are useless if you can't make them real.
All my assets from packs and episodes are free to use for non-Novaverse levels and projects, as long as proper credit is given.
Mirror of all my content and collaborations on IPFS: QmZKzVJAsD6dE2tTHEb58XEmsNLzrW2MVsTtW7HWLAAcCC
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Thu Mar 05, 2020 9:32 am
Wiimeiser wrote: ↑Thu Mar 05, 2020 7:49 am
Transitions don't work, the game spams nil value errors and the camera doesn't respect the room boundaries. The respawning does work, but rooms are inoperable unless I set rooms.transitionType = rooms.TRANSITION_TYPE_NONE. It appears to be a conflict, but this is the only custom LUA I'm using in this test episode, so if that's true, then it's with something in the base game.
This is the line the error points to:
if rooms.transitionType ~= rooms.TRANSITION_TYPE_NONE and rooms.rooms[collided].section == rooms.rooms[rooms.currentRoomIndex].section then
It's probably just me but that's very weirdly worded. What exactly is it trying to do? To me it looks like it's redirecting the other two transition types to a conditional branch that tries to pull the room ID out of thin air and since non-integers can't be converted to integers it throws an error. Also, if I try to put a function involving onRoomEnter() and don't have it exactly as I posted, it errors on startup and completely breaks all custom LUA. If I put a number there it expects <name> or ... near the number, if I put a ... there it says the number is malformed.
Also, function onRespawnReset is also broken. If I use the following code:
function onRespawnReset
player:transform(CHARACTER_BOWSER);
player.speedX = -1
end
it expects a colon between "player" and the colon, but if I do that, it says "unexpected symbol". So I have to conclude that this code is incompatible with LunaLUA itself. Someone please send me a sample level so I can see what I'm dong wrong...
About the first error: are you going from an area with no room and then entering a room? If so, I'll fix that in the next version. If not, please show the actual error.
|
|
|
|
|
|
|
|
|
-
Wiimeiser
- Tweeter

- Posts: 165
- Joined: Mon Jun 24, 2019 4:36 am
- Flair: What?
Postby Wiimeiser » Thu Mar 05, 2020 4:24 pm
I'm starting in section 0, which has no rooms, then going to section 4, which does. Is that the problem?
The second error still concerns me, though...
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Fri Mar 06, 2020 1:37 pm
Wiimeiser wrote: ↑Thu Mar 05, 2020 4:24 pm
I'm starting in section 0, which has no rooms, then going to section 4, which does. Is that the problem?
The second error still concerns me, though...
That is the problem (and it'll be fixed in the next update), and the second issue was already fixed by Enjl:
Enjl wrote: ↑Thu Mar 05, 2020 8:55 am
Of course that code is incompatible with lua. You haven't written proper lua, after all. Remember that, to define a function, you need to put the parentheses afterwards. Some examples:
function onTick()
function onRespawnReset()
Your other issues also sound like syntax errors on your end. It would help greatly if you could post your entire code instead of snippits.
|
|
|
|
|
|
|
|
|
-
Wiimeiser
- Tweeter

- Posts: 165
- Joined: Mon Jun 24, 2019 4:36 am
- Flair: What?
Postby Wiimeiser » Fri Mar 06, 2020 4:57 pm
Starting in the four-rooms test where the four rooms are does work, so I can now confirm that's what I need to do.
Regarding the code snippet where I tried to turn the player into Bowser, that was the entire code I was trying to run. Adding the parentheses made it work, so I was stupid there. But I can't figure out what I'm doing wrong the onRoomEnter part. If I set it to "function onRoomEnter()" it works but triggers for every room.
If you want the test luna.lua for the test level, here it is:
local rooms = require("rooms")
function onRespawnReset()
player:transform(CHARACTER_BOWSER);
player.speedX = -1
end
function onRoomEnter()
player:transform(CHARACTER_SNAKE);
end
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Fri Mar 06, 2020 7:12 pm
Yes, onRoomEnter triggers when entering any room. That is what it's supposed to do, after all. If you want to make it only happening when entering a certain room, you can do something like this:
function onRoomEnter(roomIdx)
if roomIdx == X then
Y
end
end
Where X is the index of the room and Y is the code to be run. (Note that you don't replace roomIdx at all)
|
|
|
|
|
|
|
|
|
-
Wiimeiser
- Tweeter

- Posts: 165
- Joined: Mon Jun 24, 2019 4:36 am
- Flair: What?
Postby Wiimeiser » Fri Mar 06, 2020 9:46 pm
Okay, that does work. Now whenever I enter room 3 I turn into Snake, and whenever I die and respawn I turn into Bowser.
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Wed Mar 11, 2020 5:24 pm
Version 1.1 has been released, and there's been a ton of under the hood changes (the entire respawn reset system has been overhauled, meaning a bunch of jank has been fixed), but there a few changes that'll hopefully help the people using this. Here's a little "change log", even if it is by no means complete:
- A bunch of massive behind the scenes changes
- Music will no longer stop on dying
- P-Switches now work properly on resetting (and no longer completely destroys levels)
- Mega mushrooms and starmans now reset properly
- Cross-section respawning now works properly
- Added an option to create a pseudo "checkpoint" on entering a section
- Added an option to reset unsaved star coins
- Added support for timer.lua
|
|
|
|
|
|
|
|
|
-
Wiimeiser
- Tweeter

- Posts: 165
- Joined: Mon Jun 24, 2019 4:36 am
- Flair: What?
Postby Wiimeiser » Thu Mar 12, 2020 3:08 am
Two further things are broken:
-The check for the music.ini file causes an error on startup. The section is "Get music paths for vanilla music" and the line it points to is:
vanillaMusicPaths[w._header] = v.. "\\".. w.file
I've had to comment out the entire thing there to stop the error appearing, but I don't know if that will break anything...
-Enabling this breaks the reserve box blocks (737 and 739) with an error about the game trying to compare a nil with a number on line 13, which is on this line:
if item < 1000 and item > 0 then return end
Then the block just spawns the NPC like a regular block does, instead of putting it in the reserve box like it's supposed to. This seems to suggest NPC IDs are being converted to nil values by the rooms script somewhere...
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Fri Mar 13, 2020 7:00 pm
Sorry for the hiccups! The download link has been updated to fix all the bugs that have been reported to me.
|
|
|
|
|
|
|
|
|
-
MarioBrosCreeper
- Goomba

- Posts: 4
- Joined: Sat May 06, 2017 6:15 am
Postby MarioBrosCreeper » Wed Mar 18, 2020 5:52 pm
I love the quick respawn feature! It's great to create Kaizo-like levels! 
However, some things don't reset. Quick respawn does not reset unlocked doors, blocks moved with an event and Event-timers don't work properly.
When I make an event activate another event in 3 seconds and die after 2 seconds, when respawning the new event gets triggered at 1 second.
Conveyor Belts don't reset as well when changed direction and sometimes NPCs such as keys, carryable blocks or disco shells just despawn.
Also, Parakoopas are janky. Their movement is completely different on the first try.
|
|
|
|
|
|
|
|
|
-
MrDoubleA
- Monty Mole

- Posts: 145
- Joined: Mon Aug 20, 2018 7:02 am
- Pronouns: he/him
-
Contact:
Postby MrDoubleA » Fri Mar 20, 2020 9:31 am
MarioBrosCreeper wrote: ↑Wed Mar 18, 2020 5:52 pm
I love the quick respawn feature! It's great to create Kaizo-like levels! 
However, some things don't reset. Quick respawn does not reset unlocked doors, blocks moved with an event and Event-timers don't work properly.
When I make an event activate another event in 3 seconds and die after 2 seconds, when respawning the new event gets triggered at 1 second.
Conveyor Belts don't reset as well when changed direction and sometimes NPCs such as keys, carryable blocks or disco shells just despawn.
Also, Parakoopas are janky. Their movement is completely different on the first try.
Alright, so let's explain all these: unfortunately, there's not much that can be done to make layers moved through events reset at the moment, so if you want moving layers you'll just have to do it through lua. Thanks for the report on locked doors and conveyor belts not resetting, and blocks should reset (are you sure you're using the latest version?). And, yes, NPCs and blocks reset when changing rooms, so they will disappear if being held.
|
|
|
|
|
Return to “LunaLua”
Who is online
Users browsing this forum: No registered users and 2 guests
|