diff --git a/mod.conf b/mod.conf index 6a2cfc9..b1313bf 100644 --- a/mod.conf +++ b/mod.conf @@ -1,6 +1,6 @@ name = tech_additions description = Adds some block and recipes. depends = default, techage -optional_depends = craft_ingredients +optional_depends = bbq, craft_ingredients, ethereal, farming min_minetest_version = 5.7 title = Tech additions \ No newline at end of file diff --git a/sieving.lua b/sieving.lua new file mode 100644 index 0000000..36c4c86 --- /dev/null +++ b/sieving.lua @@ -0,0 +1,223 @@ +local function mod_loaded(name) + return (minetest.get_modpath(name) ~= nil) +end + +local sieving_items = {} +sieving_items["default:dirt"] = { "default:sand", } +sieving_items["default:dirt_with_coniferous_litter"] = { "default:sand", } +sieving_items["default:dirt_with_dry_grass"] = { "default:sand", "default:dry_grass_1", } +sieving_items["default:dirt_with_grass"] = { "default:sand", "default:grass_1", } +sieving_items["default:dirt_with_rainforest_litter"] = { "default:sand", } +sieving_items["default:dirt_with_snow"] = { "default:sand", "default:snow" } +sieving_items["default:dry_dirt"] = { "default:deset_sand", } +sieving_items["default:dry_dirt_with_dry_grass"] = { "default:desert_sand", "default:dry_grass_1", } + + +if mod_loaded("farming") then + -- normal + table.insert(sieving_items["default:dirt"], "farming:seed_wheat") + table.insert(sieving_items["default:dirt"], "farming:seed_cotton") + + -- slightly dry and cold + table.insert(sieving_items["default:dirt_with_coniferous_litter"], "farming:seed_wheat") + + -- slightly dry + table.insert(sieving_items["default:dirt_with_dry_grass"], "farming:seed_cotton") + + -- slightly wet + table.insert(sieving_items["default:dirt_with_grass"], "farming:seed_wheat") + table.insert(sieving_items["default:dirt_with_grass"], "farming:seed_cotton") + + -- wet + table.insert(sieving_items["default:dirt_with_rainforest_litter"], "farming:seed_wheat") + + -- cold + table.insert(sieving_items["default:dirt_with_snow"], "farming:seed_wheat") + + -- dry + table.insert(sieving_items["default:dry_dirt"], "farming:seed_cotton") + + -- dry + table.insert(sieving_items["default:dry_dirt_with_dry_grass"], "farming:seed_cotton") + + if farming.mod and farming.mod == "redo" then + table.insert(sieving_items["default:dirt"], "farming:seed_rye") + table.insert(sieving_items["default:dirt"], "farming:seed_oat") + table.insert(sieving_items["default:dirt"], "farming:seed_barley") + table.insert(sieving_items["default:dirt"], "farming:seed_rice") + + table.insert(sieving_items["default:dirt_with_coniferous_litter"], "farming:seed_rye") + table.insert(sieving_items["default:dirt_with_coniferous_litter"], "farming:seed_oat") + + table.insert(sieving_items["default:dirt_with_dry_grass"], "farming:seed_rye") + table.insert(sieving_items["default:dirt_with_dry_grass"], "farming:seed_oat") + table.insert(sieving_items["default:dirt_with_dry_grass"], "farming:seed_barley") + + table.insert(sieving_items["default:dirt_with_grass"], "farming:seed_oat") + table.insert(sieving_items["default:dirt_with_grass"], "farming:seed_rice") + + table.insert(sieving_items["default:dirt_with_rainforest_litter"], "farming:seed_oat") + table.insert(sieving_items["default:dirt_with_rainforest_litter"], "farming:seed_rice") + + table.insert(sieving_items["default:dirt_with_snow"], "farming:seed_rye") + table.insert(sieving_items["default:dirt_with_snow"], "farming:seed_oat") + + table.insert(sieving_items["default:dry_dirt"], "farming:seed_oat") + table.insert(sieving_items["default:dry_dirt"], "farming:seed_barley") + + table.insert(sieving_items["default:dry_dirt_with_dry_grass"], "farming:seed_rye") + table.insert(sieving_items["default:dry_dirt_with_dry_grass"], "farming:seed_oat") + table.insert(sieving_items["default:dry_dirt_with_dry_grass"], "farming:seed_barley") + end +end + +if mod_loaded("ethereal") then + table.insert(sieving_items["default:dirt"], "ethereal:worm") + table.insert(sieving_items["default:dirt_with_coniferous_litter"], "ethereal:worm") + table.insert(sieving_items["default:dirt_with_grass"], "ethereal:worm") + table.insert(sieving_items["default:dirt_with_rainforest_litter"], "ethereal:worm") + + sieving_items["ethereal:bamboo_dirt"] = { + "default:sand", + "default:grass_1", + "ethereal:worm" + } + + sieving_items["ethereal:cold_dirt"] = { + "default:sand", + "default:grass_1" + } + + sieving_items["ethereal:crystal_dirt"] = { + "default:sand", + } + + sieving_items["ethereal:gray_dirt"] = { + "default:sand", + "ethereal:worm" + } + + sieving_items["ethereal:grove_dirt"] = { + "default:sand", + "default:grass_1", + "ethereal:worm" + } + + sieving_items["ethereal:jungle_dirt"] = { + "default:sand", + "ethereal:worm" + } + + sieving_items["ethereal:mushroom_dirt"] = { + "default:sand", + "ethereal:worm" + } + + sieving_items["ethereal:dry_dirt"] = { + "default:desert_sand", + } + + sieving_items["ethereal:fiery_dirt"] = { + "default:desert_sand", + } + + sieving_items["ethereal:prairie_dirt"] = { + "default:sand", + "default:grass_1", + "ethereal:worm" + } + + if mod_loaded("farming") then + table.insert(sieving_items["ethereal:bamboo_dirt"], "farming:seed_wheat") + table.insert(sieving_items["ethereal:bamboo_dirt"], "farming:seed_cotton") + + table.insert(sieving_items["ethereal:cold_dirt"], "farming:seed_wheat") + + table.insert(sieving_items["ethereal:gray_dirt"], "farming:seed_wheat") + table.insert(sieving_items["ethereal:gray_dirt"], "farming:seed_cotton") + + table.insert(sieving_items["ethereal:grove_dirt"], "farming:seed_wheat") + + table.insert(sieving_items["ethereal:jungle_dirt"], "farming:seed_wheat") + + table.insert(sieving_items["ethereal:dry_dirt"], "farming:seed_cotton") + + table.insert(sieving_items["ethereal:prairie_dirt"], "farming:seed_wheat") + table.insert(sieving_items["ethereal:prairie_dirt"], "farming:seed_cotton") + + if farming.mod and farming.mod == "redo" then + table.insert(sieving_items["ethereal:bamboo_dirt"], "farming:seed_rye") + table.insert(sieving_items["ethereal:bamboo_dirt"], "farming:seed_oat") + table.insert(sieving_items["ethereal:bamboo_dirt"], "farming:seed_rice") + + table.insert(sieving_items["ethereal:cold_dirt"], "farming:seed_rye") + table.insert(sieving_items["ethereal:cold_dirt"], "farming:seed_oat") + + table.insert(sieving_items["ethereal:crystal_dirt"], "farming:seed_rye") + table.insert(sieving_items["ethereal:crystal_dirt"], "farming:seed_oat") + + table.insert(sieving_items["ethereal:gray_dirt"], "farming:seed_rye") + table.insert(sieving_items["ethereal:gray_dirt"], "farming:seed_oat") + table.insert(sieving_items["ethereal:gray_dirt"], "farming:seed_barley") + table.insert(sieving_items["ethereal:gray_dirt"], "farming:seed_rice") + + table.insert(sieving_items["ethereal:grove_dirt"], "farming:seed_rye") + table.insert(sieving_items["ethereal:grove_dirt"], "farming:seed_oat") + table.insert(sieving_items["ethereal:grove_dirt"], "farming:seed_barley") + + table.insert(sieving_items["ethereal:jungle_dirt"], "farming:seed_oat") + table.insert(sieving_items["ethereal:jungle_dirt"], "farming:seed_barley") + table.insert(sieving_items["ethereal:jungle_dirt"], "farming:seed_rice") + + table.insert(sieving_items["ethereal:dry_dirt"], "farming:seed_oat") + table.insert(sieving_items["ethereal:dry_dirt"], "farming:seed_barley") + + table.insert(sieving_items["ethereal:prairie_dirt"], "farming:seed_rye") + table.insert(sieving_items["ethereal:prairie_dirt"], "farming:seed_oat") + table.insert(sieving_items["ethereal:prairie_dirt"], "farming:seed_barley") + table.insert(sieving_items["ethereal:prairie_dirt"], "farming:seed_rice") + end + end +end + +if mod_loaded("bbq") then + table.insert(sieving_items["default:dirt"], "bbq:yeast") + table.insert(sieving_items["default:dirt_with_coniferous_litter"], "bbq:yeast") + table.insert(sieving_items["default:dirt_with_grass"], "bbq:yeast") + table.insert(sieving_items["default:dirt_with_rainforest_litter"], "bbq:yeast") + + if mod_loaded("ethereal") then + table.insert(sieving_items["ethereal:bamboo_dirt"], "bbq:yeast") + table.insert(sieving_items["ethereal:gray_dirt"], "bbq:yeast") + table.insert(sieving_items["ethereal:grove_dirt"], "bbq:yeast") + table.insert(sieving_items["ethereal:jungle_dirt"], "bbq:yeast") + table.insert(sieving_items["ethereal:mushroom_dirt"], "bbq:yeast") + table.insert(sieving_items["ethereal:prairie_dirt"], "bbq:yeast") + end +end + +local sieving_items_count = {} +for dirt, items in pairs(sieving_items) do + sieving_items_count[dirt] = #items +end + +local function sieve(dirt) + local items = sieving_items[dirt] + if math.random(7) ~= 1 then + return ItemStack(items[1]) + else + return ItemStack( + items[ + math.random(sieving_items_count[dirt]) + ] + ) + end +end + +local function sieve_dirt(dirt) + return function() return sieve(dirt) end +end + +for dirt, _ in pairs(sieving_items) do + techage.register_sieving_recipe(dirt, sieve_dirt(dirt)) +end diff --git a/techage.lua b/techage.lua index 0854f78..070d92f 100644 --- a/techage.lua +++ b/techage.lua @@ -64,4 +64,7 @@ minetest.register_craft({ techage.add_grinder_recipe({input="multidecor:consolidated_oil", output="techage:plastic_granules"}) techage.add_grinder_recipe({input="ethereal:wild_onion_plant 10", output="dye:white"}) -techage.add_grinder_recipe({input="default:ice", output="default:snow 3"}) \ No newline at end of file +techage.add_grinder_recipe({input="default:ice", output="default:snow 3"}) + +--add extra sieving +dofile(minetest.get_modpath("tech_additions") .. "/sieving.lua")