1
0
Fork 0

Update + reformat based on VoxeLibre recommendations

main
Bram van den Heuvel 2024-09-02 02:53:54 +02:00
parent 2a8ff26dd7
commit 4746e121e6
1 changed files with 501 additions and 491 deletions

198
init.lua
View File

@ -1,7 +1,7 @@
noordstar_dripstone = {} noordstar_dripstone = {}
-- Constants -- Constants
local speed_factor = 30 local speed_factor = 60
local seconds_per_growth = 10 * speed_factor local seconds_per_growth = 10 * speed_factor
local seconds_per_water_trickle = 1 * speed_factor local seconds_per_water_trickle = 1 * speed_factor
local seconds_per_lava_trickle = 6 * speed_factor local seconds_per_lava_trickle = 6 * speed_factor
@ -43,33 +43,27 @@ local watered_dripstone_spike = "noordstar_dripstone:watered_dripstone_spike"
local internal = { local internal = {
-- Nodes that the mod should consider as sources to extract water from -- Nodes that the mod should consider as sources to extract water from
water_nodes = water_nodes = {
{ "default:river_water_source" "default:river_water_source",
, "default:water_source" "default:water_source",
, "mcl_core:water_source" "mcl_core:water_source",
, "mclx_core:river_water_source" "mclx_core:river_water_source",
}, },
-- Nodes that the mod should consider as sources to extract lava from -- Nodes that the mod should consider as sources to extract lava from
lava_nodes = lava_nodes = {
{ "default:lava_source" "default:lava_source",
, "mcl_core:lava_source" "mcl_core:lava_source",
}, },
-- Nodes that can catch a lava droplet instead of letting a spike grow on top -- Nodes that can catch a lava droplet instead of letting a spike grow on top
lava_cauldrons = { lava_cauldrons = {
{ from = dry_dripstone_spike, to = molten_dripstone_spike }, { 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" },
}, },
-- Nodes that can catch a water droplet instead of letting a spike grow on top -- Nodes that can catch a water droplet instead of letting a spike grow on top
water_cauldrons = { water_cauldrons = {
{ from = dry_dripstone_spike, to = watered_dripstone_spike }, { 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" },
} }
} }
@ -103,7 +97,7 @@ local function nodebox_of_size(size)
end end
end end
local function nodebox_type(size) local function drawtype_of_size(size)
if size >= 8 then if size >= 8 then
return "normal" return "normal"
else else
@ -112,8 +106,8 @@ local function nodebox_type(size)
end end
-- Sounds -- Sounds
local dripstone_sounds = nil local dripstone_sounds
if mcl_sounds then if minetest.get_modpath("mcl_sounds") then
dripstone_sounds = mcl_sounds.node_sound_stone_defaults() dripstone_sounds = mcl_sounds.node_sound_stone_defaults()
end end
@ -197,25 +191,25 @@ local water_trickle_down_spike = {
-- Tiles for dripstone -- Tiles for dripstone
local dry_dripstone_tiles = local dry_dripstone_tiles = {
{ "noordstar_dripstone_dripstone_top.png" "noordstar_dripstone_dripstone_top.png",
, "noordstar_dripstone_dripstone_top.png" "noordstar_dripstone_dripstone_top.png",
, "noordstar_dripstone_dripstone_side.png" "noordstar_dripstone_dripstone_side.png",
} }
local hardened_dripstone_tiles = local hardened_dripstone_tiles = {
{ "noordstar_dripstone_hardened_dripstone_top.png" "noordstar_dripstone_hardened_dripstone_top.png",
, "noordstar_dripstone_hardened_dripstone_top.png" "noordstar_dripstone_hardened_dripstone_top.png",
, "noordstar_dripstone_hardened_dripstone_side.png" "noordstar_dripstone_hardened_dripstone_side.png",
} }
local molten_dripstone_tiles = local molten_dripstone_tiles = {
{ "noordstar_dripstone_molten_dripstone_top.png" "noordstar_dripstone_molten_dripstone_top.png",
, "noordstar_dripstone_molten_dripstone_top.png" "noordstar_dripstone_molten_dripstone_top.png",
, "noordstar_dripstone_molten_dripstone_side.png" "noordstar_dripstone_molten_dripstone_side.png",
} }
local watered_dripstone_tiles = local watered_dripstone_tiles = {
{ "noordstar_dripstone_watered_dripstone_top.png" "noordstar_dripstone_watered_dripstone_top.png",
, "noordstar_dripstone_watered_dripstone_top.png" "noordstar_dripstone_watered_dripstone_top.png",
, "noordstar_dripstone_watered_dripstone_side.png" "noordstar_dripstone_watered_dripstone_side.png",
} }
-- Register dripstone nodes -- Register dripstone nodes
@ -226,13 +220,17 @@ local function make_dripstone(name, desc, longdesc, tiles, drop, size)
sunlight_propagates = true sunlight_propagates = true
end end
minetest.register_node(name, minetest.register_node(name, {
{ description = desc description = desc,
, _doc_items_longdesc = longdesc _doc_items_longdesc = longdesc,
, tiles = tiles tiles = tiles,
, groups = { pickaxey=2, material_stone=1, fall_damage_add_percent = math.max(4 - size, 0) / 4 * 100 } groups = {
, is_ground_content = true pickaxey=2,
, drop = { material_stone=1,
fall_damage_add_percent = math.max(4 - size, 0) / 4 * 100
},
is_ground_content = true,
drop = {
max_items = math.floor((size + 1) / 2), max_items = math.floor((size + 1) / 2),
items = { items = {
{ rarity = 1 { rarity = 1
@ -248,17 +246,16 @@ local function make_dripstone(name, desc, longdesc, tiles, drop, size)
, items = { drop } , items = { drop }
}, },
} }
} },
, sounds = dripstone_sounds sounds = dripstone_sounds,
, drawtype = nodebox_type(size) drawtype = drawtype_of_size(size),
, paramtype = "light" paramtype = "light",
, sunlight_propagates = sunlight_propagates sunlight_propagates = sunlight_propagates,
, node_box = nodebox_of_size(size) node_box = nodebox_of_size(size),
, _mcl_hardness = 1.0 + size / 8 _mcl_hardness = 1.0 + size / 8,
, _mcl_blast_resistance = 1 + size / 2 _mcl_blast_resistance = 1 + size / 2,
, _mcl_silk_touch_drop = true _mcl_silk_touch_drop = true,
} })
)
end end
-- BASE BLOCKS -- BASE BLOCKS
@ -546,10 +543,10 @@ make_dripstone(
-- ACTIONS -- ACTIONS
local function absorb_liquid(pos, node, aoc, aocw) 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 node_above = minetest.get_node(vector.offset(pos, 0, 1, 0)) or {}
local na_name = node_above.name local na_name = node_above.name
for _, water in pairs(noordstar_dripstone.water_nodes) do for _, water in pairs(internal.water_nodes) do
if water == na_name then if water == na_name then
-- Make block watery -- Make block watery
node.name = watered_dripstone_block node.name = watered_dripstone_block
@ -558,7 +555,7 @@ local function absorb_liquid(pos, node, aoc, aocw)
end end
end end
for _, lava in pairs(noordstar_dripstone.lava_nodes) do for _, lava in pairs(internal.lava_nodes) do
if lava == na_name then if lava == na_name then
-- Make block molten -- Make block molten
node.name = molten_dripstone_block node.name = molten_dripstone_block
@ -571,12 +568,11 @@ end
local function drop_down_to(options, dry_up_node_name) local function drop_down_to(options, dry_up_node_name)
return function(pos, node, aoc, aocw) return function(pos, node, aoc, aocw)
for i = 1, 25 do for i = 1, 25 do
local pos_rel = { x = pos.x, y = pos.y - i, z = pos.z } local pos_rel = vector.offset(pos, 0, -i, 0)
local node_rel = minetest.get_node(pos_rel) or {} local node_rel = minetest.get_node(pos_rel) or {}
local node_name = node_rel.name or "" local node_name = node_rel.name or ""
if node_name == "air" then if minetest.get_item_group(node_name, "air") ~= 0 then
else
-- Non-air node has been found! -- Non-air node has been found!
-- Check if it reacts to the dripstone and if it can be -- Check if it reacts to the dripstone and if it can be
-- activated. -- activated.
@ -594,7 +590,7 @@ local function drop_down_to(options, dry_up_node_name)
-- The node cannot be changed and hence a new spike starts on top -- The node cannot be changed and hence a new spike starts on top
-- of it. -- of it.
if i > 1 then if i > 1 then
pos_rel = { x = pos.x, y = pos.y - i + 1, z = pos.z } pos_rel = vector.offset(pos, 0, 1-i, 0)
minetest.set_node(pos_rel, { name = dry_dripstone_spike }) minetest.set_node(pos_rel, { name = dry_dripstone_spike })
node.name = dry_up_node_name node.name = dry_up_node_name
@ -615,7 +611,7 @@ end
local function harden(harden_nodes_func) local function harden(harden_nodes_func)
return function(pos, node, aoc, aocw) return function(pos, node, aoc, aocw)
local node_above = minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }) or {} local node_above = minetest.get_node(vector.offset(pos, 0, 1, 0)) or {}
local na_name = node_above.name local na_name = node_above.name
for _, hardener in pairs(harden_nodes_func()) do for _, hardener in pairs(harden_nodes_func()) do
@ -631,7 +627,7 @@ end
local function trickle_down(options, dry_up_node_name) local function trickle_down(options, dry_up_node_name)
return function(pos, node, aoc, aocw) return function(pos, node, aoc, aocw)
local pos_below = { x = pos.x, y = pos.y - 1, z = pos.z } local pos_below = vector.offset(pos, 0, -1, 0)
local node_below = minetest.get_node(pos_below) or {} local node_below = minetest.get_node(pos_below) or {}
local nb_name = node_below.name or "" local nb_name = node_below.name or ""
@ -666,10 +662,10 @@ end
make_abm(dry_dripstone_block, seconds_per_water_trickle, absorb_liquid) make_abm(dry_dripstone_block, seconds_per_water_trickle, absorb_liquid)
make_abm(molten_dripstone_block, seconds_per_lava_trickle, harden(function () make_abm(molten_dripstone_block, seconds_per_lava_trickle, harden(function ()
return noordstar_dripstone.water_nodes return internal.water_nodes
end)) end))
make_abm(watered_dripstone_block, seconds_per_water_trickle, harden(function () make_abm(watered_dripstone_block, seconds_per_water_trickle, harden(function ()
return noordstar_dripstone.lava_nodes return internal.lava_nodes
end)) end))
-- TRICKLE DOWN -- TRICKLE DOWN
@ -708,43 +704,57 @@ make_abm(watered_dripstone_spike, seconds_per_growth*(4*4 - 2*2), grow_to(dry_dr
-- DROP DOWN -- DROP DOWN
make_abm(molten_dripstone_spike, seconds_per_lava_trickle, drop_down_to(lava_drop_down, dry_dripstone_spike)) make_abm(molten_dripstone_spike, seconds_per_lava_trickle, drop_down_to(internal.lava_cauldrons, dry_dripstone_spike))
make_abm(watered_dripstone_spike, seconds_per_water_trickle, drop_down_to(water_drop_down, dry_dripstone_spike)) make_abm(watered_dripstone_spike, seconds_per_water_trickle, drop_down_to(internal.water_cauldrons, dry_dripstone_spike))
-- CRATING RECIPES -- CRATING RECIPES
local function gapple_recipe(gold, apple, gapple) local function make_recipe(border, middle, output)
minetest.register_craft({ minetest.register_craft({
output = gapple, output = output,
recipe = { recipe = {
{ gold, gold, gold }, { border, border, border },
{ gold, apple, gold }, { border, middle, border },
{ gold, gold, gold }, { border, border, border },
} }
}) })
end end
gapple_recipe(dry_dripstone_spike, dry_dripstone_spike, dry_dripstone_tiny) make_recipe(dry_dripstone_spike, dry_dripstone_spike, dry_dripstone_tiny)
gapple_recipe(dry_dripstone_spike, dry_dripstone_tiny, dry_dripstone_small) make_recipe(dry_dripstone_spike, dry_dripstone_tiny, dry_dripstone_small)
gapple_recipe(dry_dripstone_spike, dry_dripstone_small, dry_dripstone_medium) make_recipe(dry_dripstone_spike, dry_dripstone_small, dry_dripstone_medium)
gapple_recipe(dry_dripstone_spike, dry_dripstone_medium, dry_dripstone_great) make_recipe(dry_dripstone_spike, dry_dripstone_medium, dry_dripstone_great)
gapple_recipe(dry_dripstone_spike, dry_dripstone_great, dry_dripstone_large) make_recipe(dry_dripstone_spike, dry_dripstone_great, dry_dripstone_large)
gapple_recipe(dry_dripstone_spike, dry_dripstone_large, dry_dripstone_huge) make_recipe(dry_dripstone_spike, dry_dripstone_large, dry_dripstone_huge)
gapple_recipe(hardened_dripstone_spike, hardened_dripstone_spike, hardened_dripstone_tiny) make_recipe(hardened_dripstone_spike, hardened_dripstone_spike, hardened_dripstone_tiny)
gapple_recipe(hardened_dripstone_spike, hardened_dripstone_tiny, hardened_dripstone_small) make_recipe(hardened_dripstone_spike, hardened_dripstone_tiny, hardened_dripstone_small)
gapple_recipe(hardened_dripstone_spike, hardened_dripstone_small, hardened_dripstone_medium) make_recipe(hardened_dripstone_spike, hardened_dripstone_small, hardened_dripstone_medium)
gapple_recipe(hardened_dripstone_spike, hardened_dripstone_medium, hardened_dripstone_great) make_recipe(hardened_dripstone_spike, hardened_dripstone_medium, hardened_dripstone_great)
gapple_recipe(hardened_dripstone_spike, hardened_dripstone_great, hardened_dripstone_large) make_recipe(hardened_dripstone_spike, hardened_dripstone_great, hardened_dripstone_large)
gapple_recipe(hardened_dripstone_spike, hardened_dripstone_large, hardened_dripstone_huge) make_recipe(hardened_dripstone_spike, hardened_dripstone_large, hardened_dripstone_huge)
gapple_recipe(molten_dripstone_spike, molten_dripstone_spike, molten_dripstone_tiny) make_recipe(molten_dripstone_spike, molten_dripstone_spike, molten_dripstone_tiny)
gapple_recipe(molten_dripstone_spike, molten_dripstone_tiny, molten_dripstone_small) make_recipe(molten_dripstone_spike, molten_dripstone_tiny, molten_dripstone_small)
gapple_recipe(molten_dripstone_spike, molten_dripstone_small, molten_dripstone_medium) make_recipe(molten_dripstone_spike, molten_dripstone_small, molten_dripstone_medium)
gapple_recipe(molten_dripstone_spike, molten_dripstone_medium, molten_dripstone_great) make_recipe(molten_dripstone_spike, molten_dripstone_medium, molten_dripstone_great)
gapple_recipe(molten_dripstone_spike, molten_dripstone_great, molten_dripstone_large) make_recipe(molten_dripstone_spike, molten_dripstone_great, molten_dripstone_large)
gapple_recipe(molten_dripstone_spike, molten_dripstone_large, molten_dripstone_huge) make_recipe(molten_dripstone_spike, molten_dripstone_large, molten_dripstone_huge)
gapple_recipe(watered_dripstone_spike, watered_dripstone_spike, watered_dripstone_tiny) make_recipe(watered_dripstone_spike, watered_dripstone_spike, watered_dripstone_tiny)
gapple_recipe(watered_dripstone_spike, watered_dripstone_tiny, watered_dripstone_small) make_recipe(watered_dripstone_spike, watered_dripstone_tiny, watered_dripstone_small)
gapple_recipe(watered_dripstone_spike, watered_dripstone_small, watered_dripstone_medium) make_recipe(watered_dripstone_spike, watered_dripstone_small, watered_dripstone_medium)
gapple_recipe(watered_dripstone_spike, watered_dripstone_medium, watered_dripstone_great) make_recipe(watered_dripstone_spike, watered_dripstone_medium, watered_dripstone_great)
gapple_recipe(watered_dripstone_spike, watered_dripstone_great, watered_dripstone_large) make_recipe(watered_dripstone_spike, watered_dripstone_great, watered_dripstone_large)
gapple_recipe(watered_dripstone_spike, watered_dripstone_large, watered_dripstone_huge) make_recipe(watered_dripstone_spike, watered_dripstone_large, watered_dripstone_huge)
noordstar_dripstone.add_lava_catcher("mcl_cauldrons:cauldron", "mcl_cauldrons:cauldron_1_lava")
noordstar_dripstone.add_lava_catcher("mcl_cauldrons:cauldron_1_lava", "mcl_cauldrons:cauldron_2_lava")
noordstar_dripstone.add_lava_catcher("mcl_cauldrons:cauldron_2_lava", "mcl_cauldrons:cauldron_3_lava")
noordstar_dripstone.add_water_catcher("mcl_cauldrons:cauldron", "mcl_cauldrons:cauldron_1")
noordstar_dripstone.add_water_catcher("mcl_cauldrons:cauldron_1", "mcl_cauldrons:cauldron_2")
noordstar_dripstone.add_water_catcher("mcl_cauldrons:cauldron_2", "mcl_cauldrons:cauldron_3")
if minetest.get_modpath("mclx_core") then
noordstar_dripstone.add_water_catcher("mcl_cauldrons:cauldron", "mcl_cauldrons:cauldron_1r")
noordstar_dripstone.add_water_catcher("mcl_cauldrons:cauldron_1r", "mcl_cauldrons:cauldron_2r")
noordstar_dripstone.add_water_catcher("mcl_cauldrons:cauldron_2r", "mcl_cauldrons:cauldron_3r")
end