1
0
Fork 0

split out spring code, start roughing in mineclone support

mineclone_compatibility
FaceDeer 2022-08-16 16:27:48 -06:00
parent b35240a53a
commit 4a03dd1384
5 changed files with 96 additions and 37 deletions

View File

@ -102,28 +102,13 @@ if springs then
vm:write_to_map() vm:write_to_map()
end) end)
minetest.register_abm({ dynamic_liquid.spring({
label = "dynamic_liquid damp clay spring",
nodenames = {"dynamic_liquid:clay"}, nodenames = {"dynamic_liquid:clay"},
neighbors = {"air", "default:water_source", "default:water_flowing"}, water_source = "default:water_source",
interval = 1, water_flowing = "default:water_flowing",
chance = 1, y_max = water_level,
catch_up = false, y_min = -15,
action = function(pos,node) pressure = 15,
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
}) })
local spring_sounds = nil local spring_sounds = nil
@ -148,22 +133,13 @@ if springs then
sounds = spring_sounds, sounds = spring_sounds,
}) })
minetest.register_abm({
label = "dynamic_liquid creative spring", dynamic_liquid.spring({
nodenames = {"dynamic_liquid:spring"}, nodenames = {"dynamic_liquid:spring"},
neighbors = {"air", "default:water_flowing"}, water_source = "default:water_source",
interval = 1, water_flowing = "default:water_flowing",
chance = 1, pressure = 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
})
end end

View File

@ -26,8 +26,13 @@ local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/cooling_lava.lua") dofile(modpath.."/cooling_lava.lua")
dofile(modpath.."/dynamic_liquids.lua") dofile(modpath.."/dynamic_liquids.lua")
dofile(modpath.."/flow_through.lua") dofile(modpath.."/flow_through.lua")
dofile(modpath.."/springs.lua")
dofile(modpath.."/mapgen_prefill.lua") dofile(modpath.."/mapgen_prefill.lua")
if minetest.get_modpath("default") then if minetest.get_modpath("default") then
dofile(modpath.."/default.lua") dofile(modpath.."/default.lua")
end end
if minetest.get_modpath("mcl_core") then
dofile(modpath.."/mineclone.lua")
end

39
mineclone.lua Normal file
View File

@ -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

View File

@ -1,3 +1,3 @@
name = dynamic_liquid 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. description = Flowing dynamic liquids and ocean-maintenance springs.

39
springs.lua Normal file
View File

@ -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