stujones11 / minetest-3d_armor

Visible player armor & wielded items for minetest
Other
56 stars 98 forks source link

Fix crash with UI but no technic #132

Closed numberZero closed 6 years ago

numberZero commented 6 years ago

https://github.com/minetest-mods/unified_inventory/issues/111 Should help.

stujones11 commented 6 years ago

Thanks for the PR but I don't understand what is wrong with the current code. minetest.global_exists shouldn't cause a crash unless something else is wrongly declaring the technic global?

However, I will merge since using a local variable based on the actual mod's existence is a better solution anyway :)

Edit: I'm just thinking, won't that local be out of scope there? Maybe not, Lua is kinda strange like that and I guess you did test this, right? I will do so myself when I get a chance, I'd like to understand this a little better.

numberZero commented 6 years ago

“Should help” means “Didn’t test, but will work probably.” I just found out that it uses different methods (global_exists in one place but get_modpath in another) of detecting technic in different places, and unified them. @expertmm Does this help actually?

On locals: each file (called via dofile) has its own scope. Indeed, it behaves just like a function, it can even return values (and probably handle arguments as well, don’t remember).

numberZero commented 6 years ago

Tested. It works. With technic_worldgen but no technic, c812e0a crashes but 579d245 works.

stujones11 commented 6 years ago

Thanks again, I never really doubted you :)