Page 1 of 1

How I make when i don't have mobs mod my own mod load a .lua

PostPosted: Sat Aug 06, 2016 20:27
by MineYoshi
I mean, if i don't have mobs mod, and i have the api in my mod, the api be loaded, if i have the mobs mod then don't...

How i make that?
I tried with this:
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( minetest.get_modpath("mobs") ~= nil ) then
dofile(minetest.get_modpath("extramobs").."/api.lua"),
end


But i think that don't going to work how i want.

Re: How I make when i don't have mobs mod my own mod load a

PostPosted: Sat Aug 06, 2016 20:51
by rubenwardy
That will run a file if the mod is enabled. Is that want you want? Why not just try it out. Also, so you don't need ~= nil

Re: How I make when i don't have mobs mod my own mod load a

PostPosted: Sat Aug 06, 2016 20:55
by MineYoshi
I mean i want that when i don't have a mod, mine run a file...
How i do that?

Re: How I make when i don't have mobs mod my own mod load a

PostPosted: Sat Aug 06, 2016 20:59
by rubenwardy
Simply negate the if statement's condition

if not minetest.get_modpath("mobs") then

Re: How I make when i don't have mobs mod my own mod load a

PostPosted: Sat Aug 06, 2016 21:09
by MineYoshi
I didn't think about that, i was thinking about the api.
But well, i think i need to study a lot more...
Thanks!