2024-04-30 02:24:12 +02:00
|
|
|
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
|
|
|
local S = minetest.get_translator(minetest.get_current_modname())
|
|
|
|
|
|
|
|
vl_hollow_logs = {}
|
|
|
|
--- Function to register a hollow log. See API.md to learn how to use this function.
|
|
|
|
---@param defs table {name:string, stripped_name>string, desc:string, stripped_desc:string, not_flammable:boolean|nil}
|
|
|
|
function vl_hollow_logs.register_hollow_log(defs)
|
2024-04-30 02:29:12 +02:00
|
|
|
if not defs or #defs < 4 then
|
|
|
|
return
|
|
|
|
end
|
2024-04-30 02:24:12 +02:00
|
|
|
|
2024-04-30 02:29:12 +02:00
|
|
|
for i = 1, #defs do
|
|
|
|
if i == 5 then
|
|
|
|
if type(defs[i]) ~= "boolean" and type(defs[i]) ~= "nil" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if type(defs[i]) ~= "string" then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-04-30 02:24:12 +02:00
|
|
|
|
2024-04-30 02:29:12 +02:00
|
|
|
local name = defs[1]
|
|
|
|
local stripped_name = defs[2]
|
|
|
|
local desc = defs[3]
|
|
|
|
local stripped_desc = defs[4]
|
2024-04-30 02:24:12 +02:00
|
|
|
|
2024-04-30 02:29:12 +02:00
|
|
|
local collisionbox = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.375},
|
|
|
|
{-0.5, -0.5, -0.5, -0.375, 0.5, 0.5},
|
|
|
|
{0.375, -0.5, -0.5, 0.5, 0.5, 0.5},
|
|
|
|
{-0.5, -0.5, 0.375, 0.5, 0.5, 0.5},
|
|
|
|
}
|
|
|
|
}
|
2024-04-30 02:24:12 +02:00
|
|
|
|
2024-04-30 02:29:12 +02:00
|
|
|
local groups = {axey = 1, building_block = 1, handy = 1, hollow_log = 1}
|
2024-04-30 02:24:12 +02:00
|
|
|
|
2024-04-30 02:29:12 +02:00
|
|
|
if not defs[5] then
|
|
|
|
groups = table.insert(groups, {fire_encouragement = 5, fire_flammability = 5, flammable = 2, hollow_log_burnable = 1})
|
|
|
|
end
|
2024-04-30 02:24:12 +02:00
|
|
|
|
2024-04-30 02:29:12 +02:00
|
|
|
minetest.register_node("vl_hollow_logs:"..name.."_hollow", {
|
|
|
|
collision_box = collisionbox,
|
|
|
|
description = S(desc),
|
|
|
|
drawtype = "mesh",
|
|
|
|
groups = groups,
|
|
|
|
mesh = "vl_hollow_logs_log.obj",
|
|
|
|
on_place = mcl_util.rotate_axis,
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2024-04-30 03:49:38 +02:00
|
|
|
use_texture_alpha = "clip",
|
2024-04-30 02:29:12 +02:00
|
|
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
|
|
|
sunlight_propagates = true,
|
|
|
|
tiles = {"vl_hollow_logs_"..name..".png"},
|
|
|
|
_mcl_blast_resistance = 2,
|
|
|
|
_mcl_hardness = 2,
|
|
|
|
_mcl_stripped_variant = "vl_hollow_logs:stripped_"..name.."_hollow"
|
|
|
|
})
|
2024-04-30 02:24:12 +02:00
|
|
|
|
2024-04-30 02:29:12 +02:00
|
|
|
minetest.register_node("vl_hollow_logs:"..stripped_name.."_hollow", {
|
|
|
|
collision_box = collisionbox,
|
|
|
|
description = S(stripped_desc),
|
|
|
|
drawtype = "mesh",
|
|
|
|
groups = groups,
|
|
|
|
mesh = "vl_hollow_logs_log.obj",
|
|
|
|
on_place = mcl_util.rotate_axis,
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
2024-04-30 03:49:38 +02:00
|
|
|
use_texture_alpha = "clip",
|
2024-04-30 02:29:12 +02:00
|
|
|
sounds = mcl_sounds.node_sound_wood_defaults(),
|
|
|
|
sunlight_propagates = true,
|
|
|
|
tiles = {"vl_hollow_logs_stripped_"..name..".png"},
|
|
|
|
_mcl_blast_resistance = 2,
|
|
|
|
_mcl_hardness = 2
|
|
|
|
})
|
2024-04-30 02:24:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
vl_hollow_logs.logs = {
|
2024-04-30 02:29:12 +02:00
|
|
|
{"acaciatree", "stripped_acacia", "Hollow Acacia Log", "Stripped Hollow Acacia Log"},
|
|
|
|
{"birchtree", "stripped_birch", "Hollow Birch Log", "Stripped Hollow Birch Log"},
|
|
|
|
{"darktree", "stripped_dark_oak", "Hollow Dark Oak Log", "Stripped Hollow Dark Oak Log"},
|
|
|
|
{"jungletree", "stripped_jungle", "Hollow Jungle Log", "Stripped Hollow Jungle Log"},
|
|
|
|
{"sprucetree", "stripped_spruce", "Hollow Spruce Log", "Stripped Hollow Spruce Log"},
|
|
|
|
{"tree", "stripped_oak", "Hollow Oak Log", "Stripped Hollow Oak Log"}
|
2024-04-30 02:24:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if minetest.get_modpath("mcl_cherry_blossom") then
|
2024-04-30 02:29:12 +02:00
|
|
|
table.insert(vl_hollow_logs.logs, {"cherrytree", "stripped_cherrytree", "Hollow Cherry Log", "Stripped Hollow Cherry Log"})
|
2024-04-30 02:24:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if minetest.get_modpath("mcl_mangrove") then
|
2024-04-30 02:29:12 +02:00
|
|
|
table.insert(vl_hollow_logs.logs, {"mangrove_tree", "mangrove_stripped", "Hollow Mangrove Log", "Stripped Hollow Mangrove Log"})
|
2024-04-30 02:24:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if minetest.get_modpath("mcl_crimson") then
|
2024-04-30 02:29:12 +02:00
|
|
|
table.insert(vl_hollow_logs.logs, {"crimson_hyphae", "stripped_crimson_hyphae", "Hollow Crimson Stem", "Stripped Hollow Crimson Stem", true})
|
|
|
|
table.insert(vl_hollow_logs.logs, {"warped_hyphae", "stripped_warped_hyphae", "Hollow Warped Stem", "Stripped Hollow Warped Stem", true})
|
2024-04-30 02:24:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
for _, defs in pairs(vl_hollow_logs.logs) do
|
2024-04-30 02:29:12 +02:00
|
|
|
vl_hollow_logs.register_hollow_log(defs)
|
2024-04-30 02:24:12 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
dofile(modpath.."/recipes.lua")
|