#1 Issues with check if mod exists

Fermé
Créé il y a 3 ans par bell07 · 1 commentaires
bell07 a commenté il y a 3 ans

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 a commenté il y a 3 ans
Propriétaire

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
Connectez-vous pour rejoindre cette conversation.
Pas d'étiquette
Aucun jalon
Pas d'assignataire
2 Participants
Chargement…
Annuler
Enregistrer
Il n'existe pas encore de contenu.