diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..5ee0795 --- /dev/null +++ b/config.lua @@ -0,0 +1,12 @@ + +oillamps.burn_resource = {"basic_materials:oil_extract","ethereal:palm_wax","basic_materials:paraffin"} +oillamps.bexist = false +oillamps.existing_ressource = {} + +-- check that at least one burning ressource exist +for _,resource in pairs(oillamps.burn_resource) do + oillamps.bexist = oillamps.bexist or (minetest.registered_items[resource] ~= nil) + if (minetest.registered_items[resource]) then + table.insert(oillamps.existing_ressource,resource) + end +end diff --git a/crafts.lua b/crafts.lua index b965255..9d638ab 100644 --- a/crafts.lua +++ b/crafts.lua @@ -14,14 +14,19 @@ minetest.register_craft({ cooktime = 3 }) -minetest.register_craft({ - output = "basic_materials:oil_extract 2", - recipe = {{"group:seed","group:seed"},{"group:seed","group:seed"}}, -}) +if minetest.registered_items["basic_materials:oil_extract"] then + minetest.register_craft({ + output = "basic_materials:oil_extract 2", + recipe = {{"group:seed","group:seed"},{"group:seed","group:seed"}}, + }) +end -- fill an empty oil lamp with oil extract -minetest.register_craft({ - recipe = {{"basic_materials:oil_extract"},{"oillamps:oillampempty"}}, - output = "oillamps:oillamp 1", -}) - +for _,resource in pairs(oillamps.existing_ressource) do + if minetest.registered_items[resource] then + minetest.register_craft({ + recipe = {{resource},{"oillamps:oillampempty"}}, + output = "oillamps:oillamp 1", + }) + end +end diff --git a/init.lua b/init.lua index 0118e3b..ac1fb93 100644 --- a/init.lua +++ b/init.lua @@ -7,9 +7,14 @@ modname = minetest.get_current_modname(), minetest.log("action", "[MOD]"..oillamps.modname.." -- start loading ") -dofile(oillamps.modpath .. "/nodes.lua") -dofile(oillamps.modpath .. "/craftitems.lua") -dofile(oillamps.modpath .. "/crafts.lua") +dofile(oillamps.modpath .. "/config.lua") +if(oillamps.bexist) then + dofile(oillamps.modpath .. "/nodes.lua") + dofile(oillamps.modpath .. "/craftitems.lua") + dofile(oillamps.modpath .. "/crafts.lua") +else + minetest.log("action", "[MOD]"..oillamps.modname.." -- no ressources found -> not defining oil lamps ") +end minetest.log("action", "[MOD]"..oillamps.modname.." -- end loading ") diff --git a/mod.conf b/mod.conf index dbef04f..ce1bc4d 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,4 @@ name = oillamps -depends = default,basic_materials +depends = default +optional_depends = basic_materials,ethereal description = Create oillamps with oil from leaves (basic_materials) or create oil with seeds.