simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

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

Moderator: Userbase Moderators

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Sun Nov 10, 2024 1:38 pm

Built off of Coldcolor's inventory.lua, this library adds a highly customizable inventory to your game! It requires modernReserveItems.lua by KBM-Quine, which is included in the download below!

Gameplay Features:
The inventory is pretty simple- collected powerups are added to it instead of going to your reserve itembox! You can press the "drop item" key to open the inventory and select a powerup, which will spawn it directly in front of you! Any powerup from customPowerups.lua will be detected by this library and have an additional slot created for it! As far as I've tested, all custom powerups should work, though a few (like the Penguin Suit and Frog Suit) might act a bit funky when released from the inventory.
As far as I'm aware, this library should work perfectly fine with any player character (including X2 playables like Megaman or Rosalina), though I haven't tested any characters besides Mario and Luigi (and most custom powerups only support Mario and Luigi, and occasionally Peach, Toad, and/or Link anyhow). Please let me know if you run into any issues with this library!
This library also comes with a small handful of its own cheats:
Cheats: show
"emptypockets" - Clears the player's inventory
"stockpile" - Adds one copy of every loaded powerup to the player's inventory
"imgreedy"/"fullpockets" - Maxes out the storage space of every loaded powerup in the player's inventory
"creativemode" - Gives the player an infinite supply of every item for as long as they have the cheat enabled. When the cheat is disabled, the player's inventory is returned to its state before creativemode was activated
Here are a few screenshots (and one gif) showing off the inventory! Note that although I downloaded customPowerups.lua for these showcases, it is not included in the download below, nor are any of the custom powerups you see here! (everything on the green sizeable) You'll have to download those yourself. The test level itself is also not included, though a sample luna.lua file is!
Showcase Screenshots: show
Gif showcasing some of the features:
Image

Screenshots of the UI in various states from the same session as the gif:
Image
Image
Image
Image
Image
Image
Image

Screenshot after adding bonus slots for some vehicles in a luna.lua file:
Image
Finally, here's the download link for the library!
Downloads: show
v1.0: Download


How to Use:
  1. Download the files from the link above (which includes the library itself and the required assets, modernReserveItems.lua, and an example luna.lua file)
  2. Copy "simpleInventory.lua", "modernReserveItems.lua", and the "inventory" folder into your episode's folder (SMBX2/data/worlds/Your Episode Name)
  3. Add the following code to a luna.lua file in your episode:

    Code: Select all

    local inventory = require("simpleInventory")
  4. You should be good to go! If you want to tweak some of the settings in the library, you'll want to add a bit more code to your luna.lua file. You can find several examples in the example luna.lua file in the download above, but here's some basic examples too:
    Customization Example: show

    Code: Select all

    local inventory = require("simpleInventory")
    
    -- This will make it so that the inventory doesn't close when the player selects a powerup
    inventory.settings.closeOnSpawn = false
    
    -- This will increase the maximum amount of Super Mushrooms that can be held at once from 99 to 999
    inventory.settings.maxStorage["mushroom"] = 999
    
    -- This will allow the player to pocket any Starman they touch instead of becoming invulnerable immediately,
    -- but they can only store one at a time
    inventory.settings.starmanSlot = true
    inventory.settings.collectableStarmans = true
    inventory.settings.maxStorage["starman"] = 1

Changelogs
Changelogs: show
v1.0 - Initial public release! Since there aren't any changes to list from prior versions of this library, I'll instead go over what I've changed from Coldcolor's inventory.lua:
  • Reworked how the inventory detects when an item enters the reserve itembox, so that anything that adds an item to the reserve itembox automatically sends it to the inventory! (This includes vanilla cheats like "needaflower", lakitu shops configured to put items in the reserve itembox, and of course, powerups that are stored there because you collected another one)
  • Made the library use modernReserveItems.lua to spawn powerups, rather than having the player's state automatically change
  • Increased the default maximum supply of all powerups from 5-10 to 99
  • Tweaked how the quantity text is drawn, so that it can support numbers up to three digits, instead of only one or two
  • Changed how each slot is drawn- the panel is now a separate image, and powerup icons are loaded dynamically from their NPC textures. This means any powerup graphics replacements will be automatically applied to the inventory HUD!
  • Added support to automatically load powerups from customPowerups.lua! (Also added special behavior for the Cloud Flower to make it not add to the inventory if it should be consumed)
  • Added tons of settings, some of which include toggling features that were present in the original library (such as the feature that stopped the player from spawning powerups for the state they were in) and others are entirely new options (such as repositioning the HUD, replacing the HUD textures and sounds, adding a Starman and/or Mega Mushroom slot, and more!). See the "settings" spoiler below for a full list
  • Due to the fact that the inventory can have a dynamic number of powerup slots, it is now paginated; you can use the up/down arrows to cycle through the pages if more than a configurable number of powerups are loaded!
  • Added several functions and events for other coders to use, ranging from adding/setting item quantities to detecting when the inventory is opened or closed! See the sections on those for more details
  • Added four cheats- "emptypockets" (clears the inventory), "stockpile" (adds one item to every slot), "imgreedy"/"fullpockets" (maxes out every slot), and "creativemode" (gives infinite items)
  • Added custom drawing behavior for Yoshis; so long as their modernReserveItems configs are set up properly, any slot containing a Yoshi will display them in their colored egg! In fact, any NPC with a specified "idOverwrite" in modernReserveItems will display the container NPC instead of the actual NPC


Functions, Events, Settings, and SaveData:
For anyone looking to make more advanced use of this library, a large amount of settings and a few custom functions and events have been added! Starting with the events, they're accessed the same way as any other event, like so:
New Events: show

Code: Select all

-- Triggers when the inventory is opened, and allows you to cancel opening the inventory with eventObj.cancelled = true
function onInventoryOpen(eventObj)
	-- Your code goes here
	--eventObj.cancelled = true -- This would prevent the inventory from opening
end

-- Triggers when the inventory is closed, and allows you to cancel closing the inventory with eventObj.cancelled = true
function onInventoryClose(eventObj)
	-- Your code goes here
	--eventObj.cancelled = true -- This would prevent the inventory from closing
end

-- Triggers immediately after the inventory has opened, only if it successfully opened (so if you set eventObj.cancelled = true in onInventoryOpen, this would not run)
function onPostInventoryOpen()
	-- Your code goes here
end

-- Triggers immediately after the inventory has closed, only if it successfully closed (so if you set eventObj.cancelled = true in onInventoryClose, this would not run)
function onPostInventoryClose()
	-- Your code goes here
end

-- Triggers when an item is slated to be added to the inventory, passing in a token to cancel the addition ("eventObj"), the name of the powerup added ("slot"), and the number of items added ("quantity")
-- Note that this is called by both inventory.addItem() and inventory.setItemCount()! In both cases, the net change in item quantity is passed in to the "quantity" argument, and there's no distinction between the two
function onInventoryItemAdded(eventObj, slot, quantity)
	-- Your code goes here
end

-- Triggers immediately after any item is added to the inventory, only if it was successfully added (same logic as onPostInventoryOpen/Close)
-- Passes in the name of the powerup added ("slot") and the number of items added ("quantity")
-- Note that this is called by both inventory.addItem() and inventory.setItemCount()! In both cases, the net change in item quantity is passed in to the "quantity" argument, and there's no distinction between the two
function onPostInventoryItemAdded(slot, quantity)
	-- Your code goes here
end

-- Triggers any time inventory slots are being generated (namely in onStart() and whenever inventory.regenerateSaveData() is called)
-- The purpose of this event is for other libraries to generate their slots here to ensure consistency with what order things generate in
-- If you generate your slots here, they will always be placed after the Starman and Mega Mushroom slots (if those are enabled) but before any customPowerups slots
-- Note that this consistency is not guaranteed if customPowerups slots already exist before you generate your slots
function onInventorySlotsGenerate()
	-- Your code goes here
end
As for functions, there's quite a few of those as well! They're documented in great detail in the code itself (including support for the Visual Studio lua addon), but I'll list all of them here too:
Functions: show

