Apple's Lua Pack (v1.0.3.5) - My Mini-Libraries All in One Place!

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

Apple's Lua Pack (v1.0.3.5) - My Mini-Libraries All in One Place!

Postby AppleTheTomato » Sun Nov 05, 2023 3:01 pm

I've been helping Galeboy/HAK0TA538's with their episode SMLA (go check it out it's awesome: viewtopic.php?t=29277) and they suggested I release some of the libraries I made for them. I thought that was a great idea, especially since I had more that I use in a similar boat to those. Thing is, they aren't big enough libraries to earn a seperate forum post each, so I thought "why not group 'em together?" and here we are. I've also added libraries I HAVE seperately posted about, but they may as well go here too:
apple's Changes (.lua):
Spoiler: show
This is my general-changing library that does a lot of stuff I prefer for my projects. Reduced powerup timers, a quick-death system, spinjump patchs, dropping the reserve when hurt, faster powered forcedStates, etc:
Image
Image
Image
Image
Download: https://drive.google.com/file/d/13Uf3V- ... sp=sharing
Load in your luna.lua with something like local ch = require("appleChanges"). Here's all the settings:
Spoiler: show
*ch.quickDeathArgs - Table with arguments for the quick reload. Lines up with this: https://docs.codehaus.moe/#/reference/level-levels
Scroll down till you see Level.load and change parts of this table according to your needs, or leave it alone for default use.
There's also an extra slot on the end, "framesToWait," which is how many frames pass before reloading.

*ch.runRestartRoutine(level, episode, warp, framesToWait) - Function used to start the reloading routine. You can pass other
things for level, episode, warp, and framesToWait, but if you don't, ch.quickDeathArgs is used instead (This is what
the library does). Will NOT work if there is already a restart routine going.

*ch.loseLifeBeforeReload - Set to false to prevent losing a life before you reload
*ch.preventReload - Used by the library to prevent two reload routines running at once. Setting this to false allows a routine to happen,
setting it to true prevents it. I want to highlight, as I was told by Emral, that allowing multiple of the restart routines to run
is REALLY BAD, so don't let that happen if you abuse this field!

*ch.disableSpinshooting - When true, you don't shoot fireballs during a spinjump
*ch.disableSpinfloating - When true, Peach's floating is cancelled/unavailable during a spinjump

*ch.canDropReserve(p) - Checks if the passed player (p) should drop their reserve item when they get hurt.
*ch.paths - Table with two fields: lr and mri. The first is the path to lovelyReserves, the second is to modernReserveItems
*ch.dropReserveWhenHurt - Set this to false to PREVENT dropping your reserve when hurt.
*ch.dropReserveHurtDelay - How many frames pass before your reserve is dropped AFTER being hurt.
*ch.dropReserveWhenOnTheseMounts - Mapped table with mounts that allow you to drop the reserve when hurt.

*ch.peachCharacters - Mapped table with characters that use Peach's mem offsets (the floating ones specifically)
*ch.linkCharacters - Mapped table with characters that use Link's mem offsets (specifically the slashing / projectile cooldown ones).
*ch.bannedProjectileMounts - Mapped table with mounts that don't allow you to shoot projectiles (and SHOULDN'T mess with the projectile timer).

*ch.slowStates - Mapped table with powered forcedStates that are made faster. Each indexed state is a table with these fields:
*powerup, which is what powerup the player is set to when in this state
*iframes, which is how many invincibility frames they are given

*ch.newTimerCutoff - When the player's forcedTimer hits this number, the above are cutoff

