mt-mods / pipeworks

Pipeworks is a mod for Minetest allowing the crafting and usage of pipes and tubes
Other
15 stars 22 forks source link

attempt to index global 'unified_inventory' (a boolean value) error message #97

Closed DustyBagel closed 1 year ago

DustyBagel commented 1 year ago

If you try to run a world with PipeWorks, moreores, basic materials, and xboxs enabled, you get this error message: 2023-11-20 19:33:01: ERROR[Main]: ...t\dev\minetest\bin\Release....\mods\pipeworks\init.lua:207: attempt to index global 'unified_inventory' (a boolean value) In order to get this error message, you need to have pipeworks, moreores, basic materials, and xbows installed at the same time. I don't know why you need all of these for it to not work but that's how I got it. I don't know if it is something on the pipeworks end or on the other mod's end, but something is causing this issue. I do however have a fix for this issue. If you replace the lines 207 to 215 in the init.lua file with this code: if type(unified_inventory) == "table" and type(unified_inventory.registered_categories) == "table" then if not unified_inventory.registered_categories["automation"] then unified_inventory.register_category("automation", { symbol = "pipeworks:lua_tube000000", label = "Automation components" }) end unified_inventory.add_category_items("automation", pipeworks.ui_cat_tube_list) end

It fixes the problem. Thought you may have a problem with using this code as it is AI generated. I have confirmed that it does work thought.

OgelGames commented 1 year ago

Here's your problem, xbows is replacing the unified_inventory global, along with a bunch of other globals: https://bitbucket.org/minetest_gamers/x_bows/src/cc5afc5bd754c609db797338ff96939ea6014031/init.lua?at=master#lines-24

DustyBagel commented 1 year ago

Oh, that's what was casing it. So, I assume that this fix I suggested will not be used?

OgelGames commented 1 year ago

Although the cause should be fixed in xbows, I've added a fix to prevent similar problems, which should work to fix the error: https://github.com/mt-mods/pipeworks/commit/7c74d0bdf3259276721f594432912072f4a53bf8

DustyBagel commented 1 year ago

Good to know. Do you need it tested before you release it to the content database?

OgelGames commented 1 year ago

No, automatic releases are enabled, so it should update within a day.

JurajVajdaSakel commented 11 months ago

Hi, this was also addressed in x_bows mod here https://bitbucket.org/minetest_gamers/x_bows/commits/ddf690bcd304ea7e6c672060a809a164984462db and should be working on the latest x_bows version

DustyBagel commented 11 months ago

Good to know that this has been fixed now.

Niklp09 commented 11 months ago

@JurajVajdaSakel This isn't a good fix since mods won't check if sub tables/variables exist. Why don't you just use local variables?

JurajVajdaSakel commented 11 months ago

got ya, addressed here https://bitbucket.org/minetest_gamers/x_bows/commits/bb5815f4df6ea2cc2885a2202a02191cdb167c5c

the whole thing there is only for setting types for lua diagnostics and its not really needed for the functionality of the code, so will get rid of it