reserveItems.lua - Item box for heart-based characters! [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

reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby Marioman2007 » Fri Aug 26, 2022 5:02 am

Was very determined to do this, so finished in 2 hours.
as the title says, this script simply adds item box support for heart based characters.

GIF
https://imgur.com/W66D2Uh

Download
This script is no longer supported, use the newer script:
viewtopic.php?t=29445

Changelog:
- 1.0: released the lib
- 1.1: 2-player compatibility, modernReserveItems compatible
- 1.2: fixed a minor issue, added some variables to modify the drawing system, visible, x and y.
- 1.3: one more bugfix

Settings n' stuff
reserveItems.enabled - whether the script is enabled (bool)
reserveItems.canUseItem - whether the player can use their item (bool)
reserveItems.itemBoxVisible - is the item box visible (bool)
reserveItems.itemBoxX - x coord of the box, only works in 1p mode (int)
reserveItems.itemBoxY - y coord of the box (int)
reserveItems.mushrooms - a table for mushroom powerups
reserveItems.restrictedPowerups - a table for powerups that don't change the player state and hence won't get in the reserve box
reserveItems.powersUpToGive - a table that decides the powerups that'll be given to the player
reserveItems.setReserveItem(player, itemID) - a function to set the reserve npc id of the given player
SaveData.reserveItems[playerID] - current reserve item of the given player

NOTE: to make this work with modernReserveItems, make sure that modernReserveItems is loaded before reserveItems and add these three lines in modernReserveItems at the given spot.
Spoiler: show
Image

Please give credit to me when used!
Last edited by Marioman2007 on Wed Feb 21, 2024 10:32 am, edited 7 times in total.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1]

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

Dude, I saw you talking about this in the discord server after I posted my heartsForAll stuff, and it's great that you were able to do this! Sure will be neat to have all the OG characters use either hearts or the itembox lol

AToMIC
Monty Mole
Monty Mole
Posts: 110
Joined: Fri Jan 24, 2014 2:57 pm
Flair: I'm here
Pronouns: He/Him

Re: reserveItems.lua - Item box for heart-based characters! [v1]

Postby AToMIC » Fri Aug 26, 2022 5:25 pm

Hmmm. Could this be used on Mario and Luigi if the Hearts For all LUA is being used on them?

Update: It will not work, but I'm sure with a little Lua fine-tuning from someone with a higher skill level than me it is possible. Great work here my friend.

Animebryan
Spike
Spike
Posts: 262
Joined: Fri Jun 03, 2016 5:40 pm
Flair: Need help!
Contact:

Re: reserveItems.lua - Item box for heart-based characters! [v1]

Postby Animebryan » Sat Aug 27, 2022 3:06 am

What about 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: reserveItems.lua - Item box for heart-based characters! [v1]

Postby Marioman2007 » Sat Aug 27, 2022 4:00 am

Animebryan wrote:
Sat Aug 27, 2022 3:06 am
What about Link?
It works for every heart based character, even for X2 ones.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1]

Postby AppleTheTomato » Mon Sep 12, 2022 1:15 am

AToMIC wrote:
Fri Aug 26, 2022 5:25 pm
Hmmm. Could this be used on Mario and Luigi if the Hearts For all LUA is being used on them?

Update: It will not work, but I'm sure with a little Lua fine-tuning from someone with a higher skill level than me it is possible. Great work here my friend.
Yeah, I don't think it would ever work. I mess with the reserve box a bit to make 3 hearts display properly in heartsForAll. Plus, mines 2-player compatible, and Marioman's code here is only 1-player, so that would cause some issues. But! You can always use anotherPowerDown by KBM-Quine AND Marioman's code to get the desired gameplay effect.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1]

Postby Marioman2007 » Tue Sep 13, 2022 12:12 pm

AppleTheTomato wrote:
Mon Sep 12, 2022 1:15 am
Yeah, I don't think it would ever work. I mess with the reserve box a bit to make 3 hearts display properly in heartsForAll. Plus, mines 2-player compatible, and Marioman's code here is only 1-player, so that would cause some issues. But! You can always use anotherPowerDown by KBM-Quine AND Marioman's code to get the desired gameplay effect.
I am implementing 2p and splitscreen support so don't worry!

AToMIC wrote:
Fri Aug 26, 2022 5:25 pm
Hmmm. Could this be used on Mario and Luigi if the Hearts For all LUA is being used on them?

Update: It will not work, but I'm sure with a little Lua fine-tuning from someone with a higher skill level than me it is possible. Great work here my friend.
I might do a thing for that, in the meantime, you could use SmgLifeSystem.lua, which is easy enough to edit.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1]

Postby AppleTheTomato » Tue Sep 13, 2022 9:58 pm

Marioman2007 wrote:
Tue Sep 13, 2022 12:12 pm
AppleTheTomato wrote:
Mon Sep 12, 2022 1:15 am
Yeah, I don't think it would ever work. I mess with the reserve box a bit to make 3 hearts display properly in heartsForAll. Plus, mines 2-player compatible, and Marioman's code here is only 1-player, so that would cause some issues. But! You can always use anotherPowerDown by KBM-Quine AND Marioman's code to get the desired gameplay effect.
I am implementing 2p and splitscreen support so don't worry!

AToMIC wrote:
Fri Aug 26, 2022 5:25 pm
Hmmm. Could this be used on Mario and Luigi if the Hearts For all LUA is being used on them?

