forked from Minetest/dynamic_liquid
Add an option to keep floatlands from draining
parent
6dea6d343d
commit
1bcdefb766
116
init.lua
116
init.lua
|
@ -47,43 +47,97 @@ local set_node = minetest.set_node
|
||||||
-- Dynamic liquids
|
-- Dynamic liquids
|
||||||
-----------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
dynamic_liquid.liquid_abm = function(liquid, flowing_liquid, chance)
|
local disable_flow_above = tonumber(minetest.setting_get("dynamic_liquid_disable_flow_above"))
|
||||||
minetest.register_abm({
|
|
||||||
label = "dynamic_liquid " .. liquid .. " and " .. flowing_liquid,
|
if disable_flow_above == nil or disable_flow_above >= 31000 then
|
||||||
nodenames = {liquid},
|
|
||||||
neighbors = {flowing_liquid},
|
-- version without altitude check
|
||||||
interval = 1,
|
dynamic_liquid.liquid_abm = function(liquid, flowing_liquid, chance)
|
||||||
chance = chance or 1,
|
minetest.register_abm({
|
||||||
catch_up = false,
|
label = "dynamic_liquid " .. liquid .. " and " .. flowing_liquid,
|
||||||
action = function(pos,node) -- Do everything possible to optimize this method
|
nodenames = {liquid},
|
||||||
local check_pos = {x=pos.x, y=pos.y-1, z=pos.z}
|
neighbors = {flowing_liquid},
|
||||||
local check_node = get_node(check_pos)
|
interval = 1,
|
||||||
local check_node_name = check_node.name
|
chance = chance or 1,
|
||||||
if check_node_name == flowing_liquid or check_node_name == "air" then
|
catch_up = false,
|
||||||
set_node(pos, check_node)
|
action = function(pos,node) -- Do everything possible to optimize this method
|
||||||
set_node(check_pos, node)
|
local check_pos = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
return
|
local check_node = get_node(check_pos)
|
||||||
end
|
local check_node_name = check_node.name
|
||||||
local perm = all_direction_permutations[math.random(24)]
|
|
||||||
local dirs -- declare outside of loop so it won't keep entering/exiting scope
|
|
||||||
for i=1,4 do
|
|
||||||
dirs = perm[i]
|
|
||||||
-- reuse check_pos to avoid allocating a new table
|
|
||||||
check_pos.x = pos.x + dirs.x
|
|
||||||
check_pos.y = pos.y
|
|
||||||
check_pos.z = pos.z + dirs.z
|
|
||||||
check_node = get_node(check_pos)
|
|
||||||
check_node_name = check_node.name
|
|
||||||
if check_node_name == flowing_liquid or check_node_name == "air" then
|
if check_node_name == flowing_liquid or check_node_name == "air" then
|
||||||
set_node(pos, check_node)
|
set_node(pos, check_node)
|
||||||
set_node(check_pos, node)
|
set_node(check_pos, node)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local perm = all_direction_permutations[math.random(24)]
|
||||||
|
local dirs -- declare outside of loop so it won't keep entering/exiting scope
|
||||||
|
for i=1,4 do
|
||||||
|
dirs = perm[i]
|
||||||
|
-- reuse check_pos to avoid allocating a new table
|
||||||
|
check_pos.x = pos.x + dirs.x
|
||||||
|
check_pos.y = pos.y
|
||||||
|
check_pos.z = pos.z + dirs.z
|
||||||
|
check_node = get_node(check_pos)
|
||||||
|
check_node_name = check_node.name
|
||||||
|
if check_node_name == flowing_liquid or check_node_name == "air" then
|
||||||
|
set_node(pos, check_node)
|
||||||
|
set_node(check_pos, node)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
})
|
||||||
})
|
dynamic_liquid.registered_liquids[liquid] = flowing_liquid
|
||||||
dynamic_liquid.registered_liquids[liquid] = flowing_liquid
|
table.insert(dynamic_liquid.registered_liquid_neighbors, liquid)
|
||||||
table.insert(dynamic_liquid.registered_liquid_neighbors, liquid)
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- version with altitude check
|
||||||
|
dynamic_liquid.liquid_abm = function(liquid, flowing_liquid, chance)
|
||||||
|
minetest.register_abm({
|
||||||
|
label = "dynamic_liquid " .. liquid .. " and " .. flowing_liquid .. " with altitude check",
|
||||||
|
nodenames = {liquid},
|
||||||
|
neighbors = {flowing_liquid},
|
||||||
|
interval = 1,
|
||||||
|
chance = chance or 1,
|
||||||
|
catch_up = false,
|
||||||
|
action = function(pos,node) -- Do everything possible to optimize this method
|
||||||
|
-- This altitude check is the only difference from the version above.
|
||||||
|
-- If the altitude check is disabled we don't ever need to make the comparison,
|
||||||
|
-- hence the two different versions.
|
||||||
|
if pos.y > disable_flow_above then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local check_pos = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
|
local check_node = get_node(check_pos)
|
||||||
|
local check_node_name = check_node.name
|
||||||
|
if check_node_name == flowing_liquid or check_node_name == "air" then
|
||||||
|
set_node(pos, check_node)
|
||||||
|
set_node(check_pos, node)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local perm = all_direction_permutations[math.random(24)]
|
||||||
|
local dirs -- declare outside of loop so it won't keep entering/exiting scope
|
||||||
|
for i=1,4 do
|
||||||
|
dirs = perm[i]
|
||||||
|
-- reuse check_pos to avoid allocating a new table
|
||||||
|
check_pos.x = pos.x + dirs.x
|
||||||
|
check_pos.y = pos.y
|
||||||
|
check_pos.z = pos.z + dirs.z
|
||||||
|
check_node = get_node(check_pos)
|
||||||
|
check_node_name = check_node.name
|
||||||
|
if check_node_name == flowing_liquid or check_node_name == "air" then
|
||||||
|
set_node(pos, check_node)
|
||||||
|
set_node(check_pos, node)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
dynamic_liquid.registered_liquids[liquid] = flowing_liquid
|
||||||
|
table.insert(dynamic_liquid.registered_liquid_neighbors, liquid)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not minetest.get_modpath("default") then
|
if not minetest.get_modpath("default") then
|
||||||
|
|
|
@ -10,6 +10,11 @@ dynamic_liquid_river_water (Dynamic river water) bool false
|
||||||
#Causes lava blocks to move dynamically
|
#Causes lava blocks to move dynamically
|
||||||
dynamic_liquid_lava (Dynamic lava) bool true
|
dynamic_liquid_lava (Dynamic lava) bool true
|
||||||
|
|
||||||
|
#Floatlands are "leaky", so if you wish to prevent their lakes from draining
|
||||||
|
#set this value to somewhere below the elevation the floatlands are generated
|
||||||
|
#at.
|
||||||
|
dynamic_liquid_disable_flow_above (Disable flow above this altitude) int 31000
|
||||||
|
|
||||||
#Causes natural clay deposits to act as water sources, seeping new water blocks
|
#Causes natural clay deposits to act as water sources, seeping new water blocks
|
||||||
#into the space above them.
|
#into the space above them.
|
||||||
#Also adds a "spring" block to the creative inventory to serve as an infinite water
|
#Also adds a "spring" block to the creative inventory to serve as an infinite water
|
||||||
|
|
Loading…
Reference in New Issue