forked from Minetest/dynamic_liquid
ooh, at some point altitude checking was added to ABM definitions. Awesome.
parent
4a03dd1384
commit
103fd9a22a
|
@ -34,10 +34,8 @@ local set_node = minetest.swap_node
|
|||
-- Dynamic liquids
|
||||
-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local disable_flow_above = dynamic_liquid.config.disable_flow_above
|
||||
if disable_flow_above == nil or disable_flow_above >= 31000 then
|
||||
local disable_flow_above = dynamic_liquid.config.disable_flow_above or 32767
|
||||
|
||||
-- version without altitude check
|
||||
dynamic_liquid.liquid_abm = function(liquid, flowing_liquid, chance)
|
||||
minetest.register_abm({
|
||||
label = "dynamic_liquid " .. liquid .. " and " .. flowing_liquid,
|
||||
|
@ -45,6 +43,7 @@ if disable_flow_above == nil or disable_flow_above >= 31000 then
|
|||
neighbors = {flowing_liquid},
|
||||
interval = 1,
|
||||
chance = chance or 1,
|
||||
y_max = disable_flow_above,
|
||||
catch_up = false,
|
||||
action = function(pos,node) -- Do everything possible to optimize this method
|
||||
local check_pos = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||
|
@ -77,53 +76,6 @@ if disable_flow_above == nil or disable_flow_above >= 31000 then
|
|||
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
|
||||
|
||||
if dynamic_liquid.config.displace_liquid then
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@ 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.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
|
||||
|
|
|
@ -2,8 +2,8 @@ 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 y_min = def.y_min or -32768
|
||||
local y_max = def.y_max or 32767
|
||||
local interval = def.interval or 1
|
||||
local chance = def.chance or 1
|
||||
|
||||
|
@ -16,6 +16,8 @@ dynamic_liquid.spring = function(def)
|
|||
neighbors = {"air", def.water_source, def.water_flowing},
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
min_y = y_min,
|
||||
max_y = y_max-1,
|
||||
catch_up = false,
|
||||
action = function(pos,node)
|
||||
local y = pos.y
|
||||
|
|
Loading…
Reference in New Issue