1
0
Fork 0

Refactor dripstone block definition

main
Bram van den Heuvel 2024-08-29 17:11:15 +02:00
parent f6774858db
commit 6301616925
1 changed files with 62 additions and 69 deletions

131
init.lua
View File

@ -26,12 +26,24 @@ 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 },
},
}
if size >= 8 then
return nil
else
return {
type = "fixed",
fixed = {
{ - size / 16, -0.5, - size / 16, size / 16, 0.5, size / 16 },
},
}
end
end
local function nodebox_type(size)
if size >= 8 then
return "normal"
else
return "nodebox"
end
end
-- Sounds
@ -45,7 +57,7 @@ local speed_factor = 30
local seconds_per_growth = 10 * speed_factor
local seconds_per_water_trickle = 1 * speed_factor
local seconds_per_lava_trickle = 6 * speed_factor
local samples_per_interval = 10
local samples_per_interval = 30
-- Namespaced node names
local dry_dripstone_block = "noordstar_dripstone:dripstone_block"
@ -194,67 +206,12 @@ local watered_dripstone_tiles =
, "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"
, groups = { pickaxey=2, material_stone=1 }
, is_ground_content = true
, drop = dry_dripstone_spike
, sounds = dripstone_sounds
, _mcl_hardness = 2
, _mcl_blast_resistance = 5
, _mcl_silk_touch_drop = true
}
)
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"
, groups = { pickaxey=2, material_stone=1 }
, is_ground_content = true
, drop = dry_dripstone_spike
, sounds = dripstone_sounds
, _mcl_hardness = 2
, _mcl_blast_resistance = 5
, _mcl_silk_touch_drop = true
}
)
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"
, groups = { pickaxey=2, material_stone=1 }
, is_ground_content = true
, drop = dry_dripstone_spike
, sounds = dripstone_sounds
, _mcl_hardness = 2
, _mcl_blast_resistance = 5
, _mcl_silk_touch_drop = true
}
)
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"
, groups = { pickaxey=2, material_stone=1 }
, is_ground_content = true
, drop = dry_dripstone_spike
, sounds = dripstone_sounds
, _mcl_hardness = 2
, _mcl_blast_resistance = 5
, _mcl_silk_touch_drop = true
}
)
local function make_dripstone(name, desc, longdesc, tiles, drop, size)
local sunlight_propagates = nil
if size < 8 then
sunlight_propagates = true
end
minetest.register_node(name,
{ description = desc
, _doc_items_longdesc = longdesc
@ -279,9 +236,9 @@ local function make_dripstone(name, desc, longdesc, tiles, drop, size)
}
}
, sounds = dripstone_sounds
, drawtype = "nodebox"
, drawtype = nodebox_type(size)
, paramtype = "light"
, sunlight_propagates = true
, sunlight_propagates = sunlight_propagates
, node_box = nodebox_of_size(size)
, _mcl_hardness = 1.0 + size / 8
, _mcl_blast_resistance = 1 + size / 2
@ -290,6 +247,42 @@ local function make_dripstone(name, desc, longdesc, tiles, drop, size)
)
end
-- BASE BLOCKS
-- These blocks are able to absorb water or lava from above them.
make_dripstone(
dry_dripstone_block,
"Dripstone block",
"Dripstone block that can suck up liquids above it and creates stalactites below it.",
dry_dripstone_tiles,
dry_dripstone_spike,
8
)
make_dripstone(
hardened_dripstone_block,
"Hardened dripstone block",
"Dripstone block that is no longer able to absorb liquids above it.",
hardened_dripstone_tiles,
dry_dripstone_spike,
8
)
make_dripstone(
molten_dripstone_block,
"Molten dripstone block",
"A dripstone block that has absorbed some lava, allowing it to form a stalactite.",
molten_dripstone_tiles,
dry_dripstone_spike,
8
)
make_dripstone(
watered_dripstone_block,
"Watered dripstone block",
"A dripstone block that has absorbed some water, allowing it to form a stalactite.",
watered_dripstone_tiles,
dry_dripstone_spike,
8
)
-- HUGE DRIPSTONE
-- This is the largest form a non-block can get.