lovelyReserves (v1.0.4.4) - The Best of Both Worlds

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

Moderator: Userbase Moderators

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

lovelyReserves (v1.0.4.4) - The Best of Both Worlds

Postby AppleTheTomato » Mon Nov 27, 2023 11:46 pm

I've always liked the reserve box. The ability to carry an extra item to either swap to later or pull out when you're hurt is awesome. BUUUT I also like the heart system, which is just really solid. Now, I can have both:
Spoiler: show
Image
Image
Image
Image
Image

With the Beta 5 Update (hurrah, X2 Devs!), vanilla heart characters now work! Here's two GIFs showcasing vanilla heart compatibility vs. heartsForAll compatibility:
Image
Image
Download: https://drive.google.com/file/d/1j7Jmiv ... sp=sharing
Load in your luna.lua with something like local lr = require("lovelyReserves"). Here's the settings if you wanna mess with those:
Spoiler: show
*playerObject.data.itemCoords - A table assigned to a player in onHUDDraw with the item's X, the item's Y, and the camera index of the player
(will be 1 for both when the camera ISN'T split). Used in lr.dropReserveVanilla to properly drop the item basegame-style

*SaveData.lovelyReserves - The bread and butter of the library. It's indexed per player ID and per character.
It contains these fields (cause it's a table) afterwards:
- canUseReserve, which determines if that player/character can use their reserve
- reserveID, which is their current reserve NPC id
- stateNPC, which is the NPC id used to reach the current powerup

*lr.SD - Shorthand for the above

*lr.enabled - Set to false to disable everything
*lr.useDefaultInitialization - Set to false if you want to initialize players/characters on your own



*lr.powerupDefaults - Table that's indexed per powerup. Each indexed powerup has it's own mapped table
with all the NPCs that correspond with it

*lr.emptyReserveItems - Mapped table with powerup NPCs that only go into the reserve if it's empty
*lr.mainReserveItems - Mapped table with powerup NPCs that typically affect...everything lol. These are your flowers, super leafs, etc
*lr.dupeReserveItems - Mapped table with powerup NPCs that will typically dupe your stateNPC into the reserve.
This is one is setup slightly different, as each dupeItem is tied to another NPC ID that your stateNPC
is set to when you collect said dupeItem (for example, the SMAS2 Mushroom is [249] = 9)

*lr.straightToReserveItems - Mapped table with item NPCs that go straight into your reserve box. These NPCs will ONLY drop down from the box
vanilla style, even if you're using modernReserveItems or the discount lovelyReserves MRI.

*lr.poweringStates - Mapped table with forcedStates that prevent onTick/onTickEnd code from running
*lr.lockedBoxStates - Mapped table with forcedStates that prevent the player from dropping their reserve



*lr.useDefaultDrawing - Set to false to stop the default box/item drawing
*lr.boxCoords - Vector that has the x and y offsets for the box drawing
*lr.boxYbombOffset - How much the box is pushed down by if your character has bombs
*lr.boxXoffset - How much the boxes are offset from each other horizontally
*lr.priority - The priority the box stuff is drawn at

*lr.linkItems - Specific powerup IDs that look different for Link
*lr.linkCharacters - Mapped table with characters that behave like Link (and should use the above)



*lr.useDefaultDrop - Set to false to disable ALL types of item-dropping in this library
*lr.useMRItypeDrop - Set to true to use what is essetially a worse version of modernReserveItems' drop lol
(just go use MRI, I only have really kept this for legacy reasons)

*lr.npcCoords - Vector that has the x and y offsets for when the reserve is spawned
*lr.npcSpeedStats - Vector that has the x and y speeds for when the reserve is spawned
*lr.npcSpawnLayer - I'm not gonna continue to support the worse MRI drop this library has, but I'll add this as a last thing
*lr.dropSound - The sound that plays when the reserve is dropped



*lr.clearAllBlocks - Mapped table with block IDs that will clear your powerup and reserve
*lr.mushroomBlocks - Mapped table with block IDs that'll give you your state NPC as your reserve under certain circumstances
*lr.setReserveBlocks - Mapped table with block IDs that'll change your reserve to whatever's in these blocks



*lr.notAheartCharacter(i, c) - Checks if the passed character (c) with the given index (i) is ANY kind of heart character

*lr.figureOutHealthChecks(i, c) - Checks which health systems should be checked for the indexed character (i and c).
Returns a table with two fields: toCheck and max. Will give you an error if you aren't a
heartsForAll character OR a vanilla heart character. Use like:
local h = lr.figureOutHealthChecks(p.idx,p.character)

if h.toCheck < h.max then...


*lr.dropReserve(p, itemID, clearReserve) - Spawns an NPC of the given itemID for the player (p) if the below checks out.
You can pass false for the clearReserve part to NOT clear the reserve if you want.
This is the offbrand modernReserveItems one that uses all the lr.npcCoords and lr.npcSpeedStats stuff lol

*lr.dropReserveVanilla(p, itemID, clearReserve) - Spawns an NPC of the given itemID for the player (p) if the below checks out.
You can pass false for the clearReserve part to NOT clear the reserve if you want.
This is the vanilla drop-item recreation one

*lr.canDropReserve(p) - Checks if the passed player (p) can drop their reserve item


*lr.callCustomEvents(p, itemID) - Calls the custom library events (as well as the dropping-item functions) using the passed player (p) and the given itemID

*lr.setBothTypedReserves(itemID, p) - Using the passed itemID, set both types of reserves (vanilla and LR ones) for the passed player (p)

*lr.getDefaultPowerupItem(powerID) - Function that returns the basic powerup ID associated with the given powerID using lr.powerupDefaults
(so, if you put 5 for powerID, this function will return 169, which is the Tanooki Suit NPC)


*lr.runDefaultReserveHandling(itemID, p, sfx) - Runs the default reserve/stateNPC handling for the passed player (p) using the itemID.
If you so choose, you can use sfx to play a sound effect, since calling this on your own most likely won't play one


*lr.isDataInitialized(i, c) - Checks if the player with an index of i and a character of c has their data setup

*lr.initializeData(i, c, canUseBoxItem, startingReserve, startingStateNPC) - Sets up data for the player with an index of i and a character of c.
Optionally, you can decided if they can use the reserve, what reserve item they start with, and what their stateNPC should be.
Will NOT run if lovelyReserves data is already setup OR if the player isn't some kind of heart-based character


*lr.onLovelyDrop(eventToken, p, itemID) - Happens right before the library's default drop. eventToken.cancelled can be set to true to prevent the item from dropping,
otherwise p is the player dropping the item, and itemID is typically used to check the player's reserve powerup.

*lr.onPostLovelyDrop(p, droppedItem) - Happens after the library's default drop AND if lr.onLovelyDrop WASN'T cancelled. p is the player dropping the item, and droppedItem is, y'know...
This is good for modifying the dropping player or the dropped item afterwards, I guess? Hopefully these work okay, I've never tried this before,
I just looked at modernReserveItems and got MDA's help to see what to do LOL
I will also link modernReserveItems by KBM, and heartsForAll by me, since they work great with this!
viewtopic.php?t=26306
viewtopic.php?t=28409

Please credit me if you use this, and have a great day!
Last edited by AppleTheTomato on Wed Dec 18, 2024 2:36 pm, edited 30 times in total.

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 611
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: lovelyReserves (v1.0.0.0) - The Best of Both Worlds

Postby mariobrigade2018 » Tue Nov 28, 2023 12:15 am

Looks interesting. I’m going to check this out later. Just one question: do you need to call in heartsforall as well? Or is it like an AI file?

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

Re: lovelyReserves (v1.0.0.0) - The Best of Both Worlds

Postby AppleTheTomato » Tue Nov 28, 2023 12:26 am

You do indeed need to call in heartsForAll. I'm sorry if that wasn't clear in the post. And this does not work with vanilla heart characters, so you would need to add them to heartsForAll's boxUsers table in order for them to work with lovelyReserves.

EDIT: Nope, I'm so wrong about the first point lol. I just edited the post with better instructions. My bad xD

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 611
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: lovelyReserves (v1.0.0.0) - The Best of Both Worlds

Postby mariobrigade2018 » Tue Nov 28, 2023 12:40 am

AppleTheTomato wrote:
Tue Nov 28, 2023 12:26 am
You do indeed need to call in heartsForAll. I'm sorry if that wasn't clear in the post. And this does not work with vanilla heart characters, so you would need to add them to heartsForAll's boxUsers table in order for them to work with lovelyReserves.

EDIT: Nope, I'm so wrong about the first point lol. I just edited the post with better instructions. My bad xD
K. Thanks!

King Mario
Blooper
Blooper
Posts: 167
Joined: Sun Nov 19, 2017 2:13 pm
Flair: Jesus Christ is Lord!
Pronouns: he/him
Contact:

Re: lovelyReserves (v1.0.0.0) - The Best of Both Worlds

Postby King Mario » Tue Nov 28, 2023 11:15 am

Looks great! I'll consider trying it out.

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 611
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: lovelyReserves (v1.0.0.0) - The Best of Both Worlds

Postby mariobrigade2018 » Tue Nov 28, 2023 6:10 pm

Another thing that came to mind: Could this work with anotherpowerup.lua and/or powerups that use different forms? (Example: SMB3 P-wing)
Last edited by mariobrigade2018 on Wed Nov 29, 2023 1:23 am, edited 1 time in total.

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

Re: lovelyReserves (v1.0.0.0) - The Best of Both Worlds

Postby AppleTheTomato » Tue Nov 28, 2023 11:51 pm

I'm going to say MAYBE. I've never used anotherpowerup and don't intend to as of now. I think you'd have to mod anotherpowerup yourself to get it to work with lovelyReserves. But I will also say that there is code in lovelyReserves that checks the vanilla reserve field player.reservePowerup, so if anotherpowerup sets that, you SHOULD be fine? Again, huge maybe.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari