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

wokste
Member
 
Posts: 78
Joined: Sat Feb 11, 2012 09:06

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

by wokste » Fri Mar 09, 2012 19:56

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(...)
}
We must be careful not to clone Notches mistakes.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Mar 09, 2012 20:02

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
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33

by sdzen » Fri Mar 09, 2012 20:11

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
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

celeron55
Member
 
Posts: 430
Joined: Tue Apr 19, 2011 10:10

by celeron55 » Sat Mar 10, 2012 09:35

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)
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sat Mar 10, 2012 13:09

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')
Last edited by sfan5 on Sat Mar 10, 2012 13:10, edited 1 time in total.
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

wokste
Member
 
Posts: 78
Joined: Sat Feb 11, 2012 09:06

by wokste » Sat Mar 10, 2012 14:44

Thanks a lot
We must be careful not to clone Notches mistakes.
 


Return to Minetest General

Who is online

Users browsing this forum: No registered users and 9 guests

cron