CHS.lua - Custom Health and more! [v1.3]

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

CHS.lua - Custom Health and more! [v1.3]

Postby Marioman2007 » Tue Jan 11, 2022 9:55 am

Important!

Consider using the newer version if you don't need multiplayer compatibility and the air meter:
The newer one has better code as well.
viewtopic.php?t=28975


----------------------------------------------------------------------------------------------------------------------


Heyo!
Today I present y'all my first library, originally this was going to be a fixed version of smgModder.lua but I ended up redoing almost everything.

GIFs
Spoiler: show
Image
Image
Image
(Debug text removed.)

Credits
Spoiler: show
---- SmgLifeSystem.lua ----
Marioman2007 - Creating the library + custom NPCs for it
PixelPest - Heavy inspiration + some original snippets code
MrDoubleA - Some snippets of code
Enjl - GFX and render code for the Air meter
LxXzit - GFX of the health meter


---- Lumas and Starbits ----
Luma and Starbit sprites by SilentDream
Slightly Reshaded and Recolored by Marioman2007, using the color palettes by Q-Nova
Made into Custom NPCs by Marioman2007


---- Other ----
Life-Up Mushroom & Air Mushroom sprites by RedBallBomb
Full heal shroom, Life-Up heart & Normal heart sprites by RedBallBomb and Marioman2007
LxXzit for the SMG Big Font
Unknown source for SMW harmed sprites
Mario's harmed sprites by HartFlip0218 (8-bit version), ElectroWelly (Conversion to 16-bit) and Greorge Sprout (Better eyes and gloves)

Changelog
Spoiler: show
1.0 - Released the library
1.01 - Removed particles as they were causing some errors
1.1 - icantswim.lua support + fixed a bug related to starman invincibility
1.2 - Fixed a few more bugs + made the health and air variables global
1.3 - Tons of optimization, new features, made all the powerups use an AI file, redid the air system, 2p support,
fixed a bug where sometimes after collecting the life up powerups the game wouldn't unpause and the bar flew offscreen,
lumas no longer cause an error, redid their drawing system, added follow behavior for starbits,
no need to use ini files for player 1 states, added documentation!

Special Thanks
- Enjl
- MrDoubleA
- Rednaxela
- Sambo
- Hoeloe

Download
https://drive.google.com/file/d/1FWQyzz ... sp=sharing

Documentation
https://docs.google.com/document/d/1QpK ... sp=sharing


Enjoy and give credits if used!
Last edited by Marioman2007 on Tue Apr 09, 2024 4:15 am, edited 9 times in total.

georgespezi12
Buster Beetle
Buster Beetle
Posts: 99
Joined: Mon Jun 01, 2020 3:45 am

Re: SmgLifeSystem.lua - Custom Health and more!

Postby georgespezi12 » Tue Jan 11, 2022 10:12 am

Download link doesn't work

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: SmgLifeSystem.lua - Custom Health and more!

Postby Marioman2007 » Tue Jan 11, 2022 10:20 am

georgespezi12 wrote:
Tue Jan 11, 2022 10:12 am
Download link doesn't work
works fine for me
anyways, updated the original post with an alternate download link

thanks for reporting!

tangy
Monty Mole
Monty Mole
Posts: 115
Joined: Tue Oct 23, 2018 11:32 pm
Flair: less is more

Re: SmgLifeSystem.lua - Custom Health and more!

Postby tangy » Tue Jan 11, 2022 11:01 am

why are you hosting on discord? i am a purveyor of bad ideas and even i wouldnt do that

georgespezi12
Buster Beetle
Buster Beetle
Posts: 99
Joined: Mon Jun 01, 2020 3:45 am

Re: SmgLifeSystem.lua - Custom Health and more!

Postby georgespezi12 » Tue Jan 11, 2022 11:11 am

Image

Spawning a life shroom from a ? block spawns this error.

Sonya Sanchez
Rinka
Rinka
Posts: 666
Joined: Fri May 10, 2019 3:05 pm
Flair: Robotic
Pronouns: They/Them

Re: SmgLifeSystem.lua - Custom Health and more!

Postby Sonya Sanchez » Tue Jan 11, 2022 12:23 pm

tangeruse wrote:
Tue Jan 11, 2022 11:01 am
why are you hosting on discord? i am a purveyor of bad ideas and even i wouldnt do that
How is that a bad idea? The only way you wouldn’t be able to download this would be if he deletes the message that has the download link or if discord is down.

There’s no rule of disallowing stuff being hosted over discord and it’s even imo more reliable than certain other hosting sites!

