From 4ca70a7af1eaf5c8ecfc546758c660f90a334431 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 4 Sep 2021 01:05:19 +0200 Subject: [PATCH] speed up water flow (WIP) --- mods/ITEMS/mcl_core/nodes_liquid.lua | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index 0479c7f7..f12a8de4 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -108,6 +108,53 @@ S("• When water is directly below lava, the water turns into stone."), _mcl_hardness = -1, }) +function flow_water_downwards(pos, node, limit) + if limit == 0 then + return + end + if node.name ~= "air" then + minetest.debug("node not air") + return + end + minetest.debug(dump(node.name), dump(limit)) + minetest.set_node( + pos, + { + name="mcl_core:water_flowing", + param2 = 15, + } + ) + local below_pos = {x=pos.x, y=pos.y-1, z=pos.z} + local below_node = minetest.get_node(below_pos) + minetest.after( + 0, + function() + flow_water_downwards( + below_pos, + below_node, + limit - 1 + ) + end + ) +end + +minetest.register_abm({ + label="speed up water flow", + nodenames = {"mcl_core:water_flowing"}, + neighbors = {"air"}, + interval = 1, + chance = 1, + action = function(pos, node) + local below_pos = {x=pos.x, y=pos.y-1, z=pos.z} + local below_node = minetest.get_node(below_pos) + flow_water_downwards( + below_pos, + below_node, + 20 + ) + end, +}) + minetest.register_node("mcl_core:lava_flowing", { description = S("Flowing Lava"), _doc_items_create_entry = false,