Share and discuss custom LunaLua code and content packs for SMBX2.
Moderator: Userbase Moderators
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 537
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Wed Apr 12, 2023 12:24 am
Title says it all, this is for those who just need a custom health system.
It has better code than CHS but less features. I felt like CHS was bulky so I did a little recode.
GIF:
Credits:
- Me
- LxXzit
- FieryExplosion
- Mageker
Loading
Loading is done like any other library.
Code: Select all local health = require("customHealth")
Changelog:
v1.0 - First release
v1.1 - Now you can store mushrooms in the reserve box and specify a default powerup.
v1.2 - Added health.onPostPlayerHurt, health bar now hides with the vanilla hud, setting hudoverride.visible.itemBox now works, and some fixes related to powerup and hp setting.
Download:
https://drive.google.com/file/d/1-r5__2 ... sp=sharing
Give credits if used! Enjoy!
Last edited by Marioman2007 on Sat Apr 13, 2024 12:14 pm, edited 6 times in total.
|
|
|
|
|
|
|
|
|
-
Mal8rk
- Snifit

- Posts: 216
- Joined: Mon Oct 25, 2021 11:04 pm
- Flair: English Speaking Spanish Speaker
- Pronouns: He/Him
-
Contact:
Postby Mal8rk » Wed May 24, 2023 11:42 pm
Is there a way to have custom hurt sheets for other characters aside from Mario, Luigi, Peach, or Toad?
|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 537
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Thu May 25, 2023 2:44 am
Mal8rk wrote: ↑Wed May 24, 2023 11:42 pm
Is there a way to have custom hurt sheets for other characters aside from Mario, Luigi, Peach, or Toad?
Code: Select all health.VFX.hurt[CHARACTER_#] = Graphics.loadImageResolved(path)
CHARACTER_# must be a character constant: https://docs.codehaus.moe/#/constants/characters
path must be a string, for example - "customHealth/hurtWario.png"
|
|
|
|
|
|
|
|
|
-
Thundaga_T2
- Ripper II

- Posts: 352
- Joined: Wed Jun 11, 2014 6:31 am
Postby Thundaga_T2 » Fri Jun 02, 2023 2:57 am
Is it possible to have either this one, or the original be compatible with MDA's Sonic Monitors? Specifically having the bubble shield give infinite air while its active?
|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 537
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Wed Feb 07, 2024 2:22 am
Version 1.1 released!
Changelog in the main post
Thundaga_T2 wrote: ↑Fri Jun 02, 2023 2:57 am
Is it possible to have either this one, or the original be compatible with MDA's Sonic Monitors? Specifically having the bubble shield give infinite air while its active?
You can use this code (after loading customhealth):
Code: Select all local monitor = require("monitor_ai")
function health.onPlayerHurt(event, p)
if monitor.getPlayerData(p).currentShield then
event.cancelled = true
end
end
|
|
|
|
|
|
|
|
|
-
RotisserieSalad
- Spiny

- Posts: 27
- Joined: Tue Feb 06, 2024 3:57 pm
- Flair: the terrible tormentor of twinks /j
- Pronouns: he/him or they/them
-
Contact:
Postby RotisserieSalad » Sun Feb 11, 2024 7:42 pm
would it be possible to only have this code active in one section? i want to use it for a boss at the end of a castle but i don't want to use the health system for the entire castle
if it's not possible that's ok!
|
|
|
|
|
|
|
|
|
-
Jumper
- Tweeter

- Posts: 130
- Joined: Tue Feb 02, 2016 9:32 pm
Postby Jumper » Mon Feb 19, 2024 2:59 am
Is it at all possible to set a custom main and max health outside the default 3 main, 6 max?
Like if someone wanted to change it to be 5 for main, and 10 for max?
|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 537
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Mon Feb 19, 2024 6:22 am
Jumper wrote: ↑Mon Feb 19, 2024 2:59 am
Is it at all possible to set a custom main and max health outside the default 3 main, 6 max?
Like if someone wanted to change it to be 5 for main, and 10 for max?
you can use this code to do that:
Code: Select all local health = require("customHealth")
health.settings.mainHealth = 5
health.settings.maxHealth = 10
health.curHealth = health.settings.mainHealth
Note that you will need to change the health bar sprites too.
Here's the layout to do that.
Code: Select all Frame 1 - 0 health
Frame 2 - 1 health
Frame 3 - 2 health
Frame 4 - 3 health
Frame 5 - 4 health
Frame 6 - 5 health
Frame 7 - No health (used in the counting up animation)
Frame 8 - 6 health
Frame 9 - 7 health
Frame 10 - 8 health
Frame 11 - 9 health
Frame 12 - 10 health
Frame 13 - Daredevil health
|
|
|
|
|
|
|
|
|
-
Jumper
- Tweeter

- Posts: 130
- Joined: Tue Feb 02, 2016 9:32 pm
Postby Jumper » Mon Feb 19, 2024 7:38 am
Marioman2007 wrote: ↑Mon Feb 19, 2024 6:22 am
Jumper wrote: ↑Mon Feb 19, 2024 2:59 am
Is it at all possible to set a custom main and max health outside the default 3 main, 6 max?
Like if someone wanted to change it to be 5 for main, and 10 for max?
you can use this code to do that:
Code: Select all local health = require("customHealth")
health.settings.mainHealth = 5
health.settings.maxHealth = 10
health.curHealth = health.settings.mainHealth
Note that you will need to change the health bar sprites too.
Here's the layout to do that.
Code: Select all Frame 1 - 0 health
Frame 2 - 1 health
Frame 3 - 2 health
Frame 4 - 3 health
Frame 5 - 4 health
Frame 6 - 5 health
Frame 7 - No health (used in the counting up animation)
Frame 8 - 6 health
Frame 9 - 7 health
Frame 10 - 8 health
Frame 11 - 9 health
Frame 12 - 10 health
Frame 13 - Daredevil health
TYVM, man.
|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 537
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Sat Apr 13, 2024 3:47 am
Version 1.2 is here
More bug fixes, changelog in the main post.
|
|
|
|
|
|
|
|
|
-
Jaximus_The_Great
- Goomba

- Posts: 2
- Joined: Wed May 15, 2024 11:07 pm
- Pronouns: he/him
Postby Jaximus_The_Great » Thu May 16, 2024 12:48 am
I was testing this out, it worked great, but I'm not proficient in lua code, so I can't figure out how to make the life mushroom work.
|
|
|
|
|
|
|
|
|
-
Just_Thomas
- Spike

- Posts: 296
- Joined: Sat Dec 16, 2023 3:32 am
- Pronouns: he/him
Postby Just_Thomas » Sat May 18, 2024 10:47 am
Hello,
first of all: Thanks for your work.
But let's get straight down to business (joke):
I think (!!) this might be bug with the fire flower here.
Collecting the item gives health but does not increase the health bar.
So either I guess the health increase is not supposed to happen or the display does bug around. I guess it is the first one.
I hope I haven't overlooked anything here...
Edit: But that has nothing to do with the mushroom in the reserve box (after collecting the flower), does it? After all, it is not “activated”. Would be strange, if it does count as "extra health".

|
|
|
|
|
|
|
|
|
-
PizzaNoob
- Bot

- Posts: 55
- Joined: Wed May 29, 2024 8:36 pm
- Flair: I like to make comics!
- Pronouns: he/him
Postby PizzaNoob » Wed May 29, 2024 8:46 pm
Is there any way to "hide" the bar when cutscenePal is active?
Edit: I actually found out my self LOL
|
|
|
|
|
|
|
|
|
-
FutureNyanCat
- Eerie

- Posts: 766
- Joined: Fri Dec 20, 2013 8:39 pm
- Flair: Species: Felis robotus
- Pronouns: He/Him
-
Contact:
Postby FutureNyanCat » Wed Sep 18, 2024 7:18 pm
I reported that this script causes issues with the Defines.levelFreeze define, which will make it not pause the entire level anymore, because its value was always set via the onTick function in the script.
Consequentially it also prevents the basegame green P-Switch and SMB2 clocks from working properly.
|
|
|
|
|
|
|
|
|
-
PizzaNoob
- Bot

- Posts: 55
- Joined: Wed May 29, 2024 8:36 pm
- Flair: I like to make comics!
- Pronouns: he/him
Postby PizzaNoob » Sun Jan 26, 2025 5:49 pm
Hey I found a bug with respawnRooms and customHealth.
Basically, when the player dies, they keep dying on and on.
From my understanding, whenever the bar is at 0, it kills the player no matter what. Is there a way in which I can reset the player's bar after a quick death?

|
|
|
|
|
|
|
|
|
-
Marioman2007
- 2025 Egg Hunter

- Posts: 537
- Joined: Tue Aug 25, 2020 3:19 am
- Flair: Dr. Bones
- Pronouns: He/Him
Postby Marioman2007 » Sat Feb 01, 2025 10:58 am
PizzaNoob wrote: ↑Sun Jan 26, 2025 5:49 pm
Hey I found a bug with respawnRooms and customHealth.
Basically, when the player dies, they keep dying on and on.
From my understanding, whenever the bar is at 0, it kills the player no matter what. Is there a way in which I can reset the player's bar after a quick death?
Do you have v1.2? Because it works fine for me.
|
|
|
|
|
|
|
|
|
-
PizzaNoob
- Bot

- Posts: 55
- Joined: Wed May 29, 2024 8:36 pm
- Flair: I like to make comics!
- Pronouns: he/him
Postby PizzaNoob » Sat Feb 01, 2025 1:14 pm
Marioman2007 wrote: ↑Sat Feb 01, 2025 10:58 am
PizzaNoob wrote: ↑Sun Jan 26, 2025 5:49 pm
Hey I found a bug with respawnRooms and customHealth.
Basically, when the player dies, they keep dying on and on.
From my understanding, whenever the bar is at 0, it kills the player no matter what. Is there a way in which I can reset the player's bar after a quick death?
Do you have v1.2? Because it works fine for me.
Yeah. Turns out I just had to change "local respawnRooms
pcall(function() respawnRooms = require("respawnRooms") end)"
to "local respawnRooms
pcall(function() respawnRooms = require("Scripts/respawnRooms") end)".
I have all scripts in a seperate file.
|
|
|
|
|
|
|
|
|
-
AlphaBlue1011
- Spiny

- Posts: 29
- Joined: Sun Feb 02, 2025 3:00 pm
- Flair: never underestimate hyperfixations :3
- Pronouns: she/her or they/them
Postby AlphaBlue1011 » Tue Feb 18, 2025 7:33 pm
Came up with a way to make the health never go up past 2 without changing the main and max health values:
function onStart()
health.curHealth = 2
end
function onTick()
if health.curHealth >= 3 then
health.curHealth = 2
end
end
this could be useful in two-hit challenges. Also, just setting the main or max health to 2 or anything else seems to mess up how the health is rendered without making changes to the sprites. this is just a lazy way to make it display properly in a situation like this.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 4 guests
|