Not to mention there’s a alternative link.

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: SmgLifeSystem.lua - Custom Health and more!

Postby Marioman2007 » Wed Jan 12, 2022 2:41 am

Sonya Sanchez wrote:
Tue Jan 11, 2022 12:23 pm
tangeruse wrote:
Tue Jan 11, 2022 11:01 am
why are you hosting on discord? i am a purveyor of bad ideas and even i wouldnt do that
The only way you wouldn’t be able to download this would be if he deletes the message that has the download link or if discord is down.
oh, didn't knew that was causing the problem, lol
georgespezi12 wrote:
Tue Jan 11, 2022 11:11 am
Image

Spawning a life shroom from a ? block spawns this error.
Fixed, thanks!
also added an Air Mushroom and documentation for adding/setting - health and air!

MegaDood
Charged Spiny
Charged Spiny
Posts: 1831
Joined: Wed Nov 01, 2017 2:43 am

Re: SmgLifeSystem.lua - Custom Health and more!

Postby MegaDood » Wed Jan 12, 2022 4:57 am

I really like this script! Well done! I also love how you added starbits and lumas with their own colours.
Really good that we can choose between Galaxy or Odyssey styled life ups.

AlanLive2020
Buster Beetle
Buster Beetle
Posts: 98
Joined: Fri Nov 27, 2020 8:15 am
Flair: The guy with no social skills or self-esteem :')

Re: SmgLifeSystem.lua - Custom Health and more!

Postby AlanLive2020 » Wed Jan 12, 2022 9:11 am

Oh cool! I also made one using the mario editor health images (which i havent published) but this is way better

TheGameyFireBro105
Eerie
Eerie
Posts: 747
Joined: Thu Jan 09, 2020 6:09 pm
Flair: Good at remakes
Pronouns: he/him

Re: SmgLifeSystem.lua - Custom Health and more!

Postby TheGameyFireBro105 » Wed Jan 12, 2022 9:50 am

Could you make it compatible with icantswim.lua? I'm trying to use it for a recreation of Sonic 1 (Genesis) Labryinth Zone.

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: SmgLifeSystem.lua - Custom Health and more!

Postby Marioman2007 » Wed Jan 12, 2022 10:02 am

MegaDood wrote:
Wed Jan 12, 2022 4:57 am
I really like this script! Well done! I also love how you added starbits and lumas with their own colours.
Really good that we can choose between Galaxy or Odyssey styled life ups.
AlanLive2020 wrote:
Wed Jan 12, 2022 9:11 am
Oh cool! I also made one using the mario editor health images (which i havent published) but this is way better
Thanks guys ^-^

TheGameyFireBro105 wrote:
Wed Jan 12, 2022 9:50 am
Could you make it compatible with icantswim.lua? I'm trying to use it for a recreation of Sonic 1 (Genesis) Labryinth Zone.
hmm, I don't see why it shouldn't be compatible...

TheGameyFireBro105
Eerie
Eerie
Posts: 747
Joined: Thu Jan 09, 2020 6:09 pm
Flair: Good at remakes
Pronouns: he/him

Re: SmgLifeSystem.lua - Custom Health and more!

Postby TheGameyFireBro105 » Wed Jan 12, 2022 10:06 am

I don't see the air meter when submerging with icantswim.


(LOOK! I'm now in Metroid Dread! I'm a Rinka!)

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: SmgLifeSystem.lua - Custom Health and more!

Postby Marioman2007 » Wed Jan 12, 2022 10:27 am

TheGameyFireBro105 wrote:
Wed Jan 12, 2022 10:06 am
I don't see the air meter when submerging with icantswim.


(LOOK! I'm now in Metroid Dread! I'm a Rinka!)

Code: Select all

SmgLifeSystem.AirMeterActive = true
in your luna.lua file

AlanLive2020
Buster Beetle
Buster Beetle
Posts: 98
Joined: Fri Nov 27, 2020 8:15 am
Flair: The guy with no social skills or self-esteem :')

Re: SmgLifeSystem.lua - Custom Health and more!

Postby AlanLive2020 » Wed Jan 12, 2022 10:34 am

Hey uhhh, just a suggestion, maybe use Game Data so it saves between loading levels?

Added in 46 seconds:
marioman2007 wrote:
Wed Jan 12, 2022 10:27 am
TheGameyFireBro105 wrote:
Wed Jan 12, 2022 10:06 am
I don't see the air meter when submerging with icantswim.


(LOOK! I'm now in Metroid Dread! I'm a Rinka!)