Code: Select all

-- Returns the name of a powerup slot given an alias
-- For example, "Super Mushroom", "SuperShroom", "shroom", etc. would all return "mushroom"
-- This method is automatically called by most functions that call for a slot name (such as addItem and getSlot)
-- This method also automatically removes capitalization, spaces, hyphens, and underscores from input aliases, so it's quite flexible with what is a valid alias!
-- (i.e, you don't have to specifically add "Super Mushroom" as an alias, it'll automatically work as an alias if "supermushroom" is an alias, which it is by default)
inventory.getAlias(name)

-- Given a name (or existing alias) and either a new alias or a list of new aliases, adds them to the internal alias map, allowing them to be returned by getAlias()
-- This is mostly useful for custom powerups, since by default they don't have any aliases (aside from accounting for capitalization/spaces/etc.)
-- Example: inventory.addAlias("Bee Mushroom", { "bee", "beeShroom" })
-- Assuming you kept the default internal name of the Bee Mushroom custom powerup, this would create two new valid aliases, so you could call inventory.getSlot("bee") instead of having to type out "beemushroom" or "Bee Mushroom" every time
inventory.addAlias(name, newAlias)

-- Given the name (or alias) of a slot, returns its numerical index
-- This is needed to access the inventory list in SaveData (SaveData.inventory[inventory.getSlot("Super Mushroom")] for example)
inventory.getSlot(name)

