#1 Issues with check if mod exists

Закрыто
3 лет назад открыта bell07 · комментариев: 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
Войдите, чтобы присоединиться к обсуждению.
Нет меток
Нет этапа
Нет ответственного
2 участников
Загрузка...
Отмена
Сохранить
Пока нет содержимого.