Code: Select all

SmgLifeSystem.AirMeterActive = true
in your luna.lua file
Doesn't work

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: SmgLifeSystem.lua - Custom Health and more!

Postby Marioman2007 » Wed Jan 12, 2022 10:59 am

AlanLive2020 wrote:
Wed Jan 12, 2022 10:35 am
Hey uhhh, just a suggestion, maybe use Game Data so it saves between loading levels?

Added in 46 seconds:
marioman2007 wrote:
Wed Jan 12, 2022 10:27 am

Code: Select all

SmgLifeSystem.AirMeterActive = true
in your luna.lua file
Doesn't work
1) I guess no, it would make some levels a lot harder (1-2 hp) or easier (5-6 hp)
2) oh oof, I'll see what I could do, but later

Sluggish
Shy Guy
Shy Guy
Posts: 5
Joined: Sat Feb 01, 2020 9:08 pm

Re: SmgLifeSystem.lua - Custom Health and more!

Postby Sluggish » Fri Jan 14, 2022 3:43 pm

This is amazing but is there any way to turn off the harm animation. I just want a single frame to be there instead of full animation. I tried that but it still moves up and down.

AlanLive2020
Buster Beetle
Buster Beetle
Posts: 98
Joined: Fri Nov 27, 2020 8:15 am
Flair: The guy with no social skills or self-esteem :')

Re: SmgLifeSystem.lua - Custom Health and more!

Postby AlanLive2020 » Sun Jan 16, 2022 2:46 pm

Found a workaround to it not working with icantswim.

Replace line 546 with this:

Code: Select all

if player:mem(0x34, FIELD_WORD) > 0 and player:mem(0x06, FIELD_WORD) == 0 or Defines.jumpheight == 40 then
Note that this only works when the icantswim jumpheight is 40. If you change the jump height in the icantswim code, change the number here as well.

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: SmgLifeSystem.lua v1.1 - Custom Health and more! Now with icantswim.lua support!

Postby Marioman2007 » Mon Jan 17, 2022 1:00 am

Version 1.1 is here!

This version adds support for icantswim.lua
you can turn it on/off by setting SmgLifeSystem.icantswimSupport to true/false

it also fixes a bug with starman invincibility

link is in the main post!

Sluggish wrote:
Fri Jan 14, 2022 3:43 pm
This is amazing but is there any way to turn off the harm animation. I just want a single frame to be there instead of full animation. I tried that but it still moves up and down.
set SmgLifeSystem.SetHurtFrame to false and remove the players' ini files

AlanLive2020
Buster Beetle
Buster Beetle
Posts: 98
Joined: Fri Nov 27, 2020 8:15 am
Flair: The guy with no social skills or self-esteem :')

Re: SmgLifeSystem.lua v1.1 - Custom Health and more! Now with icantswim.lua support!

Postby AlanLive2020 » Mon Jan 17, 2022 8:31 am

marioman2007 wrote:
Mon Jan 17, 2022 1:00 am
Version 1.1 is here!

This version adds support for icantswim.lua
you can turn it on/off by setting SmgLifeSystem.icantswimSupport to true/false

it also fixes a bug with starman invincibility

link is in the main post!

Sluggish wrote:
Fri Jan 14, 2022 3:43 pm
This is amazing but is there any way to turn off the harm animation. I just want a single frame to be there instead of full animation. I tried that but it still moves up and down.
set SmgLifeSystem.SetHurtFrame to false and remove the players' ini files
Well thats a better solution.

Added in 3 hours 49 minutes 31 seconds:
Re: SmgLifeSystem.lua - Custom Health and more!
There is some boolean text on the top left of the screen. Dunno if thats intentional or not. Anyway i deleted it.

Added in 4 minutes 54 seconds:
Re: SmgLifeSystem.lua - Custom Health and more!
How do i make the coin reward from collecting a heart at full health add to anothercurrency.lua?

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: SmgLifeSystem.lua v1.1 - Custom Health and more! Now with icantswim.lua support!

Postby Marioman2007 » Mon Jan 17, 2022 8:49 pm

AlanLive2020 wrote:
Mon Jan 17, 2022 12:25 pm
There is some boolean text on the top left of the screen. Dunno if thats intentional or not. Anyway i deleted it.
at which line? can't seem to find that

AlanLive2020 wrote:
Mon Jan 17, 2022 12:25 pm
How do i make the coin reward from collecting a heart at full health add to anothercurrency.lua?
it already does that


Return to “LunaLua”

Who is online

Users browsing this forum: Alexx0612 and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari