Page 1 of 1

Lua, how do you check if a mod is installed.

PostPosted: Fri Mar 09, 2012 19:56
by wokste
I would like to add items made of materials from other mods (e.g. bronze and obsidian), but I do not want to add additional dependencies.

Is there an easy way to find out if a mod is loaded?
I am looking for something like:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
if (mod_loaded("obsidian")){
  minetest.register_craft(...)
}

PostPosted: Fri Mar 09, 2012 20:02
by sfan5
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function mod_loaded(str)
  if minetest.get_modpath(str) ~= nil
    return true
  else
    return false
  end
end

That should work :D

PostPosted: Fri Mar 09, 2012 20:11
by sdzen
or you could just not add a dependency that works for me on occasion its just if its trying to call a value on me the exists on the needed mod but that shouldnt be the case ie my bluilding blocks mod only needs default but theirs a bonus towel that uses the flowers mod :P

PostPosted: Sat Mar 10, 2012 09:35
by celeron55
sfan5's answer is correct, but there is currently no way to tell Minetest which mods, if exist, should be loaded before your mod. Other than strictly depending on them, that is.

Patch welcome. (for example "?modname" in depends.txt)

PostPosted: Sat Mar 10, 2012 13:09
by sfan5
celeron55 wrote:sfan5's answer is correct, but there is currently no way to tell Minetest which mods, if exist, should be loaded before your mod. Other than strictly depending on them, that is.

Patch welcome. (for example "?modname" in depends.txt)

Someone should make minetest.load_mod('bla')

PostPosted: Sat Mar 10, 2012 14:44
by wokste
Thanks a lot