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

Share and discuss custom LunaLua code and content packs for SMBX2.
Marioman2007
Lakitu
Lakitu
Posts: 469
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: 200
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: 469
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: 469
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
Koopa
Koopa
Posts: 15
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: 469
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: 469
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.


Return to “LunaLua”

Who is online

Users browsing this forum: ebro801, Semrush [Bot] and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari