Rixi's lua draft collection

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

Moderator: Userbase Moderators

Rixitic
Spike
Spike
Posts: 269
Joined: Sat Dec 12, 2015 1:00 am
Contact:

Rixi's lua draft collection

Postby Rixitic » Fri Jul 19, 2024 3:22 am

Occasionally I'll write something for a project that I realize could be useful as a standalone library, but then I never actually get it to a release-worthy state with all the necessary preparations -- writing documentation, cleaning up the comments and debug calls, preparing a sample level and sample code, etc.

At some point, it's better to just put the code out there in its current state than keep sitting on them, right? So, as I did with the Terraria NPC pack, here's three lua libraries I'm releasing in their current state! I'll post more whenever they happen.

Everything in this thread comes as-is with no guarantees of support or updates, but they worked the last time I checked and if there are any issues they shouldn't need much work to fix up. And if someone wants to finish and package up any of these as proper releases, go for it!


shuffledQueues.lua
A library for managing randomly-shuffled lists with additional handling for avoiding repeated values. Good for boss attack queues, card decks... I guess if you want to make a roguelike in SMBX you could use it for that too?

cgfxBridge.lua
You know how you can use a folders.ini file to tell the editor which subfolders your episode's custom graphics and config files are in? Well, you can override that file for individual levels. Doing so can make assets show up properly in the editor even if they're not in the level's resource folder, but those graphics and configs still won't be applied when playing the level.

cgfxBridge fixes that to an extent by comparing the episode and level folders.ini files, loading images and txt files from any unique paths listed, and applying them to Graphics.sprites.npc, Block.config, etc. This means that if you have a tileset you'll be using in multiple levels but don't want to make all of those assets episode-wide resprites, you can just store them in one place and have those levels share them! As of version 0.4, it also supports replacements for SMBX 1.3 sound effects (the ones in this list here.)

Note that this only changes things on the in-game side, the current limits of folders.ini still apply within the editor; you'll still need to include, for example, copies of any custom tileset inis in the level's resource folder.

Here's the older version 0.3.5 if you want that for whatever reason.

customAssetHelper.lua
Say you want to set up a type of custom asset used in your episode, like hats or inventory items. You could just store the assets' data as hardcoded nested tables, but you'd prefer to set it up within SMBX's file-and-folder workflow so that things are a bit more collaboration-friendly.

This library lets you define custom asset types that work similarly to costumes, with each asset of that type getting its own folder and specific files to check for within that folder; so, for example, your episode might look something like this:

  • ExampleEpisode
    • danielcraig
      • danielcraig.png
      • luna.lua
    • danielcraig.lvlx
    • FINALBOSS
    • FINALBOSS.lvlx
    • hats
      • ribbon
        • config.json
        • above.png
        • below.png
        • icon.png
      • beret
        • config.json
        • above.png
        • below.png
        • icon.png
      • aviator
        • config.json
        • above.png
        • below.png
        • icon.png
    • luna.lua

Then in your code you can do this:

Code: Select all

local customAssetHelper = require("customAssetHelper")

local hatData = customAssetHelper.importAssets{
        folder = "hats",
        prefix = "Hat",
        images = {"above","below","icon"}
}

function onStart()
        Misc.dialog(HAT_AVIATOR, HAT_RIBBON, "", hatData)
end
delightfulSoundTest.lua
Someone on Discord asked for help with making a sound test, so I threw together this library from the one I made for Delightful Enhanced.

Here's footage of the original in action, which doesn't want to work with the youtube tag for some reason.
Last edited by Rixitic on Wed Jun 04, 2025 2:58 pm, edited 3 times in total.

Rixitic
Spike
Spike
Posts: 269
Joined: Sat Dec 12, 2015 1:00 am
Contact:

Re: Rixi's lua draft collection

Postby Rixitic » Tue Sep 17, 2024 11:51 am

I've updated cgfxBridge.lua to fix a number of bugs, make the library a bit more configurable, and improve commenting and clarity in some places. It also now needs to be run manually with cgfxBridge.apply() after importing it; see the added instructions at the start of the library for more info. Shout-out to Chipss for the thorough testing and being super patient during the troubleshooting process!

Here's a quick link for convenience, but the link in the OP points to v.0.3.5 as well.

I'll see about writing a docs page for folders.ini in the near(ish?) future.

Rixitic
Spike
Spike
Posts: 269
Joined: Sat Dec 12, 2015 1:00 am
Contact:

Re: Rixi's lua draft collection

Postby Rixitic » Tue May 27, 2025 8:18 pm

Another quick update: I wrote the folders.ini docs entry a while ago and cgfxBridge v0.4, which now properly supports sound effect replacements (at least for the original 91 SMBX 1.3 sounds, not the extended ones.)

Once again, providing those links for convenience but the original post has been updated to include them as well.

Rixitic
Spike
Spike
Posts: 269
Joined: Sat Dec 12, 2015 1:00 am
Contact:

Re: Rixi's lua draft collection

Postby Rixitic » Wed Jun 04, 2025 2:34 pm

New library:

delightfulSoundTest.lua
Someone on Discord asked for help with making a sound test, so I threw together this library from the one I made for Delightful Enhanced.

Here's footage of the original in action, which doesn't want to work with the youtube tag for some reason.


Return to “LunaLua”

Who is online

Users browsing this forum: Amazon [Bot], Bedream, lugiaTheAntarticLord and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari