customHealth.lua [v1.2] - New CHS with less features

Share and discuss custom LunaLua code and content packs for SMBX2.
Marioman2007
Lakitu
Lakitu
Posts: 487
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

customHealth.lua [v1.2] - New CHS with less features

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:
Spoiler: show
Image

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
Snifit
Posts: 209
Joined: Mon Oct 25, 2021 11:04 pm
Flair: English Speaking Spanish Speaker
Pronouns: He/Him
Contact:

Re: customHealth.lua [v1] - New CHS with less features

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
Lakitu
Lakitu
Posts: 487
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: customHealth.lua [v1] - New CHS with less features

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
Flurry
Flurry
Posts: 350
Joined: Wed Jun 11, 2014 6:31 am

Re: customHealth.lua [v1] - New CHS with less features

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
Lakitu
Lakitu
Posts: 487
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: customHealth.lua [v1.1] - New CHS with less features

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
Bob-Omb
Bob-Omb
Posts: 22
Joined: Tue Feb 06, 2024 3:57 pm
Flair: the terrible tormentor of twinks /j
Pronouns: he/him or they/them
Contact:

Re: customHealth.lua [v1.1] - New CHS with less features

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
Monty Mole
Monty Mole
Posts: 130
Joined: Tue Feb 02, 2016 9:32 pm

Re: customHealth.lua [v1.1] - New CHS with less features

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
Lakitu
Lakitu
Posts: 487
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: customHealth.lua [v1.1] - New CHS with less features

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
Monty Mole
Monty Mole
Posts: 130
Joined: Tue Feb 02, 2016 9:32 pm

Re: customHealth.lua [v1.1] - New CHS with less features

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
Lakitu
Lakitu
Posts: 487
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: customHealth.lua [v1.2] - New CHS with less features

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
Goomba
Posts: 2
Joined: Wed May 15, 2024 11:07 pm
Pronouns: he/him

Re: customHealth.lua [v1.2] - New CHS with less features

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
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: customHealth.lua [v1.2] - New CHS with less features

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.
Image

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".
Image
Image

PizzaNoob
Bob-Omb
Bob-Omb
Posts: 20
Joined: Wed May 29, 2024 8:36 pm
Flair: I like to make comics!
Pronouns: he/him

Re: customHealth.lua [v1.2] - New CHS with less features

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
Eerie
Posts: 721
Joined: Fri Dec 20, 2013 8:39 pm
Flair: Species: Felis robotus
Pronouns: He/Him
Contact:

Re: customHealth.lua [v1.2] - New CHS with less features

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.


Return to “LunaLua”

Who is online

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

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari