heartsForAll (v3.1.0.5) - Applies Heart System to Box Users

Share and discuss custom LunaLua code and content packs for SMBX2.
AppleTheTomato
Bit
Bit
Posts: 78
Joined: Wed Jun 02, 2021 8:44 pm
Flair: I am a Tomato named Apple.
Pronouns: He/Him

heartsForAll (v3.1.0.5) - Applies Heart System to Box Users

Postby AppleTheTomato » Fri Aug 26, 2022 12:10 am

I remember browsing through the #help channel on the SMBX Discord Server and seeing someone ask 'how do you hide the reserve box?' MrDoubleA then gave them an answer, and gave me an idea. What if Mario and Luigi could use the heart system?

Thus, after several days and long nights much, MUCH time, a full re-write, and MUCH testing, I finally developed code to do just that.
Behold! (I spoiler tagged these cause there's a lot of them lol)
Spoiler: show
Image
Image
Image
Image
Image
Image
Image
Here's the download: https://drive.google.com/file/d/1wZoTh4 ... sp=sharing
To use, simply put the below in your luna.lua file:

Code: Select all

local pc = require("heartsForAll")
Here's what you can customize:
Spoiler: show
SaveData.heartsForAll - Global HFA data that's indexed first per index, then by character. Contains the fields health and healthLimit.
The first is that indexed character's health, the second is the max health they can reach.


pc.initializeData(i, c, startingHealth, maxHealth, optionalHUDtype) - Setups up SaveData for the passed player index (i) and player character (c). This will not work if the passed character already has data setup
via pc.outaHearts(i, c), and also won't work if they aren't in pc.boxUsers. There is also startingHealth and maxHealth, which determine how much health the indexed character starts with / can reach.
There is ALSO optionalHUDtype, which is what the character's HUD type is set to. If nothing is provided, Graphics.HUD_HEARTS is used.

pc.outaHearts(i, c) - Used by the library itself to check if heartsForAll player character data (hence the c) has been initialiazed for the player (hence the i), but if
you wanna check if it's initialized yourself, you can call this.

pc.getCurrentHealth(i, c) - Gets the current health of the indexed character (i and c)
pc.getMaxHealth(i, c) - Same as the above, but for that indexed character's health limit

pc.jinkies(sound, p, state, iframes) - The function used by the library to play a certain sound, sets p's state, and gives p iframes worth of invincibility frames (p should be a player object)
pc.notDead(p) - Checks if the passed player (p) is dead in some way



pc.applyGraphics - Set to false to disable drawing the new hearts
pc.verticalHearts - Set to true to make the hearts draw vertically (going down).
You'll want to adjust the hearts' placements after this.

pc.setHealth - Whether to set your health manually for big+ powerups in onTickEnd, for stuff like powerup filters, and the megashroom (Does nothing if you're using pc.cantTouchThese below)
pc.handleHealth - May seem dumb, but do you even WANT this to handle health setting? Basically, everything but setting the heart HUD and checking the hearts will not work

pc.useDefaultInitialization - Set to false to disable the default initialization in onInputUpdate (can be used with your own call to pc.initializeData)
pc.checkpoint - Do you want to get extra health from checkpoints? (Works with base-heart characters!)

pc.setVanillaHearts - Set to false to have the vanilla hearts NOT be set to the new health
pc.removeReserve - Set to false to prevent the reserve from being cleared in onTickEnd



pc.scrapedMyKnee - A massive table with all the current powerups and various settings for them (check that below) Used when you are hurt
pc.powerups - The table of powerup NPCS that will increase your health, and you can customize how much each one does heal (access by doing pc.powerups[id].amount)

pc.cantTouchThese - A table that you can put certain powerup states into. When hurt, if you are one of these powerups, you won't lose it. When you register a powerup
(via something like "pc.cantTouchThese[PLAYER_LEAF]"), you must also define a table with these two settings: sound and iframes. First is the
sound that plays when you are hurt with this powerup, second is how many invincibility frames you get. Final product should look like
"pc.cantTouchThese[PLAYER_LEAF] = {sound = 76, iframes = 150}"

pc.bannedStates - A mapped table with all states that do NOT allow the hearts to update in onTickEnd
pc.boxUsers - A mapped table with the box users' IDs (This now includes heart characters, too, 'cause I had to mess with the vanilla hearts to draw the new ones)

pc.horseShield - If you have one of these mounts and get hurt, both the harm events will not run
pc.splitScreens - Mapped table with dynamic screen types that split the screen



pc.priority - The priority the new hearts are drawn at
pc.twoPlayerOffset - How much the hearts are offset in co-op
pc.heartOffset - How much space is put between each heart. This is a vector, where the x value is for horizontal hearts,
and the y value is for vertical hearts

pc.mainXoffset - How much the hearts are offset from the (relative) center of the camera
(NOTE: If you change the maximum number of hearts, you'll probably want to adjust this)

pc.mainY - The y value the new hearts are drawn at
The credits are throughout the lua file.
If you wanna use this, go ahead! I just want some form of credidation, like: heartsForAll.lua: by AppleTheTomato
This is my first released piece of lua, so it may not be the most polished, but I did the best I could to optimize it, and I hope it works well!
If you find any bugs, reply to this post. I'll check on it as frequently as possible.
Also, it's 2-Player, so that's epic.
Last edited by AppleTheTomato on Wed Feb 21, 2024 8:17 pm, edited 42 times in total.

sonic_de_hedhog
Shy Guy
Shy Guy
Posts: 7
Joined: Fri Jan 20, 2023 7:37 am
Pronouns: he/him

Re: heartsForAll (v2.4.2.5) - Applies Heart System to Box Users

Postby sonic_de_hedhog » Fri Jan 27, 2023 12:36 pm

can you make a version for smbx2

MrDoubleA
Flurry
Flurry
Posts: 385
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?
Pronouns: he/him

Re: heartsForAll (v2.4.2.5) - Applies Heart System to Box Users

Postby MrDoubleA » Sun Jan 29, 2023 12:53 pm

sonic_de_hedhog wrote:
Fri Jan 27, 2023 12:36 pm
can you make a version for smbx2
It is for SMBX2.

sonic_de_hedhog
Shy Guy
Shy Guy
Posts: 7
Joined: Fri Jan 20, 2023 7:37 am
Pronouns: he/him

Re: heartsForAll (v2.4.2.5) - Applies Heart System to Box Users

Postby sonic_de_hedhog » Tue Jan 31, 2023 2:20 am

how do i get it to work

Alagirez
Boom Boom
Boom Boom
Posts: 3467
Joined: Tue Dec 02, 2014 2:28 am
Flair: Show your fangs!
Pronouns: He/Him/That wolf
Contact:

Re: heartsForAll (v2.4.2.5) - Applies Heart System to Box Users

Postby Alagirez » Tue Jan 31, 2023 6:34 am

sonic_de_hedhog wrote:
Tue Jan 31, 2023 2:20 am
how do i get it to work
You need to put this code into your luna.lua file:

Code: Select all

local pC = require("heartsForAll")

mariobrigade2018
Spike
Spike
Posts: 263
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

Re: heartsForAll (v3.0.8.0) - Applies Heart System to Box Users

Postby mariobrigade2018 » Wed Nov 29, 2023 1:25 pm

The Super Star inconsistently gives out invincibility. Here is the glitch:

Image

And this is the following test:

Image

Why is this happening? Do note that I am using lovelyReserve as well.

AppleTheTomato
Bit
Bit
Posts: 78
Joined: Wed Jun 02, 2021 8:44 pm
Flair: I am a Tomato named Apple.
Pronouns: He/Him

Re: heartsForAll (v3.0.8.0) - Applies Heart System to Box Users

Postby AppleTheTomato » Wed Nov 29, 2023 8:14 pm

Oh what the lol. Probably something weird going on with onPlayerHarm/onPostPlayerHarm in heartsForAll. Luckily, I think this is an easy fix. Gimme a sec.

EDIT: Should be good now.

mariobrigade2018
Spike
Spike
Posts: 263
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

Re: heartsForAll (v3.0.8.1) - Applies Heart System to Box Users

Postby mariobrigade2018 » Fri Dec 01, 2023 12:41 pm

AppleTheTomato wrote:
Wed Nov 29, 2023 8:14 pm
Oh what the lol. Probably something weird going on with onPlayerHarm/onPostPlayerHarm in heartsForAll. Luckily, I think this is an easy fix. Gimme a sec.

EDIT: Should be good now.
The problems unfortunately don't end there. I discovered that the Flight powerup's flight randomly gets taken away:
Image
This continues to happen after replacing to old version with this one. I'll also send in my other custom stuff in case this can't be replicated.

AppleTheTomato
Bit
Bit
Posts: 78
Joined: Wed Jun 02, 2021 8:44 pm
Flair: I am a Tomato named Apple.
Pronouns: He/Him

Re: heartsForAll (v3.0.8.1) - Applies Heart System to Box Users

Postby AppleTheTomato » Fri Dec 01, 2023 2:11 pm

That's odd. I don't have this issue on my end. Comment out some of your other lua code to try and narrow down the culprit.

EDIT: Nevermind, I DID run into the same issue, but when I went and tested it without heartsForAll/lovelyReserves, I still had the issue. Must be a weird basegame thing.

Just_Thomas
Snifit
Snifit
Posts: 223
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: heartsForAll (v3.0.8.2) - Applies Heart System to Box Users

Postby Just_Thomas » Wed Jan 10, 2024 8:23 am

AppleTheTomato wrote:
Fri Aug 26, 2022 12:10 am
This is my first released piece of lua, so it may not be the most polished, but I did the best I could to optimize it, and I hope it works well!
If you find any bugs, reply to this post. I'll check on it as frequently as possible.
Also, it's 2-Player, so that's epic.
Anyway, first of all: Congrats.
I think you can definitely celebrate your release more. Firstly, because it is your first work, which is immediately functional in the "standard configuration". The many options and settings are definitely nice, but it's nice that it just runs properly right from the start. No crashes on startup (at least from the editor), not even a warning message. And then you've also gone to the trouble of making it work for two players. You've already done more than anyone could have expected.
And the fact that the installation is the easiest possible is of course another plus point. I don't know if I'll find a use for this, but it's definitely a great job you've done with it.

Above all, I find it incredible that there are so many scripters and coders for new NPCs etc. here. If only the community was a bit bigger and more unified (in terms of location on the selected forum), but content creators can't help that.

Edit: So yearh, if they are bugs, it just does happen.
I have designed a bunch of levels for Super Dungeon Maker for the Switch, some basic things are not working there. Keep in mind we are talking about a paid product there. Bugs just do happen. As long there is a fix or workaround, anything is fine.


However I do have question a this point:
I am NOT very familiar with SMB2-"USA". In the game the characters can have up to 4 hearts as it seems. I was a little bit dumbfounded when I saw that in a lets play video, did not even know this. Could this be arranged here with "pc.setHealth" as well? Does anybody believe it would make sense or the game to easy? I just like to keep a few options open specially, with this amazing pack of expanded GFX-Pack for SMB2.

Edit:

How do I set it up, like pc.checkpoint?
It does not seem to be a bool.
Is there some kind of heartsForAll.settings = {
(stuff)
}

AppleTheTomato
Bit
Bit
Posts: 78
Joined: Wed Jun 02, 2021 8:44 pm
Flair: I am a Tomato named Apple.
Pronouns: He/Him

Re: heartsForAll (v3.0.8.2) - Applies Heart System to Box Users

Postby AppleTheTomato » Sun Jan 21, 2024 4:58 pm

Just_Thomas wrote:
Wed Jan 10, 2024 8:23 am
However I do have question a this point:
I am NOT very familiar with SMB2-"USA". In the game the characters can have up to 4 hearts as it seems. I was a little bit dumbfounded when I saw that in a lets play video, did not even know this. Could this be arranged here with "pc.setHealth" as well? Does anybody believe it would make sense or the game to easy? I just like to keep a few options open specially, with this amazing pack of expanded GFX-Pack for SMB2.

Edit:

How do I set it up, like pc.checkpoint?
It does not seem to be a bool.
Is there some kind of heartsForAll.settings = {
(stuff)
}
This is a tad tricky. You CAN adjust how much maximum health the players can have by using pc.initializeData. It would look something like this:

Code: Select all

local pc = require("heartsForAll")
pc.useDefaultInitialization = false
pc.initializeData(1, CHARACTER_MARIO, 1, 4)
This will make it so that Player 1's Mario with start out with 1 health and can reach 4 health. But here's the catch: heartsForAll uses the vanilla heart HUD by default, which only lets you go up to 3 health. So you'd have to draw your own hearts. That may be something I add later.

mariobrigade2018
Spike
Spike
Posts: 263
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

Re: heartsForAll (v3.0.8.2) - Applies Heart System to Box Users

Postby mariobrigade2018 » Sun Jan 21, 2024 5:20 pm

AppleTheTomato wrote:
Sun Jan 21, 2024 4:58 pm
Just_Thomas wrote:
Wed Jan 10, 2024 8:23 am
However I do have question a this point:
I am NOT very familiar with SMB2-"USA". In the game the characters can have up to 4 hearts as it seems. I was a little bit dumbfounded when I saw that in a lets play video, did not even know this. Could this be arranged here with "pc.setHealth" as well? Does anybody believe it would make sense or the game to easy? I just like to keep a few options open specially, with this amazing pack of expanded GFX-Pack for SMB2.

Edit:

How do I set it up, like pc.checkpoint?
It does not seem to be a bool.
Is there some kind of heartsForAll.settings = {
(stuff)
}
This is a tad tricky. You CAN adjust how much maximum health the players can have by using pc.initializeData. It would look something like this:

Code: Select all

local pc = require("heartsForAll")
pc.useDefaultInitialization = false
pc.initializeData(1, CHARACTER_MARIO, 1, 4)
This will make it so that Player 1's Mario with start out with 1 health and can reach 4 health. But here's the catch: heartsForAll uses the vanilla heart HUD by default, which only lets you go up to 3 health. So you'd have to draw your own hearts. That may be something I add later.
Having a customizable heart heart system for the other characters was something I was considering making, but if you’re going to add that in HFA, then I guess I’ll wait, since your coding skills are way better than mine.

AppleTheTomato
Bit
Bit
Posts: 78
Joined: Wed Jun 02, 2021 8:44 pm
Flair: I am a Tomato named Apple.
Pronouns: He/Him

Re: heartsForAll (v3.1.0.0) - Applies Heart System to Box Users

Postby AppleTheTomato » Sun Jan 21, 2024 8:41 pm

Gents, you're in luck! I got bored today and decided to go and update heartsForAll with custom drawing! You'll probably have to mess with the new fields to arrange the hearts the way you want, but it's possible now! Should work just fine as it did originally, too, if you don't want to.

Just_Thomas
Snifit
Snifit
Posts: 223
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: heartsForAll (v3.1.0.0) - Applies Heart System to Box Users

Postby Just_Thomas » Mon Jan 22, 2024 9:15 am

Cool!
and BTW: Still funny, your work is really useful for a "no reserve box" - campaign as well. For those curious, I used these settings.

Code: Select all

	powerups = {

		--mushroom-esque items
		[9]   = {amount = 0},
		[94]  = {amount = 1},
		[101] = {amount = 1},
		[102] = {amount = 1},
		[184] = {amount = 0},
		[185] = {amount = 0},
		[249] = {amount = 1},
		[250] = {amount = 1},

		--flowers
		[14]  = {amount = 0},
		[182] = {amount = 0},
		[183] = {amount = 0},
		[264] = {amount = 0},
		[277] = {amount = 0},

		--leaf and tanooki/hammer suits
		[34]  = {amount = 0},
		[169] = {amount = 0},
		[170] = {amount = 0}
	},


	useDefaultInitialization = true,
	applyGraphics = false,
	removeReserve = true,
	handleHealth = true,
	checkpoint = false,
	setHealth = true
}
Also put in custom "hardcoded-48-0/1/2" image files in there, which are .. empty.
"has-item" is a copy of the mushroom powerup sfx.

mariobrigade2018
Spike
Spike
Posts: 263
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

Re: heartsForAll (v3.1.0.0) - Applies Heart System to Box Users

Postby mariobrigade2018 » Mon Jan 22, 2024 11:34 am

Just_Thomas wrote:
Mon Jan 22, 2024 9:15 am
Cool!
and BTW: Still funny, your work is really useful for a "no reserve box" - campaign as well. For those curious, I used these settings.

Code: Select all

	powerups = {

		--mushroom-esque items
		[9]   = {amount = 0},
		[94]  = {amount = 1},
		[101] = {amount = 1},
		[102] = {amount = 1},
		[184] = {amount = 0},
		[185] = {amount = 0},
		[249] = {amount = 1},
		[250] = {amount = 1},

		--flowers
		[14]  = {amount = 0},
		[182] = {amount = 0},
		[183] = {amount = 0},
		[264] = {amount = 0},
		[277] = {amount = 0},

		--leaf and tanooki/hammer suits
		[34]  = {amount = 0},
		[169] = {amount = 0},
		[170] = {amount = 0}
	},


	useDefaultInitialization = true,
	applyGraphics = false,
	removeReserve = true,
	handleHealth = true,
	checkpoint = false,
	setHealth = true
}
Also put in custom "hardcoded-48-0/1/2" image files in there, which are .. empty.
"has-item" is a copy of the mushroom powerup sfx.
Haven’t checked the new file yet, but do keep in mind that this no longer uses the hardcoded images.

Just_Thomas
Snifit
Snifit
Posts: 223
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: heartsForAll (v3.1.0.0) - Applies Heart System to Box Users

Postby Just_Thomas » Mon Jan 22, 2024 12:13 pm

mariobrigade2018 wrote:
Mon Jan 22, 2024 11:34 am
Haven’t checked the new file yet, but do keep in mind that this no longer uses the hardcoded images.
I still use the "old" version currently. Might update later if it does not use the hardcoded images but rather something else I might just rename the "empty image" files. Not a big deal. :mrgreen:


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari