Add inital dripstone design
|
@ -0,0 +1,616 @@
|
|||
noordstar_dripstone = {
|
||||
water_nodes =
|
||||
{ "default:river_water_source"
|
||||
, "default:water_source"
|
||||
, "mcl_core:water_source"
|
||||
, "mclx_core:river_water_source"
|
||||
}
|
||||
, lava_nodes =
|
||||
{ "default:lava_source"
|
||||
, "mcl_core:lava_source"
|
||||
}
|
||||
}
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
|
||||
local function load(module_name)
|
||||
return dofile(modpath .. "/lua/" .. module_name .. ".lua")
|
||||
end
|
||||
local function schem(module_name)
|
||||
return dofile(modpath .. "/schematics/" .. module_name .. ".lua")
|
||||
end
|
||||
|
||||
-- Create a node box for any given dripstone size.
|
||||
-- Size 8 is a normal block size
|
||||
local function nodebox_of_size(size)
|
||||
return {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ - size / 16, -0.5, - size / 16, size / 16, 0.5, size / 16 },
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
-- Constants
|
||||
local speed_factor = 180
|
||||
local seconds_per_growth = 10 * speed_factor
|
||||
local seconds_per_trickle = 1 * speed_factor
|
||||
local samples_per_interval = 100
|
||||
|
||||
-- Namespaced node names
|
||||
local dry_dripstone_block = "noordstar_dripstone:dripstone_block"
|
||||
local dry_dripstone_huge = "noordstar_dripstone:huge_dripstone"
|
||||
local dry_dripstone_large = "noordstar_dripstone:large_dripstone"
|
||||
local dry_dripstone_great = "noordstar_dripstone:great_dripstone"
|
||||
local dry_dripstone_medium = "noordstar_dripstone:medium_dripstone"
|
||||
local dry_dripstone_small = "noordstar_dripstone:small_dripstone"
|
||||
local dry_dripstone_tiny = "noordstar_dripstone:tiny_dripstone"
|
||||
local dry_dripstone_spike = "noordstar_dripstone:dripstone_spike"
|
||||
local hardened_dripstone_block = "noordstar_dripstone:hardened_dripstone_block"
|
||||
local hardened_dripstone_huge = "noordstar_dripstone:huge_hardened_dripstone"
|
||||
local hardened_dripstone_large = "noordstar_dripstone:large_hardened_dripstone"
|
||||
local hardened_dripstone_great = "noordstar_dripstone:great_hardened_dripstone"
|
||||
local hardened_dripstone_medium = "noordstar_dripstone:medium_hardened_dripstone"
|
||||
local hardened_dripstone_small = "noordstar_dripstone:small_hardened_dripstone"
|
||||
local hardened_dripstone_tiny = "noordstar_dripstone:tiny_hardened_dripstone"
|
||||
local hardened_dripstone_spike = "noordstar_dripstone:hardened_dripstone_spike"
|
||||
local molten_dripstone_block = "noordstar_dripstone:molten_dripstone_block"
|
||||
local molten_dripstone_huge = "noordstar_dripstone:huge_molten_dripstone"
|
||||
local molten_dripstone_large = "noordstar_dripstone:large_molten_dripstone"
|
||||
local molten_dripstone_great = "noordstar_dripstone:great_molten_dripstone"
|
||||
local molten_dripstone_medium = "noordstar_dripstone:medium_molten_dripstone"
|
||||
local molten_dripstone_small = "noordstar_dripstone:small_molten_dripstone"
|
||||
local molten_dripstone_tiny = "noordstar_dripstone:tiny_molten_dripstone"
|
||||
local molten_dripstone_spike = "noordstar_dripstone:molten_dripstone_spike"
|
||||
local watered_dripstone_block = "noordstar_dripstone:watered_dripstone_block"
|
||||
local watered_dripstone_huge = "noordstar_dripstone:huge_watered_dripstone"
|
||||
local watered_dripstone_large = "noordstar_dripstone:large_watered_dripstone"
|
||||
local watered_dripstone_great = "noordstar_dripstone:great_watered_dripstone"
|
||||
local watered_dripstone_medium = "noordstar_dripstone:medium_watered_dripstone"
|
||||
local watered_dripstone_small = "noordstar_dripstone:small_watered_dripstone"
|
||||
local watered_dripstone_tiny = "noordstar_dripstone:tiny_watered_dripstone"
|
||||
local watered_dripstone_spike = "noordstar_dripstone:watered_dripstone_spike"
|
||||
|
||||
-- Trickle down config
|
||||
|
||||
local lava_trickle_down = {
|
||||
{ from = dry_dripstone_block, to = molten_dripstone_block },
|
||||
{ from = dry_dripstone_huge, to = molten_dripstone_huge },
|
||||
{ from = dry_dripstone_large, to = molten_dripstone_large },
|
||||
{ from = dry_dripstone_great, to = molten_dripstone_great },
|
||||
{ from = dry_dripstone_medium, to = molten_dripstone_medium },
|
||||
{ from = dry_dripstone_small, to = molten_dripstone_small },
|
||||
{ from = dry_dripstone_tiny, to = molten_dripstone_tiny },
|
||||
{ from = dry_dripstone_spike, to = molten_dripstone_spike },
|
||||
{ from = watered_dripstone_block, to = hardened_dripstone_block },
|
||||
{ from = watered_dripstone_huge, to = hardened_dripstone_huge },
|
||||
{ from = watered_dripstone_large, to = hardened_dripstone_large },
|
||||
{ from = watered_dripstone_great, to = hardened_dripstone_great },
|
||||
{ from = watered_dripstone_medium, to = hardened_dripstone_medium },
|
||||
{ from = watered_dripstone_small, to = hardened_dripstone_small },
|
||||
{ from = watered_dripstone_tiny, to = hardened_dripstone_tiny },
|
||||
{ from = watered_dripstone_spike, to = hardened_dripstone_spike },
|
||||
{ from = "air", to = dry_dripstone_spike },
|
||||
}
|
||||
local water_trickle_down = {
|
||||
{ from = dry_dripstone_block, to = watered_dripstone_block },
|
||||
{ from = dry_dripstone_huge, to = watered_dripstone_huge },
|
||||
{ from = dry_dripstone_large, to = watered_dripstone_large },
|
||||
{ from = dry_dripstone_great, to = watered_dripstone_great },
|
||||
{ from = dry_dripstone_medium, to = watered_dripstone_medium },
|
||||
{ from = dry_dripstone_small, to = watered_dripstone_small },
|
||||
{ from = dry_dripstone_tiny, to = watered_dripstone_tiny },
|
||||
{ from = dry_dripstone_spike, to = watered_dripstone_spike },
|
||||
{ from = molten_dripstone_block, to = hardened_dripstone_block },
|
||||
{ from = molten_dripstone_huge, to = hardened_dripstone_huge },
|
||||
{ from = molten_dripstone_large, to = hardened_dripstone_large },
|
||||
{ from = molten_dripstone_great, to = hardened_dripstone_great },
|
||||
{ from = molten_dripstone_medium, to = hardened_dripstone_medium },
|
||||
{ from = molten_dripstone_small, to = hardened_dripstone_small },
|
||||
{ from = molten_dripstone_tiny, to = hardened_dripstone_tiny },
|
||||
{ from = molten_dripstone_spike, to = hardened_dripstone_spike },
|
||||
{ from = "air", to = dry_dripstone_spike },
|
||||
}
|
||||
|
||||
local lava_trickle_down_spike = {
|
||||
{ from = dry_dripstone_block, to = molten_dripstone_block },
|
||||
{ from = dry_dripstone_huge, to = molten_dripstone_huge },
|
||||
{ from = dry_dripstone_large, to = molten_dripstone_large },
|
||||
{ from = dry_dripstone_great, to = molten_dripstone_great },
|
||||
{ from = dry_dripstone_medium, to = molten_dripstone_medium },
|
||||
{ from = dry_dripstone_small, to = molten_dripstone_small },
|
||||
{ from = dry_dripstone_tiny, to = molten_dripstone_tiny },
|
||||
{ from = dry_dripstone_spike, to = molten_dripstone_spike },
|
||||
{ from = watered_dripstone_block, to = hardened_dripstone_block },
|
||||
{ from = watered_dripstone_huge, to = hardened_dripstone_huge },
|
||||
{ from = watered_dripstone_large, to = hardened_dripstone_large },
|
||||
{ from = watered_dripstone_great, to = hardened_dripstone_great },
|
||||
{ from = watered_dripstone_medium, to = hardened_dripstone_medium },
|
||||
{ from = watered_dripstone_small, to = hardened_dripstone_small },
|
||||
{ from = watered_dripstone_tiny, to = hardened_dripstone_tiny },
|
||||
{ from = watered_dripstone_spike, to = hardened_dripstone_spike },
|
||||
}
|
||||
local water_trickle_down_spike = {
|
||||
{ from = dry_dripstone_block, to = watered_dripstone_block },
|
||||
{ from = dry_dripstone_huge, to = watered_dripstone_huge },
|
||||
{ from = dry_dripstone_large, to = watered_dripstone_large },
|
||||
{ from = dry_dripstone_great, to = watered_dripstone_great },
|
||||
{ from = dry_dripstone_medium, to = watered_dripstone_medium },
|
||||
{ from = dry_dripstone_small, to = watered_dripstone_small },
|
||||
{ from = dry_dripstone_tiny, to = watered_dripstone_tiny },
|
||||
{ from = dry_dripstone_spike, to = watered_dripstone_spike },
|
||||
{ from = molten_dripstone_block, to = hardened_dripstone_block },
|
||||
{ from = molten_dripstone_huge, to = hardened_dripstone_huge },
|
||||
{ from = molten_dripstone_large, to = hardened_dripstone_large },
|
||||
{ from = molten_dripstone_great, to = hardened_dripstone_great },
|
||||
{ from = molten_dripstone_medium, to = hardened_dripstone_medium },
|
||||
{ from = molten_dripstone_small, to = hardened_dripstone_small },
|
||||
{ from = molten_dripstone_tiny, to = hardened_dripstone_tiny },
|
||||
{ from = molten_dripstone_spike, to = hardened_dripstone_spike },
|
||||
}
|
||||
|
||||
local lava_drop_down = {
|
||||
{ from = dry_dripstone_spike, to = molten_dripstone_spike },
|
||||
{ from = "mcl_cauldrons:cauldron", to = "mcl_cauldrons:cauldron_1_lava" },
|
||||
{ from = "mcl_cauldrons:cauldron_1_lava", to = "mcl_cauldrons:cauldron_2_lava" },
|
||||
{ from = "mcl_cauldrons:cauldron_2_lava", to = "mcl_cauldrons:cauldron_3_lava" },
|
||||
}
|
||||
local water_drop_down = {
|
||||
{ from = dry_dripstone_spike, to = watered_dripstone_spike },
|
||||
{ from = "mcl_cauldrons:cauldron", to = "mcl_cauldrons:cauldron_1" },
|
||||
{ from = "mcl_cauldrons:cauldron_1", to = "mcl_cauldrons:cauldron_2" },
|
||||
{ from = "mcl_cauldrons:cauldron_2", to = "mcl_cauldrons:cauldron_3" },
|
||||
}
|
||||
|
||||
-- Tiles for dripstone
|
||||
local dry_dripstone_tiles =
|
||||
{ "noordstar_dripstone_dripstone_top.png"
|
||||
, "noordstar_dripstone_dripstone_top.png"
|
||||
, "noordstar_dripstone_dripstone_side.png"
|
||||
}
|
||||
local hardened_dripstone_tiles =
|
||||
{ "noordstar_dripstone_hardened_dripstone_top.png"
|
||||
, "noordstar_dripstone_hardened_dripstone_top.png"
|
||||
, "noordstar_dripstone_hardened_dripstone_side.png"
|
||||
}
|
||||
local molten_dripstone_tiles =
|
||||
{ "noordstar_dripstone_molten_dripstone_top.png"
|
||||
, "noordstar_dripstone_molten_dripstone_top.png"
|
||||
, "noordstar_dripstone_molten_dripstone_side.png"
|
||||
}
|
||||
local watered_dripstone_tiles =
|
||||
{ "noordstar_dripstone_watered_dripstone_top.png"
|
||||
, "noordstar_dripstone_watered_dripstone_top.png"
|
||||
, "noordstar_dripstone_watered_dripstone_side.png"
|
||||
}
|
||||
|
||||
-- BASE BLOCKS
|
||||
-- These blocks are able to absorb water or lava from above them.
|
||||
|
||||
minetest.register_node(dry_dripstone_block,
|
||||
{ description = "Dripstone block"
|
||||
, _doc_items_longdesc = "Dripstone block that can suck up liquids above it and creates stalactites below it."
|
||||
, tiles = dry_dripstone_tiles
|
||||
, drawtype = "normal"
|
||||
}
|
||||
)
|
||||
minetest.register_node(hardened_dripstone_block,
|
||||
{ description = "Hardened dripstone block"
|
||||
, _doc_items_longdesc = "Dripstone block that is no longer able to absorb liquids above it."
|
||||
, tiles = hardened_dripstone_tiles
|
||||
, drawtype = "normal"
|
||||
}
|
||||
)
|
||||
minetest.register_node(molten_dripstone_block,
|
||||
{ description = "Molten dripstone block"
|
||||
, _doc_items_longdesc = "A dripstone block that has absorbed some lava, allowing it to form a stalactite."
|
||||
, tiles = molten_dripstone_tiles
|
||||
, drawtype = "normal"
|
||||
}
|
||||
)
|
||||
minetest.register_node(watered_dripstone_block,
|
||||
{ description = "Watered dripstone block"
|
||||
, _doc_items_longdesc = "A dripstone block that has absorbed some water, allowing it to form a stalactite."
|
||||
, tiles = watered_dripstone_tiles
|
||||
, drawtype = "normal"
|
||||
}
|
||||
)
|
||||
|
||||
local function make_dripstone(name, desc, longdesc, tiles, size)
|
||||
minetest.register_node(name,
|
||||
{ description = desc
|
||||
, _doc_items_longdesc = longdesc
|
||||
, tiles = tiles
|
||||
, drawtype = "nodebox"
|
||||
, paramtype = "light"
|
||||
, sunlight_propagates = true
|
||||
, node_box = nodebox_of_size(size)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
-- HUGE DRIPSTONE
|
||||
-- This is the largest form a non-block can get.
|
||||
|
||||
make_dripstone(
|
||||
dry_dripstone_huge,
|
||||
"Huge dripstone",
|
||||
"Dripstone in the largest shape it can reach.",
|
||||
dry_dripstone_tiles,
|
||||
7
|
||||
)
|
||||
make_dripstone(
|
||||
hardened_dripstone_huge,
|
||||
"Huge hardened dripstone",
|
||||
"Dripstone in the largest shape it can reach. It is no longer able to grow or absorb liquids.",
|
||||
hardened_dripstone_tiles,
|
||||
7
|
||||
)
|
||||
make_dripstone(
|
||||
molten_dripstone_huge,
|
||||
"Huge molten dripstone",
|
||||
"Dripstone in the largest shape it can reach. It has absorbed some lava, but it can no longer grow in thickness.",
|
||||
molten_dripstone_tiles,
|
||||
7
|
||||
)
|
||||
make_dripstone(
|
||||
watered_dripstone_huge,
|
||||
"Huge watered dripstone",
|
||||
"Dripstone in the largest shape it can reach. It has absorbed some water, but it can no longer grow in thickness.",
|
||||
watered_dripstone_tiles,
|
||||
7
|
||||
)
|
||||
|
||||
-- LARGE DRIPSTONE
|
||||
|
||||
make_dripstone(
|
||||
dry_dripstone_large,
|
||||
"Large dripstone",
|
||||
"A thick layer of dripstone.",
|
||||
dry_dripstone_tiles,
|
||||
6
|
||||
)
|
||||
make_dripstone(
|
||||
hardened_dripstone_large,
|
||||
"Large hardened dripstone",
|
||||
"A thick layer of dripstone. It is no longer able to grow or absorb liquids.",
|
||||
hardened_dripstone_tiles,
|
||||
6
|
||||
)
|
||||
make_dripstone(
|
||||
molten_dripstone_large,
|
||||
"Large molten dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some lava, so it is able to grow in thickness.",
|
||||
molten_dripstone_tiles,
|
||||
6
|
||||
)
|
||||
make_dripstone(
|
||||
watered_dripstone_large,
|
||||
"Large watered dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some water, so it is able to grow in thickness.",
|
||||
watered_dripstone_tiles,
|
||||
6
|
||||
)
|
||||
|
||||
-- GREAT DRIPSTONE
|
||||
|
||||
make_dripstone(
|
||||
dry_dripstone_great,
|
||||
"Great dripstone",
|
||||
"A thick layer of dripstone.",
|
||||
dry_dripstone_tiles,
|
||||
5
|
||||
)
|
||||
make_dripstone(
|
||||
hardened_dripstone_great,
|
||||
"Great hardened dripstone",
|
||||
"A thick layer of dripstone. It is no longer able to grow or absorb liquids.",
|
||||
hardened_dripstone_tiles,
|
||||
5
|
||||
)
|
||||
make_dripstone(
|
||||
molten_dripstone_great,
|
||||
"Great molten dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some lava, so it is able to grow in thickness.",
|
||||
molten_dripstone_tiles,
|
||||
5
|
||||
)
|
||||
make_dripstone(
|
||||
watered_dripstone_great,
|
||||
"Great watered dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some water, so it is able to grow in thickness.",
|
||||
watered_dripstone_tiles,
|
||||
5
|
||||
)
|
||||
|
||||
-- MEDIUM DRIPSTONE
|
||||
|
||||
make_dripstone(
|
||||
dry_dripstone_medium,
|
||||
"Medium dripstone",
|
||||
"A thick layer of dripstone.",
|
||||
dry_dripstone_tiles,
|
||||
4
|
||||
)
|
||||
make_dripstone(
|
||||
hardened_dripstone_medium,
|
||||
"Medium hardened dripstone",
|
||||
"A thick layer of dripstone. It is no longer able to grow or absorb liquids.",
|
||||
hardened_dripstone_tiles,
|
||||
4
|
||||
)
|
||||
make_dripstone(
|
||||
molten_dripstone_medium,
|
||||
"Medium molten dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some lava, so it is able to grow in thickness.",
|
||||
molten_dripstone_tiles,
|
||||
4
|
||||
)
|
||||
make_dripstone(
|
||||
watered_dripstone_medium,
|
||||
"Medium watered dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some water, so it is able to grow in thickness.",
|
||||
watered_dripstone_tiles,
|
||||
4
|
||||
)
|
||||
|
||||
-- SMALL DRIPSTONE
|
||||
|
||||
make_dripstone(
|
||||
dry_dripstone_small,
|
||||
"Small dripstone",
|
||||
"A thick layer of dripstone.",
|
||||
dry_dripstone_tiles,
|
||||
3
|
||||
)
|
||||
make_dripstone(
|
||||
hardened_dripstone_small,
|
||||
"Small hardened dripstone",
|
||||
"A thick layer of dripstone. It is no longer able to grow or absorb liquids.",
|
||||
hardened_dripstone_tiles,
|
||||
3
|
||||
)
|
||||
make_dripstone(
|
||||
molten_dripstone_small,
|
||||
"Small molten dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some lava, so it is able to grow in thickness.",
|
||||
molten_dripstone_tiles,
|
||||
3
|
||||
)
|
||||
make_dripstone(
|
||||
watered_dripstone_small,
|
||||
"Small watered dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some water, so it is able to grow in thickness.",
|
||||
watered_dripstone_tiles,
|
||||
3
|
||||
)
|
||||
|
||||
-- TINY DRIPSTONE
|
||||
|
||||
make_dripstone(
|
||||
dry_dripstone_tiny,
|
||||
"Tiny dripstone",
|
||||
"A thick layer of dripstone.",
|
||||
dry_dripstone_tiles,
|
||||
2
|
||||
)
|
||||
make_dripstone(
|
||||
hardened_dripstone_tiny,
|
||||
"Tiny hardened dripstone",
|
||||
"A thick layer of dripstone. It is no longer able to grow or absorb liquids.",
|
||||
hardened_dripstone_tiles,
|
||||
2
|
||||
)
|
||||
make_dripstone(
|
||||
molten_dripstone_tiny,
|
||||
"Tiny molten dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some lava, so it is able to grow in thickness.",
|
||||
molten_dripstone_tiles,
|
||||
2
|
||||
)
|
||||
make_dripstone(
|
||||
watered_dripstone_tiny,
|
||||
"Tiny watered dripstone",
|
||||
"A thick layer of dripstone. It has absorbed some water, so it is able to grow in thickness.",
|
||||
watered_dripstone_tiles,
|
||||
2
|
||||
)
|
||||
|
||||
-- DRIPSTONE SPIKE
|
||||
|
||||
make_dripstone(
|
||||
dry_dripstone_spike,
|
||||
"Dripstone spike",
|
||||
"A thick layer of dripstone.",
|
||||
dry_dripstone_tiles,
|
||||
1
|
||||
)
|
||||
make_dripstone(
|
||||
hardened_dripstone_spike,
|
||||
"Hardened dripstone spike",
|
||||
"A thick layer of dripstone. It is no longer able to grow or absorb liquids.",
|
||||
hardened_dripstone_tiles,
|
||||
1
|
||||
)
|
||||
make_dripstone(
|
||||
molten_dripstone_spike,
|
||||
"Molten dripstone spike",
|
||||
"A thick layer of dripstone. It has absorbed some lava, so it is able to grow in thickness.",
|
||||
molten_dripstone_tiles,
|
||||
1
|
||||
)
|
||||
make_dripstone(
|
||||
watered_dripstone_spike,
|
||||
"Watered dripstone spike",
|
||||
"A thick layer of dripstone. It has absorbed some water, so it is able to grow in thickness.",
|
||||
watered_dripstone_tiles,
|
||||
1
|
||||
)
|
||||
|
||||
-- ACTIONS
|
||||
|
||||
local function absorb_liquid(pos, node, aoc, aocw)
|
||||
local node_above = minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }) or {}
|
||||
local na_name = node_above.name
|
||||
|
||||
for _, water in pairs(noordstar_dripstone.water_nodes) do
|
||||
if water == na_name then
|
||||
-- Make block watery
|
||||
node.name = watered_dripstone_block
|
||||
minetest.set_node(pos, node)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
for _, lava in pairs(noordstar_dripstone.lava_nodes) do
|
||||
if lava == na_name then
|
||||
-- Make block molten
|
||||
node.name = molten_dripstone_block
|
||||
minetest.set_node(pos, node)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function drop_down_to(options, dry_up_node_name)
|
||||
return function(pos, node, aoc, aocw)
|
||||
for i = 1, 25 do
|
||||
local pos_rel = { x = pos.x, y = pos.y - i, z = pos.z }
|
||||
local node_rel = minetest.get_node(pos_rel) or {}
|
||||
local node_name = node_rel.name or ""
|
||||
|
||||
if node_name == "air" then
|
||||
else
|
||||
-- Non-air node has been found!
|
||||
-- Check if it reacts to the dripstone and if it can be
|
||||
-- activated.
|
||||
for _, option in pairs(options) do
|
||||
if node_name == option.from then
|
||||
node_rel.name = option.to
|
||||
node.name = dry_up_node_name
|
||||
|
||||
minetest.set_node(pos, node)
|
||||
minetest.set_node(pos_rel, node_rel)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- The node cannot be changed and hence a new spike starts on top
|
||||
-- of it.
|
||||
if i > 1 then
|
||||
pos_rel = { x = pos.x, y = pos.y - i + 1, z = pos.z }
|
||||
minetest.set_node(pos_rel, { name = dry_dripstone_spike })
|
||||
|
||||
node.name = dry_up_node_name
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function grow_to(dry_grown_node_name)
|
||||
return function(pos, node, aoc, aocw)
|
||||
node.name = dry_grown_node_name
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
local function harden(harden_nodes_func)
|
||||
return function(pos, node, aoc, aocw)
|
||||
local node_above = minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }) or {}
|
||||
local na_name = node_above.name
|
||||
|
||||
for _, hardener in pairs(harden_nodes_func()) do
|
||||
if hardener == na_name then
|
||||
-- Harden dripstone block
|
||||
node.name = hardened_dripstone_block
|
||||
minetest.set_node(pos, node)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function trickle_down(options, dry_up_node_name)
|
||||
return function(pos, node, aoc, aocw)
|
||||
local pos_below = { x = pos.x, y = pos.y - 1, z = pos.z }
|
||||
local node_below = minetest.get_node(pos_below) or {}
|
||||
local nb_name = node_below.name or ""
|
||||
|
||||
for _, option in pairs(options) do
|
||||
local expected_node_name = option.from or nil
|
||||
local resulted_node_name = option.to
|
||||
|
||||
if nb_name == expected_node_name then
|
||||
node.name = dry_up_node_name
|
||||
node_below.name = resulted_node_name
|
||||
|
||||
minetest.set_node(pos, node)
|
||||
minetest.set_node(pos_below, node_below)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function make_abm(nodename, expected_duration, action)
|
||||
minetest.register_abm(
|
||||
{ nodenames = { nodename }
|
||||
, interval = expected_duration / samples_per_interval
|
||||
, chance = samples_per_interval
|
||||
, catch_up = true
|
||||
, action = action
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
-- ABSORB LIQUIDS
|
||||
|
||||
make_abm(dry_dripstone_block, seconds_per_trickle, absorb_liquid)
|
||||
make_abm(molten_dripstone_block, seconds_per_trickle, harden(function ()
|
||||
return noordstar_dripstone.water_nodes
|
||||
end))
|
||||
make_abm(watered_dripstone_block, seconds_per_trickle, harden(function ()
|
||||
return noordstar_dripstone.lava_nodes
|
||||
end))
|
||||
|
||||
-- TRICKLE DOWN
|
||||
|
||||
make_abm(molten_dripstone_block, seconds_per_trickle, trickle_down(lava_trickle_down, dry_dripstone_block))
|
||||
make_abm(watered_dripstone_block, seconds_per_trickle, trickle_down(water_trickle_down, dry_dripstone_block))
|
||||
make_abm(molten_dripstone_huge, seconds_per_trickle, trickle_down(lava_trickle_down, dry_dripstone_huge))
|
||||
make_abm(watered_dripstone_huge, seconds_per_trickle, trickle_down(water_trickle_down, dry_dripstone_huge))
|
||||
make_abm(molten_dripstone_large, seconds_per_trickle, trickle_down(lava_trickle_down, dry_dripstone_large))
|
||||
make_abm(watered_dripstone_large, seconds_per_trickle, trickle_down(water_trickle_down, dry_dripstone_large))
|
||||
make_abm(molten_dripstone_great, seconds_per_trickle, trickle_down(lava_trickle_down, dry_dripstone_great))
|
||||
make_abm(watered_dripstone_great, seconds_per_trickle, trickle_down(water_trickle_down, dry_dripstone_great))
|
||||
make_abm(molten_dripstone_medium, seconds_per_trickle, trickle_down(lava_trickle_down, dry_dripstone_medium))
|
||||
make_abm(watered_dripstone_medium, seconds_per_trickle, trickle_down(water_trickle_down, dry_dripstone_medium))
|
||||
make_abm(molten_dripstone_small, seconds_per_trickle, trickle_down(lava_trickle_down, dry_dripstone_small))
|
||||
make_abm(watered_dripstone_small, seconds_per_trickle, trickle_down(water_trickle_down, dry_dripstone_small))
|
||||
make_abm(molten_dripstone_tiny, seconds_per_trickle, trickle_down(lava_trickle_down, dry_dripstone_tiny))
|
||||
make_abm(watered_dripstone_tiny, seconds_per_trickle, trickle_down(water_trickle_down, dry_dripstone_tiny))
|
||||
make_abm(molten_dripstone_spike, seconds_per_trickle, trickle_down(lava_trickle_down_spike, dry_dripstone_spike))
|
||||
make_abm(watered_dripstone_spike, seconds_per_trickle, trickle_down(water_trickle_down_spike, dry_dripstone_spike))
|
||||
|
||||
-- GROW
|
||||
|
||||
make_abm(molten_dripstone_large, seconds_per_growth*(14*14 - 12*12), grow_to(dry_dripstone_huge))
|
||||
make_abm(watered_dripstone_large, seconds_per_growth*(14*14 - 12*12), grow_to(dry_dripstone_huge))
|
||||
make_abm(molten_dripstone_great, seconds_per_growth*(12*12 - 10*10), grow_to(dry_dripstone_large))
|
||||
make_abm(watered_dripstone_great, seconds_per_growth*(12*12 - 10*10), grow_to(dry_dripstone_large))
|
||||
make_abm(molten_dripstone_medium, seconds_per_growth*(10*10 - 8*8), grow_to(dry_dripstone_great))
|
||||
make_abm(watered_dripstone_medium, seconds_per_growth*(10*10 - 8*8), grow_to(dry_dripstone_great))
|
||||
make_abm(molten_dripstone_small, seconds_per_growth*(8*8 - 6*6), grow_to(dry_dripstone_medium))
|
||||
make_abm(watered_dripstone_small, seconds_per_growth*(8*8 - 6*6), grow_to(dry_dripstone_medium))
|
||||
make_abm(molten_dripstone_tiny, seconds_per_growth*(6*6 - 4*4), grow_to(dry_dripstone_small))
|
||||
make_abm(watered_dripstone_tiny, seconds_per_growth*(6*6 - 4*4), grow_to(dry_dripstone_small))
|
||||
make_abm(molten_dripstone_spike, seconds_per_growth*(4*4 - 2*2), grow_to(dry_dripstone_tiny))
|
||||
make_abm(watered_dripstone_spike, seconds_per_growth*(4*4 - 2*2), grow_to(dry_dripstone_tiny))
|
||||
|
||||
-- DROP DOWN
|
||||
|
||||
make_abm(molten_dripstone_spike, seconds_per_trickle, drop_down_to(lava_drop_down, dry_dripstone_spike))
|
||||
make_abm(watered_dripstone_spike, seconds_per_trickle, drop_down_to(water_drop_down, dry_dripstone_spike))
|
|
@ -0,0 +1,6 @@
|
|||
name=noordstar_dripstone
|
||||
description=Add stalactites and stalagmites to your game.
|
||||
author=Noordstar
|
||||
title=Noordstar Dripstone
|
||||
depends=
|
||||
optional_depends=default,mcl_cauldron,mcl_core
|
After Width: | Height: | Size: 176 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 175 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 178 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 177 B |
After Width: | Height: | Size: 543 B |
After Width: | Height: | Size: 51 KiB |