Update: It will not work, but I'm sure with a little Lua fine-tuning from someone with a higher skill level than me it is possible. Great work here my friend.
I might do a thing for that, in the meantime, you could use SmgLifeSystem.lua, which is easy enough to edit.
I actually just decided to change how health is handled, and now it doesn't mess with the reserve! It's cleared by default, but you can disable that. So, HOPEFULLY, these will work together now! Here's the link again: viewtopic.php?f=101&t=28409&p=394466#p394466

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.1]

Postby Marioman2007 » Wed Sep 14, 2022 12:43 am

Updated to version 1.1!
Check the original post!

Added in 11 hours 15 minutes 25 seconds:
I noticed there was a minor issue so I quickly patched that, also added some stuff related to the drawing system.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby AppleTheTomato » Thu Sep 15, 2022 12:00 am

So, I thought this was a bug at first, but after looking at the library's comments, I guess mushrooms don't go into the reserve anymore? Is there a reason for this? Other bugs, perhaps?

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby Marioman2007 » Thu Sep 15, 2022 1:17 am

AppleTheTomato wrote:
Thu Sep 15, 2022 12:00 am
So, I thought this was a bug at first, but after looking at the library's comments, I guess mushrooms don't go into the reserve anymore? Is there a reason for this? Other bugs, perhaps?
Yeah this is an intended behavior, the reason is because if you collect a mushroom while at one heart, it will make you big
BUT
it you collect a mushroom while at two hearts, it will increase them to 3 and ALSO go in the reserve box, when you get hurt while at three hearts, they will decrease to two and if you use your reserve mushroom it will again increase the value two 3 and will again go to the reserve box.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby AppleTheTomato » Thu Sep 15, 2022 1:37 am

Marioman2007 wrote:
Thu Sep 15, 2022 1:17 am
AppleTheTomato wrote:
Thu Sep 15, 2022 12:00 am
So, I thought this was a bug at first, but after looking at the library's comments, I guess mushrooms don't go into the reserve anymore? Is there a reason for this? Other bugs, perhaps?
Yeah this is an intended behavior, the reason is because if you collect a mushroom while at one heart, it will make you big
BUT
it you collect a mushroom while at two hearts, it will increase them to 3 and ALSO go in the reserve box, when you get hurt while at three hearts, they will decrease to two and if you use your reserve mushroom it will again increase the value two 3 and will again go to the reserve box.
Oh weird. Tho, it makes me wonder...couldn't you just add some kind of check like "if you are at 3 health, and your reserve is empty, and you collect a mushroom, put that mushroom in the reserve?" IDK, just throwing that out there.

Also, weird thing I found: say you collect the SMW Fire Flower (npc-183), then the SMAS3 Fire Flower (npc-14) goes into the reserve. Fine enough, but if you are using modernReserveItems, then when you drop your item, it's that SMW Fire Flower that gets spawned, not the SMAS3 Fire Flower in the reserve. Not sure how'd you fix that, but I figured I'd point it out.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby Marioman2007 » Thu Sep 15, 2022 1:55 am

For the first one yeah I did try that but unfortunately that didn't work well.
As for the 2nd one yeah, it worked fine in the first version but it had some bugs so I just scrapped that idea
I am currently trying to find that first version to replicate that AI and fix it.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby AppleTheTomato » Thu Sep 15, 2022 2:52 am

Fair enough. Library works great regardless, but those were just random things I found lol

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby AppleTheTomato » Thu Sep 15, 2022 10:29 pm

Uh...I will add that the mushroom issue you were talking about DOES apply to every other powerup. For example, you are Fire Peach, at 2 health, and have a fire flower in the reserve. You pop it, go to 3 health, and get a fire flower in the reserve again. Can't seem to upload a GIF, but I'd look into that.

To add, I wonder if it would work to only give you a reserve item if your health is at 3.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby Marioman2007 » Thu Sep 15, 2022 11:13 pm

I think the best would be create a custom health system.
(SmgLifeSystem also has this issue so now I have to update it)

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby AppleTheTomato » Thu Sep 15, 2022 11:32 pm

Yeah lol. Main health system works fine, till you mess with it. Story of SMBX...

AToMIC
Monty Mole
Monty Mole
Posts: 110
Joined: Fri Jan 24, 2014 2:57 pm
Flair: I'm here
Pronouns: He/Him

Re: reserveItems.lua - Item box for heart-based characters! [v1]

Postby AToMIC » Sat Sep 17, 2022 5:57 am

AToMIC wrote:
Fri Aug 26, 2022 5:25 pm
Hmmm. Could this be used on Mario and Luigi if the Hearts For all LUA is being used on them?

Update: It will not work, but I'm sure with a little Lua fine-tuning from someone with a higher skill level than me it is possible. Great work here my friend.
I might do a thing for that, in the meantime, you could use SmgLifeSystem.lua, which is easy enough to edit.
[/quote]

Thanks my friend! Keep up the quality work!

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby AppleTheTomato » Wed Sep 28, 2022 9:52 am

Found another interesting issue. The SMB2 'duplicate mushrooms' don't work anymore lol. Not sure how you'd fix that, but I figured I'd mention it.

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

Re: reserveItems.lua - Item box for heart-based characters! [v1.3]

Postby Marioman2007 » Thu Sep 29, 2022 12:44 am

AppleTheTomato wrote:
Wed Sep 28, 2022 9:52 am
Found another interesting issue. The SMB2 'duplicate mushrooms' don't work anymore lol. Not sure how you'd fix that, but I figured I'd mention it.
Thanks, I will fix all the bugs after I am done with SmgLifeSystem.
This script will only be perfectly usable with a custom health library.

I plan to give mushrooms a special behavior, they'll go to the reserve box if health is full but not if health is not full
other powerups are not gonna give health.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari