#1 Issues with check if mod exists

已关闭
bell073 年之前创建 · 1 条评论
bell07 评论于 3 年之前

See issues in the check for doors mod, you added in last commit.

At the first you have to add doors into optional dependencies of maple mod. Otherwise it can happends the maple is loaded before doors is loaded because of not defined loading order. Without the dependency it is not possible to register doors because the doors mod is not loaded at this point.

To check if a mod is enabled in game, minetest.get_modpath("modname") is usually used. This check is not nil even the mod is enabled but not loaded yet because of loading order. Useful for recipes, that does not deed the depending mod loaded.

The other way is to check if the global variable exists. If you like this way, please use if minetest.global_exists("doors") then instead of just if doors then. The short produces a developer warning about access to not existing global variable into log if doors not enabled. Of course the global exists only if the mod is previously loaded. So optional dependency is required for this check

See issues in the check for doors mod, you added in last commit. At the first you have to add doors into optional dependencies of maple mod. Otherwise it can happends the maple is loaded before doors is loaded because of not defined loading order. Without the dependency it is not possible to register doors because the doors mod is not loaded at this point. To check if a mod is enabled in game, `minetest.get_modpath("modname")` is usually used. This check is not nil even the mod is enabled but not loaded yet because of loading order. Useful for recipes, that does not deed the depending mod loaded. The other way is to check if the global variable exists. If you like this way, please use `if minetest.global_exists("doors") then` instead of just `if doors then`. The short produces a developer warning about access to not existing global variable into log if doors not enabled. Of course the global exists only if the mod is previously loaded. So optional dependency is required for this check
dacmot 评论于 3 年之前
所有者

Very good points. Thank you for the tips. I made corrections in 56ec0692c6

Very good points. Thank you for the tips. I made corrections in 56ec0692c67c2a3819c3a2c590e7d65016b4b807
dacmot3 年之前 关闭
登录 并参与到对话中。
未选择标签
未选择里程碑
未指派成员
2 名参与者
正在加载...
取消
保存
这个人很懒,什么都没留下。