-- Creates a new slot and returns its index (or, if a slot with this name already exists, returns that slot's numerical index)
-- Newly-created slots are always appended at the end of the list in SaveData
-- Unlike the other functions, this one uses named args (similar to, say, textplus.print). The valid arguments for this method are as follows:
-- "name": The name of the new slot (required)
-- "defaultPowerup": The NPC ID to use as the slot's icon, and to spawn when the player takes an item from this slot (required)
-- "givenState": The powerup state the player enters upon consuming a powerup associated with this slot
-- "minStorage", "maxStorage", and "quantity": Numbers defining the corresponding values for this slot
-- "aliases": A table of strings defining the aliases for this slot
-- "linkedPowerups": A table of NPC IDs defining the non-default powerups linked to this slot
-- "overwriteMRI": A boolean specifying whether or not to replace modernReserveItem's default configs for the provided NPC ID
-- "mriSettings": A table containing config data for modernReserveItems (see that library's post for more details). Only used if "overwriteMRI" is also true, and if not specified while "overwriteMRI" is true, a default set of configs will be applied that ensures consistent behavior for all spawned powerups
inventory.newSlot(args)

-- Removes the specified slot from SaveData.inventory
-- As with most methods, you can input an alias and it will be automatically accounted for
inventory.removeSlot(name)

-- Basically nukes the entire SaveData.inventory table and recreates it from scratch
-- I don't see this being too useful, but maybe it could be useful if you remove a bunch of custom powerups and don't want to manually remove each slot? Or maybe if you enable the Starman/Mega Mushroom slots late and don't like them being at the end of the list?
-- Do keep in mind, however, that inventory data obviously does not transfer across saves! So anyone who plays your episode should see the inventory generate with the "proper" order, assuming they're booting up your episode for the first time
inventory.regenerateSaveData()

-- Adds items to a slot in the inventory. "num" is a number specifying the amount. If not specified, num is automatically inferred as 1 (so you can just do inventory.addItem("mushroom") to add one Super Mushroom to the inventory)
-- "slot" can either be a string for the type of item you want to add (aliases are supported), or an index number for the slot (obtained from inventory.getSlot())
inventory.addItem(slot, num)

-- Sets the amount of items in a given slot to the specified number. "slot" and "num" are the same as in addItem, except that "num" is required here.
-- The difference between addItem and setItemCount can be visualized like so:
-- inventory.addItem("mushroom", 10): 5 -> 15
-- inventory.setItemCount("mushroom", 10): 5 -> 10
inventory.setItemCount(slot, num)

-- Clears every slot in the player's inventory, setting their quantities to the minimum value. Same functionality as the "emptypockets" cheat
inventory.clear()

-- Opens and closes the inventory respectively!
inventory.open()
inventory.close()
In addition to events and methods, simpleInventory.lua has a whole host of settings you can mess with! Here's those if you want to take a look:
Settings: show

Code: Select all

-- If true, prevents the player from selecting powerups if they are already in the corresponding state. Defaults to false
inventory.settings.disableRepeatSpawning = false

-- If true, closes the inventory automatically when the player selects a powerup to spawn. Defaults to true
inventory.settings.closeOnSpawn = true

-- Controls the number of powerup slots displayed on a single page. I don't recommend going over 12, because the 13th slot onwards will render offscreen while the inventory is opened. It still functions fine, but you won't be able to see what you have selected
-- Defaults to 10
inventory.settings.powerupsPerPage = 10

-- If true, shows 2 x powerupsPerPage inventory slots while the inventory is closed. Defaults to true
inventory.settings.showTwoPagesWhenClosed = true

-- If true, displays the quantities of items while the inventory is closed. Defaults to true
inventory.settings.showCountsWhenClosed = true

-- Controls the position at which the inventory HUD is displayed. vector(0, 0) is the top-left corner of the screen. Defaults to vector(20, 536)
-- The height of the HUD controls whether it expands up, down, or centered when opened
inventory.settings.hudPosition = vector(20, 536)

-- If true, adds an inventory slot for the Starman or Mega Mushroom, respectively. If collectableStarmans/collectableMegas is false, you will need to do some lua coding to add either item to the player's inventory yourself (such as setting up a Lakitu Shop to send items to the player's reserve itembox). Both default to false
inventory.settings.starmanSlot = false
inventory.settings.megaSlot = false

-- If true (and starmanSlot/megaSlot is true), collecting a Starman or Mega Mushroom respectively through any means adds it to your inventory instead of providing their default effects. Probably not a good idea to enable this unless you account for players being able to use these items at any time in any level. Defaults to false
inventory.settings.collectableStarmans = false
inventory.settings.collectableMegas = false

-- If false, entering any of the cheats from this library will not do anything. "emptypockets" is not considered a cheat, and is not affected by this config option. Defaults to true
inventory.settings.enableCheats = true

-- Controls which image files are loaded for the background panels and selector. Powerup images are loaded automatically, and are not included here. Defaults to the following files:
inventory.settings.images.panel = Graphics.loadImage(Misc.resolveFile("inventory/panel.png"))
inventory.settings.images.selector = Graphics.loadImage(Misc.resolveFile("inventory/selector.png"))

-- Controls which audio files are loaded for the five custom sound effects. If you want to use a vanilla sound, you can set these variables to the sound ID of whatever sound you want (see SMBX2/data/_templates/sounds.ini for a list of all the sound IDs) Defaults to the following files:
inventory.settings.sounds.errorSFX = Misc.resolveFile("inventory/error.wav")
--inventory.settings.sounds.errorSFX = 9 -- Vanilla sound ID example, this one points to the "Shell Kick" sound
inventory.settings.sounds.closeSFX = Misc.resolveFile("inventory/invclose.wav")
inventory.settings.sounds.openSFX = Misc.resolveFile("inventory/invopen.wav")
inventory.settings.sounds.menuSFX = Misc.resolveFile("inventory/menuselect.wav")
inventory.settings.sounds.selectSFX = Misc.resolveFile("inventory/powerupselect.wav")
Finally, I may as well explain how the inventory data is stored in SaveData, since it's accessible to any lua file:
SaveData.inventory: show

Code: Select all

-- Each powerup type has its own numerical index, which you can access with inventory.getSlot() like so:
local idx = inventory.getSlot("Super Mushroom")

-- This will allow you to access SaveData.inventory like so:
SaveData.inventory[idx] --[[ Returns a table that looks like this: {
	name="mushroom",
	defaultPowerup=9, -- SMB3 Super Mushroom
	givenState=PLAYER_BIG, -- Will be nil for Starman, Mega Mushroom, and custom powerups
	minStorage=0,
	maxStorage=99,
	quantity=0
}]]--

-- If you want to set the min/max storage of an item, you can do so like this:
SaveData.inventory[idx].minStorage = 10
SaveData.inventory[idx].maxStorage = 999 -- Note: Numbers above 999 are allowed, but may look funny in the HUD

-- Another useful table you have access to is inventory.itemMap, which lets you take any NPC ID and figure out what slot it corresponds to!
inventory.itemMap[183] -- npc-183 is the SMW Fire Flower, so this would return "fire"
Last edited by Lurrae on Sun Nov 10, 2024 1:57 pm, edited 1 time in total.

Coldcolor
Koopa
Koopa
Posts: 18
Joined: Tue Oct 23, 2018 1:15 pm
Pronouns: he/him
Contact:

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Coldcolor » Sun Nov 10, 2024 1:45 pm

You made my inventory library actually good and not broken! Yay!

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

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby mariobrigade2018 » Sun Nov 10, 2024 2:56 pm

Jesus, that’s a big post.

Also I’m very happy that we now can have a nice Bowser’s Fury inventory system that supports custom powerups! You should be proud of yourself.

I do have one question. Can you rearrange how the powerup are listed?

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Sun Nov 10, 2024 5:43 pm

mariobrigade2018 wrote: I do have one question. Can you rearrange how the powerup are listed?
Technically, if you edit the SaveData file directly, that might allow you to adjust the order the slots show up, though that would only affect one specific save file. There's probably some way I could change how the inventory is saved/loaded to allow altering the order of the slots, but for now I don't believe there's any easy way to change the load order of powerups across all save files.

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

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby mariobrigade2018 » Sun Nov 10, 2024 5:49 pm

All right. Thanks!

Added in 4 hours 31 minutes 28 seconds:
Found a bug

Image

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Sun Nov 10, 2024 11:41 pm

mariobrigade2018 wrote:
Sun Nov 10, 2024 10:21 pm
Found a bug

Image
Hm... That's an odd bug. Looks like the texture for some powerup couldn't be loaded? Without access to the level you were testing in, I can't really determine what else would've caused it. Were you using any custom powerups, or did you add a new NPC to the inventory? The most likely culprit is some custom powerup or other NPC I didn't test was added, and the inventory couldn't fetch its texture for whatever reason. That, or the inventory system doesn't play as nicely with custom textures as I thought... Let me know if you were using any custom textures, custom powerups, or added any new slots to the inventory!

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

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby mariobrigade2018 » Sun Nov 10, 2024 11:46 pm

Lurrae wrote:
Sun Nov 10, 2024 11:41 pm
mariobrigade2018 wrote:
Sun Nov 10, 2024 10:21 pm
Found a bug

Image
Hm... That's an odd bug. Looks like the texture for some powerup couldn't be loaded? Without access to the level you were testing in, I can't really determine what else would've caused it. Were you using any custom powerups, or did you add a new NPC to the inventory? The most likely culprit is some custom powerup or other NPC I didn't test was added, and the inventory couldn't fetch its texture for whatever reason. That, or the inventory system doesn't play as nicely with custom textures as I thought... Let me know if you were using any custom textures, custom powerups, or added any new slots to the inventory!
I do have custom powerups (all bells, the white leaf, and the cape) and all powerups I’m using have custom textures, so that’s probably what’s going on. I’ll send my test level in PMs.

Added in 2 hours 20 minutes 32 seconds:
Alright. As promised, I sent the test level in PMs.

Paka_Mzuri
Goomba
Goomba
Posts: 3
Joined: Fri Jan 17, 2025 9:56 pm
Pronouns: He/Him or They/Them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Paka_Mzuri » Mon Apr 07, 2025 3:53 pm

Currently having issues editing the max inventory amount for custom powerups, for whatever reason custom powerups dont go into the inventory at all for whatever reason. Does anyone have any ideas as to what could be causing this or how I can fix it?

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

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby DrMekar » Thu Apr 10, 2025 3:04 pm

That looks amazing and will defenitly will come in handy, especially with the fact that some Powerups are quite rare in my Episode.

Anyway, I did entcountered this error popping up. All Custom Powerups except two also don't seem to work all the time as they sometimes don't register.
Image


Image

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Mon May 12, 2025 9:40 pm

Paka_Mzuri wrote:
Mon Apr 07, 2025 3:53 pm
Currently having issues editing the max inventory amount for custom powerups, for whatever reason custom powerups dont go into the inventory at all for whatever reason. Does anyone have any ideas as to what could be causing this or how I can fix it?
DrMekar wrote:
Thu Apr 10, 2025 3:04 pm
That looks amazing and will defenitly will come in handy, especially with the fact that some Powerups are quite rare in my Episode.

Anyway, I did entcountered this error popping up. All Custom Powerups except two also don't seem to work all the time as they sometimes don't register.
Image


Image
Apologies for not getting back to you two sooner! Now that I'm looking at the issues you two are having, I'm realizing that any character that does not have a reserve itembox by default (such as Peach, Toad, or Link) won't actually work with the inventory at all because powerups are only added to the inventory if they're added to the itembox first, which never happens for characters without the itembox. I'm also realizing that the code I use to hide the itembox for Mario/Luigi also hides the hearts for other characters... This is what I get for not testing any characters besides Mario and Luigi, I guess ^-^;
For now, the hearts being invisible can be fixed by simply commenting out/deleting line 631 of simpleInventory.lua:

Code: Select all

hudoverride.visible.itembox = false
(EDIT: You can alternatively add this check instead:)

Code: Select all

if Graphics.getHUDType(player.character) ~= Graphics.HUD_HEARTS then
	hudoverride.visible.itembox = false
end
That said, this doesn't explain the issues you were having DrMekar, since it looks like you were playing as Mario... Would you be able to send your luna.lua file? That might help me troubleshoot what's going wrong there

legacy
Goomba
Goomba
Posts: 2
Joined: Mon Jan 23, 2023 4:34 pm
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby legacy » Wed May 14, 2025 2:31 am

getting quite a few errors that make the inventory ui not appear and error out entirely when i try and get an item out of the reserve. there's no custom powerups in the level either

Image

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Wed May 14, 2025 6:13 pm

legacy wrote:
Wed May 14, 2025 2:31 am
getting quite a few errors that make the inventory ui not appear and error out entirely when i try and get an item out of the reserve. there's no custom powerups in the level either

Image
That's a weird error... I'm not sure why it would be happening; the obvious thing is that some variables aren't being set to what they should, but everything that I would assume could produce that error should be erroring before the line that errors if I'm understanding the error right.
I'll try to look into it, but in the meantime would you be able to find a save#-ext.dat file (not sure how much it'll help me but it's worth a shot) and send that to me, either here or in private messages? If there's anything noteworthy in your luna.lua file (i.e, anything other than loading libraries like simpleInventory) I'd appreciate if you could share that as well

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

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby DrMekar » Fri May 16, 2025 9:48 am

Lurrae wrote:
Mon May 12, 2025 9:40 pm
Paka_Mzuri wrote:
Mon Apr 07, 2025 3:53 pm
Currently having issues editing the max inventory amount for custom powerups, for whatever reason custom powerups dont go into the inventory at all for whatever reason. Does anyone have any ideas as to what could be causing this or how I can fix it?
DrMekar wrote:
Thu Apr 10, 2025 3:04 pm
That looks amazing and will defenitly will come in handy, especially with the fact that some Powerups are quite rare in my Episode.

Anyway, I did entcountered this error popping up. All Custom Powerups except two also don't seem to work all the time as they sometimes don't register.
Image


Image
Apologies for not getting back to you two sooner! Now that I'm looking at the issues you two are having, I'm realizing that any character that does not have a reserve itembox by default (such as Peach, Toad, or Link) won't actually work with the inventory at all because powerups are only added to the inventory if they're added to the itembox first, which never happens for characters without the itembox. I'm also realizing that the code I use to hide the itembox for Mario/Luigi also hides the hearts for other characters... This is what I get for not testing any characters besides Mario and Luigi, I guess ^-^;
For now, the hearts being invisible can be fixed by simply commenting out/deleting line 631 of simpleInventory.lua:

Code: Select all

hudoverride.visible.itembox = false
(EDIT: You can alternatively add this check instead:)

Code: Select all

if Graphics.getHUDType(player.character) ~= Graphics.HUD_HEARTS then
	hudoverride.visible.itembox = false
end
That said, this doesn't explain the issues you were having DrMekar, since it looks like you were playing as Mario... Would you be able to send your luna.lua file? That might help me troubleshoot what's going wrong there
Sure, here it is.
https://pastebin.com/XhzMuBng

It's a bit chaotic so apolgies for that, but I only really added the libary so far without any settings or changes. In case it's any help, My Episode also uses all 5 default characters and the following Custom Powerups:
- Cape Feather
- Superball Flower
- Gold Flower
- Jumping Lui (Renamed to Grey Suit)
- Plasma Shell
- Swooper Suit

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Fri May 16, 2025 1:38 pm

DrMekar wrote: Sure, here it is.
https://pastebin.com/XhzMuBng

It's a bit chaotic so apolgies for that, but I only really added the libary so far without any settings or changes. In case it's any help, My Episode also uses all 5 default characters and the following Custom Powerups:
- Cape Feather
- Superball Flower
- Gold Flower
- Jumping Lui (Renamed to Grey Suit)
- Plasma Shell
- Swooper Suit
Hm, actually maybe it would be easier for me to troubleshoot things if you could send the full episode as a zip file? (again, either here or PMs is fine!) It'll be easier to figure out the issue if I have the proper environment in which to replicate it, especially with all of the additional powerups and other libraries you've got. For now I'll just start by adding the powerups you mentioned to my test episode and see if I can replicate any of the issues that way

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

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby DrMekar » Fri May 16, 2025 2:28 pm

Lurrae wrote:
Fri May 16, 2025 1:38 pm
DrMekar wrote: Sure, here it is.
https://pastebin.com/XhzMuBng

It's a bit chaotic so apolgies for that, but I only really added the libary so far without any settings or changes. In case it's any help, My Episode also uses all 5 default characters and the following Custom Powerups:
- Cape Feather
- Superball Flower
- Gold Flower
- Jumping Lui (Renamed to Grey Suit)
- Plasma Shell
- Swooper Suit
Hm, actually maybe it would be easier for me to troubleshoot things if you could send the full episode as a zip file? (again, either here or PMs is fine!) It'll be easier to figure out the issue if I have the proper environment in which to replicate it, especially with all of the additional powerups and other libraries you've got. For now I'll just start by adding the powerups you mentioned to my test episode and see if I can replicate any of the issues that way
Sure. The Episode is quite large so I quickly made
a copy containing only the level from the screenshots
and (hopefully) all essential files, but no other levels
or the music.

https://www.mediafire.com/file/uiilsv23 ... t.zip/file

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Fri May 16, 2025 2:41 pm

DrMekar wrote: Sure. The Episode is quite large so I quickly made
a copy containing only the level from the screenshots
and (hopefully) all essential files, but no other levels
or the music.

https://www.mediafire.com/file/uiilsv23 ... t.zip/file
Great, thank you! I did manage to replicate the custom powerups not entering the inventory actually, so I'm gonna see if I can fix that first and then look into the error message you were getting

Added in 24 minutes 13 seconds:
Do you have an npc-755 in your episode? I'm getting errors when I try to enter a level that seems to indicate that it's trying to load an npc texture from that ID, but there's no npc with that ID in the episode from the looks of things. Did you change a powerup's ID and forget to update some of the references to that ID or something?

Added in 58 minutes 28 seconds:
Okay, I think what must have happened is that at some point, you had different powerups in the episode than what you have now, and simpleInventory doesn't really know how to handle that on its own. I was able to fix it by pressing tab and typing this into the console that popped up:

Code: Select all

require("simpleInventory").regenerateSaveData()
After I ran this, the inventory seemed to have no issues loading any powerup textures, and the regeneration code only needs to be run once in order to work properly. Another way to fix it would be to clear out your SaveData entirely, as the issue is exclusively tied to the SaveData storing powerup IDs that no longer correspond to content that exists (which also means that players playing your episode shouldn't run into the issue). The next version of simpleInventory will use a fallback texture in the event that a texture can't be found, which I honestly should have done from the start

legacy
Goomba
Goomba
Posts: 2
Joined: Mon Jan 23, 2023 4:34 pm
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby legacy » Fri May 16, 2025 4:16 pm

Lurrae wrote:
Wed May 14, 2025 6:13 pm
legacy wrote:
Wed May 14, 2025 2:31 am
getting quite a few errors that make the inventory ui not appear and error out entirely when i try and get an item out of the reserve. there's no custom powerups in the level either

Image
That's a weird error... I'm not sure why it would be happening; the obvious thing is that some variables aren't being set to what they should, but everything that I would assume could produce that error should be erroring before the line that errors if I'm understanding the error right.
I'll try to look into it, but in the meantime would you be able to find a save#-ext.dat file (not sure how much it'll help me but it's worth a shot) and send that to me, either here or in private messages? If there's anything noteworthy in your luna.lua file (i.e, anything other than loading libraries like simpleInventory) I'd appreciate if you could share that as well
The most I really have in the luna.lua aside from enabling simpleinventory is some code setting the camera and resolution, that's pretty much it. I don't have a save-ext.dat file either

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Fri May 16, 2025 4:34 pm

I see... Would you be able to send your episode folder as well? Hopefully that'll allow me to reproduce the issue and figure out what causes it, since I'll have all the same files you have

Lurrae
Bob-Omb
Bob-Omb
Posts: 23
Joined: Sun Apr 17, 2016 8:08 am
Pronouns: he/him or they/them

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby Lurrae » Fri May 16, 2025 11:14 pm

...Oh, that's interesting: Apparently if you have customPowerups.lua active, even if you don't have any actual powerups to go with it, heart characters like Peach and Toad will actually send excess powerups to the inventory! I'm still gonna try to look into making it work without any additional libraries tho

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

Re: simpleInventory.lua [v1.0] - Yet another Bowser's Fury-inspired inventory!

Postby DrMekar » Sat May 17, 2025 2:36 am

Lurrae wrote:
Fri May 16, 2025 4:04 pm
DrMekar wrote: Sure. The Episode is quite large so I quickly made
a copy containing only the level from the screenshots
and (hopefully) all essential files, but no other levels
or the music.

https://www.mediafire.com/file/uiilsv23 ... t.zip/file
Great, thank you! I did manage to replicate the custom powerups not entering the inventory actually, so I'm gonna see if I can fix that first and then look into the error message you were getting

Added in 24 minutes 13 seconds:
Do you have an npc-755 in your episode? I'm getting errors when I try to enter a level that seems to indicate that it's trying to load an npc texture from that ID, but there's no npc with that ID in the episode from the looks of things. Did you change a powerup's ID and forget to update some of the references to that ID or something?

Added in 58 minutes 28 seconds:
Okay, I think what must have happened is that at some point, you had different powerups in the episode than what you have now, and simpleInventory doesn't really know how to handle that on its own. I was able to fix it by pressing tab and typing this into the console that popped up:

Code: Select all

require("simpleInventory").regenerateSaveData()
After I ran this, the inventory seemed to have no issues loading any powerup textures, and the regeneration code only needs to be run once in order to work properly. Another way to fix it would be to clear out your SaveData entirely, as the issue is exclusively tied to the SaveData storing powerup IDs that no longer correspond to content that exists (which also means that players playing your episode shouldn't run into the issue). The next version of simpleInventory will use a fallback texture in the event that a texture can't be found, which I honestly should have done from the start
Thank You, it works now. I can't remember using ID 755 for a global npc, but it's entirely possible that I did when I tried through diffrent Powerups.


Return to “LunaLua”

Who is online

Users browsing this forum: PizzaNoob, RimeNTreason and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari