diff --git a/default.lua b/default.lua index fd64729..da7da20 100644 --- a/default.lua +++ b/default.lua @@ -102,28 +102,13 @@ if springs then vm:write_to_map() end) - minetest.register_abm({ - label = "dynamic_liquid damp clay spring", + dynamic_liquid.spring({ nodenames = {"dynamic_liquid:clay"}, - neighbors = {"air", "default:water_source", "default:water_flowing"}, - interval = 1, - chance = 1, - catch_up = false, - action = function(pos,node) - local check_node - local check_node_name - while pos.y < water_level do - pos.y = pos.y + 1 - check_node = get_node(pos) - check_node_name = check_node.name - if check_node_name == "air" or check_node_name == "default:water_flowing" then - set_node(pos, {name="default:water_source"}) - elseif check_node_name ~= "default:water_source" then - --Something's been put on top of this clay, don't send water through it - break - end - end - end + water_source = "default:water_source", + water_flowing = "default:water_flowing", + y_max = water_level, + y_min = -15, + pressure = 15, }) local spring_sounds = nil @@ -148,22 +133,13 @@ if springs then sounds = spring_sounds, }) - minetest.register_abm({ - label = "dynamic_liquid creative spring", + + dynamic_liquid.spring({ nodenames = {"dynamic_liquid:spring"}, - neighbors = {"air", "default:water_flowing"}, - interval = 1, - chance = 1, - catch_up = false, - action = function(pos,node) - pos.y = pos.y + 1 - local check_node = get_node(pos) - local check_node_name = check_node.name - if check_node_name == "air" or check_node_name == "default:water_flowing" then - set_node(pos, {name="default:water_source"}) - end - end - }) + water_source = "default:water_source", + water_flowing = "default:water_flowing", + pressure = 1, + }) end diff --git a/init.lua b/init.lua index e5ce0f0..d31d1d5 100644 --- a/init.lua +++ b/init.lua @@ -26,8 +26,13 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath.."/cooling_lava.lua") dofile(modpath.."/dynamic_liquids.lua") dofile(modpath.."/flow_through.lua") +dofile(modpath.."/springs.lua") dofile(modpath.."/mapgen_prefill.lua") if minetest.get_modpath("default") then dofile(modpath.."/default.lua") end + +if minetest.get_modpath("mcl_core") then + dofile(modpath.."/mineclone.lua") +end diff --git a/mineclone.lua b/mineclone.lua new file mode 100644 index 0000000..ac69c10 --- /dev/null +++ b/mineclone.lua @@ -0,0 +1,39 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +local water_probability = dynamic_liquid.config.water_probability +local river_water_probability = dynamic_liquid.config.river_water_probability +local lava_probability = dynamic_liquid.config.lava_probability +local water_level = dynamic_liquid.config.water_level +local springs = dynamic_liquid.config.springs + + +if dynamic_liquid.config.lava then + dynamic_liquid.liquid_abm("mcl_core:lava_source", "mcl_core:lava_flowing", lava_probability) +end + +if dynamic_liquid.config.water then + -- override water_source and water_flowing with liquid_renewable set to false + local override_def = {liquid_renewable = false} + minetest.override_item("mcl_core:water_source", override_def) + minetest.override_item("mcl_core:water_flowing", override_def) + + dynamic_liquid.liquid_abm("mcl_core:water_source", "mcl_core:water_flowing", water_probability) +end + +if dynamic_liquid.config.river_water then + dynamic_liquid.liquid_abm("mclx_core:river_water_source", "mclx_core:river_water_flowing", river_water_probability) +end + +if dynamic_liquid.config.springs then + --TODO: mapgen clay, this is a temporary measure for testing purposes + + dynamic_liquid.spring({ + nodenames = {"mcl_core:clay"}, + water_source = "mcl_core:water_source", + water_flowing = "mcl_core:water_flowing", + y_max = water_level, + y_min = -15, + pressure = 15, + }) + +end \ No newline at end of file diff --git a/mod.conf b/mod.conf index 99e915e..c0c1f26 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,3 @@ name = dynamic_liquid -optional_depends = default, doc, xpanes, carts +optional_depends = default, doc, xpanes, carts, mcl_core, mclx_core description = Flowing dynamic liquids and ocean-maintenance springs. \ No newline at end of file diff --git a/springs.lua b/springs.lua new file mode 100644 index 0000000..09420f8 --- /dev/null +++ b/springs.lua @@ -0,0 +1,39 @@ +dynamic_liquid.spring = function(def) + local water_source = def.water_source + local water_flowing = def.water_flowing + local pressure = def.pressure + local y_min = def.y_min or -31000 + local y_max = def.y_max or 31000 + local interval = def.interval or 1 + local chance = def.chance or 1 + + local get_node = minetest.get_node + local set_node = minetest.set_node + + minetest.register_abm({ + label = "dynamic_liquid spring " .. table.concat(def.nodenames, ", "), + nodenames = def.nodenames, + neighbors = {"air", def.water_source, def.water_flowing}, + interval = interval, + chance = chance, + catch_up = false, + action = function(pos,node) + local y = pos.y + local y_top = math.min(y+pressure, y_max) + if y < y_min or y >= y_max then return end + local check_node + local check_node_name + while pos.y < y_top do + pos.y = pos.y + 1 + check_node = get_node(pos) + check_node_name = check_node.name + if check_node_name == "air" or check_node_name == water_flowing then + set_node(pos, {name=water_source}) + elseif check_node_name ~= water_source then + --Something's been put on top of this clay, don't send water through it + break + end + end + end + }) +end \ No newline at end of file