*ch.cheepNPCs - Mapped table with Cheep-Cheep-like NPCs that should have their death cancelled when stepped on in water
*ch.forceGrabNPCs - Mapped table with NPC IDs that should be force grabbed if they have grabside enabled
boundaryCrush.lua:
Spoiler: show
This was code FireSeraphim had in SMZ (another cool episode, check it out: https://www.smwcentral.net/?p=viewthrea ... 7#p1624457) that he says he got from either MDA or MegaDood. I then asked permission to use this code and then expanded it into this. It makes the typical "autoscroll crushing" from other Marios work.
Download: https://drive.google.com/file/d/1Je-orO ... sp=sharing
Load in your luna.lua with something like local bc = require("boundaryCrush"). Here's all the settings:
Spoiler: show
*bc.enabled - Set to false to disable this library

*bc.isPlayerDead(p) - Checks if the passed player (p) has died
*bc.horizontalCrush(p) - Checks if the passed player (p) is being crushed horizontally
handyHoarder.lua:
Spoiler: show
I made this for fun in a scrapped project and then released it. It allows box users to store their held item in said box by pressing up and altRun:
Image
Download: https://drive.google.com/file/d/1YyE8c3 ... sp=sharing
Load in your luna.lua with something like local hh = require("handyHoarder"). Here's all the settings:
Spoiler: show
*hh.allowedCharacters - Which characters can store items. Used this over Graphics.getHUDType so you COULD remove box users if you want


*hh.containerNPCs - A mapped table with NPC IDs that are containers, so that if you hold one of these and store it,
the contained item will be saved for when you spawn the container again

*hh.bannedNPCs - A mapped table with banned NPCs that don't really work well with this system

*hh.transformNPCs - When you map an NPC ID to this table, you will assign it to a different NPC ID. If you are holding an NPC of the first ID,
it'll put the second ID into your reserve when you store the NPC

*hh.saveSettingsNPCs - Mapped table with NPC IDs that have their settings saved to the player that stored them.
That way, if the NPC's settings are essential, they can be applied again when they're used. Will NOT work
with the vanilla reserve. You must either be using lovelyReserves and/or modernReserveItems.


*hh.storeSounds - Table with two fields: yoshi and normal. First is a SFX ID that gets used when Yoshi saves an item, second is when you store an item yourself

*hh.enabled - Can you store your held item?
*hh.canNormalStore - Can you store an item normally?
*hh.canYoshiStore - Can Yoshi store your item?s


*hh.onStoreItem(eventToken, npc, p) - Custom event called right before default item-storing shenanigans. eventToken.cancelAll can be set to true to prevent everything,
npc is the npc that's attempting to be stored, and p is the player attempting the storing

*hh.onAdjustItem(eventTokens, npc, p, item) - Custom event called right before the stored-item-ID is adjusted regularly. eventTokens.cancelAdjustment can be set to true to prevent default adjusting,
eventTokens.cancelNPCkill can be set to true to prevent the held-NPC from dying (as well as the reserve-ing of that NPC), npc is the held-NPC in question, p is the player attempting the storing,
and item (which's .id field is what your reserve will be set to) can be maunually set to something else if eventTokens.cancelAdjustment is set to true

*hh.onPostStoreItem(p, item) - Custom event called after the item has successfully been stored. p is the player that stored their item, and item.id is what the reserve was set to
oneTimeLevels.lua:
Spoiler: show
This allows you to make certain levels unplayable once you beat them.
Download: https://drive.google.com/file/d/1fsZ7wi ... sp=sharing
Load in your luna.lua AND map.lua with something like local otl = require("oneTimeLevels"). To make a specific level unplayable once you beat it, put otl.addLevel(Level.filename()) in said level's luna.lua. Here's the settings:
Spoiler: show
*SaveData.oneTimeLevels - Table that is indexed per-level, where that level is a one time level. Each indexed part is another
level that has one field, 'hasBeaten,' which is used to check if that level has been beaten and should not be enterable
again on the world map.

*otl.addLevel(filename) - Function used to add a one time level if it hasn't been added already. You should be able to
just put 'Level.filename()' for 'filename,' unless you want to specify a level

*otl.standingOnValidLevel(filedTable) - Function that does a general check to see if, on the map, you're standing on a valid level and can
check whatever needed table (that's what 'filedTable' is for)
poweredDown.lua:
Spoiler: show
This library allows you to take away ALL of the player's powerup related things, and then give them back when you want. Here, I do it when the player enters certain sections:
Image
Download: https://drive.google.com/file/d/1vb96Mo ... sp=sharing
Load in your luna.lua with something like local pd = require("poweredDown"). Here are all the settings:
Spoiler: show
*SaveData.poweredDownplayerData - Where player data is stored for each player index. The table settings are:
reserve, for the player's reserve-powerup
powerup, for the player's powerup
mount, for the player's mount
color, for the player's mount-color

*pd.setPlayerData(i) - Sets SaveData.poweredDownplayerData with the passed player index, along with "resetting" that player
*pd.setWithPlayerData(i) - Sets the player's data using SaveData.poweredDownplayerData
removedFlight.lua:
Spoiler: show
Me and a few other people helped ArUFuhReal on Discord with code that removes the leaf flight. I held on to that for my own use and, of course, library-ified it.
Download: https://drive.google.com/file/d/1oMf0Dg ... sp=sharing
Load in your luna.lua with something like local rf = require("removedFlight"). Here's the settings:
Spoiler: show
*rf.enabled - Set to false to disable the library
starItemCounters.lua:
Spoiler: show
I extracted this from my simplifiedHUD (haha self plug: viewtopic.php?t=29156) for Galeboy/HAK0TA538's episode, and this was the code he suggested I release that inspired this pack. It draws four counters on the map: a global starcoin counter, and a per-level starcoin counter, and the same two, but for stars:
Image
Download: https://drive.google.com/file/d/1Dgb5eT ... sp=sharing
Load in your luna.lua AND map.lua with something like local sc = require("starItemCounters"). The counters will only show up if the level you're on has starcoins AND you've entered that level in some way. Here's the settings:
Spoiler: show
*SaveData.starItemCounters_starData - Where the per-level star data is saved. Has two fields: collected and total

*sc.standingOnValidLevel(levelName, t) - Checks if the level of the given name (levelName) is a valid level.
t is a table which is level file index checked in the code

*sc.getLevelFullyCollected(levelFile) - Copied from the main starcoin AI file and adjusted for the COLLECTED_WEAK starcoin state.
Checks for all fully collected/saved starcoins in the given level (using levelFile)


*sc.worldX - The x position of the redrawn stuff on the world map
*sc.worldY - The y position of the redrawn stuff on the world map

*sc.spaceBetweenCounterParts - The space between each of the counter parts (icon, cross, value, etc)
*sc.p2Offset - How much the counters move if Player 2 is on the map
*sc.priority - The priority ALL stuff is redrawn at

*sc.starCounterOffset - How much the per-level star counter is offset from the y stuff
*sc.starcoinCounterOffset - Same as the above, but for the per-level starcoin counter
*sc.starcoinOffset - Same as the two above, but for the global starcoin counter

*sc.starNPCs - Mapped table with star NPC IDs
tailToFireFixes.lua:
Spoiler: show
I made this one after seeing a discussion regarding the "invisible while powering from leaf to fire" issue. This provides fixes for ALL leaf to fire situations, like this one here:
Image
Download: https://drive.google.com/file/d/1mtrsOx ... sp=sharing
Load in your luna.lua with something like local pff = require("tailToFireFixes"). Here's the settings:
Spoiler: show
*pff.powering - The powering forced states that allow the frame fixes (Fire and Ice by default)

*pff.holdingJumpKey(p) - Checks if the passed player (p) is holding some kind of jump button

*pff.frameFixes - Table with all the possible frame fixes (Has some examples by default)

*pff.tailPowers - Table with the current tail powers (Leaf and Tanooki)
whatsInTheBox.lua
Spoiler: show
My current episode has the player as Small Mario for the majority of it, and so I wanted to find a way to get powerups to spawn normally out of blocks without turning into mushrooms. So I wrote this lol. Works pretty well, I hope:
Image
Download: https://drive.google.com/file/d/1rcIEX9 ... sp=sharing
Load in your luna.lua with something like local witb = require("whatsInTheBox"). Here's the settings:
Spoiler: show
*witb.enabled - Set to false to disable the...disabling lol

*witb.inBlockState - Mapped table with "NPC coming out of a block" states.
They relate to the 0x138 offset

*witb.powerups - Mapped table with powerup IDs that should have their progression disabled
whatsThatPowerup.lua:
Spoiler: show
In the process of remaking a bunch of playables that lacked all the necessary powerup sprites, I went to lua as a fix instead of trying to "fake" the forms. With this library, you can register certain forced states and/or powerups for a character that put them into a different state/powerup. It's got an intended use, and a cool use:
Image
Image
Download: https://drive.google.com/file/d/1rOCVlQ ... sp=sharing
Load in your luna.lua with something like local wtp = require("whatsThatPowerup"). In the library file is an example on how to use it. Here's the settings:
Spoiler: show
*wtp.enabled - Set to false to disable the library

*wtp.bannedPowers - A table with another possible table per-character. It has 4 fields:
banStates and changeStates (if you are in the first, you are put into the second),
and banPowers and changePowers (same as above, but with powerups).
These are all tables btw.
changelog lol:
Spoiler: show
*v1.0.0.0:
- First released version

*v1.0.0.1:
- Used otl.standingOnValidLevel(filedTable) from oneTimeLevels.lua in starcoinCounters.lua

*v1.0.1.0:
- Added "drop reserve when hurt" functionality to apple's Changes
- Fixed a unintentional crushing issue with boundaryCrush's vertical checks

*v1.0.2.0:
- Added faster powered forcedStates to apple's Changes
- Added whatsInTheBox.lua

*v1.0.2.1:
- apple's Changes now supports lovelyReserves

*v1.0.2.2:
- Fixed a bug with the starman and apple's Changes' drop-when-hurt stuff

*v1.0.2.3:
- handyHoarder now supports lovelyReserves

*v1.0.2.4:
- apple's Changes now removes your reserve when you die. Can be disabled in the same way the "drop reserve when hurt" can

*v1.0.2.5:
- apple's Changes got a small documentation update

*v1.0.2.6:
- starcoinCounters got a sizable update

*v1.0.2.7:
- starcoinCounters got changed to starItemCounters, and now handles stars!

*v1.0.2.8:
- starItemCounters got a small update
- Might as well group this in here, but applesChanges got a small update just now

*v1.0.2.9:
- applesChanges got a small update

*v1.0.3.0:
- applesChanges got a small update
- handyHoarder got a big update

*v1.0.3.1:
- Another solid handyHoarder update

*v1.0.3.2:
-applesChanges got the most miniscule update

*v1.0.3.3:
- applesChanges received a bug fix/new field to use

*v1.0.3.4:
- applesChanges received a minor update

*v1.0.3.5:
- applesChanges received a bug fix
Here's a download for the whole pack if you'd rather have that: https://drive.google.com/drive/folders/ ... sp=sharing
I want to thank all the individuals who either directly contributed to these libraries or indirectly did by helping me learn things about X2's lua.
Please remember to credit me if you used any of these, and have a great day!
Last edited by AppleTheTomato on Sun Jun 09, 2024 8:04 pm, edited 20 times in total.

Alexx0612
Swooper
Swooper
Posts: 50
Joined: Wed Apr 13, 2022 5:18 am
Pronouns: he/him

Re: Apple's Lua Pack (v1.0.2.3) - My Mini-Libraries All in One Place!

Postby Alexx0612 » Sun Dec 03, 2023 8:36 am

Where should I write the settings?

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

Re: Apple's Lua Pack (v1.0.2.3) - My Mini-Libraries All in One Place!

Postby AppleTheTomato » Sun Dec 03, 2023 4:43 pm

I'm not 100% sure what you mean. The settings are just the library fields that if you WANT to change, you can. You don't have to mess with them. That may have been bad wording on my part. If you DO want to change something, you'd do it like this (using starcoinCounters as an example):
local sc = require("starcoinCounters")
sc.priority = 69

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

Re: Apple's Lua Pack (v1.0.2.4) - My Mini-Libraries All in One Place!

Postby King Mario » Fri Dec 08, 2023 11:07 pm

Hi Apple! Could you please consider making a star indicator for individual levels on the world map? You know, something like your starCoinCounter, but for stars, not coins? I tried doing some things, but I'm hardly proficient at making complex lua code all by myself. I've seen that you're well-crafted and proficient at coding and do really nice things for the community, and you already made a Star Coin Counter for world map, so I didn't think doing the same for stars would be too much to ask. Thank you in advance!

Added in 2 minutes 58 seconds:
Should I just PM this?

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

Re: Apple's Lua Pack (v1.0.2.4) - My Mini-Libraries All in One Place!

Postby AppleTheTomato » Sat Dec 09, 2023 8:16 pm

I'll consider it. I've got a couple ideas for that thinking about it. And thanks for the kind words lol.

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

Re: Apple's Lua Pack (v1.0.2.4) - My Mini-Libraries All in One Place!

Postby King Mario » Sat Dec 09, 2023 9:02 pm

AppleTheTomato wrote:
Sat Dec 09, 2023 8:16 pm
Thanks for the kind words lol.
You're welcome!

DrMekar
Eerie
Eerie
Posts: 779
Joined: Sat Apr 08, 2017 7:16 am
Flair: CUSTOM CHARACTER CREATOR
Contact:

Re: Apple's Lua Pack (v1.0.2.5) - My Mini-Libraries All in One Place!

Postby DrMekar » Tue Feb 06, 2024 1:52 pm

WhatsthatPowerup is exactly what I was looking for as even though I have Code in Place to transform some Powerups, those states could still be achieved in atleast two places in my episode as the items spawned too quickly.

Great work :)

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

Re: Apple's Lua Pack (v1.0.3.2) - My Mini-Libraries All in One Place!

Postby Just_Thomas » Sat May 25, 2024 6:02 am

About: apple's Changes (.lua)
The reserve box also does drops the item if you get hit while mounted (e.g. on a Yoshi).
Can you fix that or is there a (planned new) option for this?

Code: Select all

*ch.canDropReserve(p) - Checks if the passed player (p) should drop their reserve item.
*ch.dropReserveWhenHurt - Set this to false to PREVENT dropping your reserve when hurt.
Unfortunately, this is a little too imprecise.

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

Re: Apple's Lua Pack (v1.0.3.2) - My Mini-Libraries All in One Place!

Postby AppleTheTomato » Sat May 25, 2024 7:06 pm

Just_Thomas wrote:
Sat May 25, 2024 6:02 am
About: apple's Changes (.lua)
The reserve box also does drops the item if you get hit while mounted (e.g. on a Yoshi).
Can you fix that or is there a (planned new) option for this?
That's just something I overlooked. I'll patch it in a second.
Just_Thomas wrote:
Sat May 25, 2024 6:02 am

Code: Select all

*ch.canDropReserve(p) - Checks if the passed player (p) should drop their reserve item.
*ch.dropReserveWhenHurt - Set this to false to PREVENT dropping your reserve when hurt.
Unfortunately, this is a little too imprecise.
I'm not sure what you mean by this.

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

Re: Apple's Lua Pack (v1.0.3.2) - My Mini-Libraries All in One Place!

Postby Just_Thomas » Sun May 26, 2024 4:18 am

AppleTheTomato wrote:
Sat May 25, 2024 7:06 pm
Just_Thomas wrote:
Sat May 25, 2024 6:02 am
About: apple's Changes (.lua)
The reserve box also does drops the item if you get hit while mounted (e.g. on a Yoshi).
Can you fix that or is there a (planned new) option for this?
That's just something I overlooked. I'll patch it in a second.
Just_Thomas wrote:
Sat May 25, 2024 6:02 am

Code: Select all

*ch.canDropReserve(p) - Checks if the passed player (p) should drop their reserve item.
*ch.dropReserveWhenHurt - Set this to false to PREVENT dropping your reserve when hurt.
Unfortunately, this is a little too imprecise.
I'm not sure what you mean by this.
In SMW the reserve box does NOT automatically drop the item if you get hit/hurt by an enemy, if you are on a yoshi for example.
Here however it does happen.

It does not look like I can set this up here. Either reserve box does drop the item ALL the time - when the player somehow gets hit or hurt or never.
This is what I meant the options are somehow too imprecise. Would be cool therefore it you could update that.

By the way, please don't get this wrong: I have absolute respect for your work ;)

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

Re: Apple's Lua Pack (v1.0.3.3) - My Mini-Libraries All in One Place!

Postby AppleTheTomato » Sun May 26, 2024 11:36 am

I should have fixed it. Added a new field for mounts and updated the wording for the fields you mentioned, too.

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

Re: Apple's Lua Pack (v1.0.3.3) - My Mini-Libraries All in One Place!

Postby Just_Thomas » Mon May 27, 2024 5:10 am

Thank you very much. I really appreciate that. I will edit here, if I have some [undestanding] issues.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari