Refactored vl_hollow_logs a bit

This commit is contained in:
the-real-herowl 2024-09-26 23:29:30 +02:00 committed by the-real-herowl
parent 642c9ec32d
commit 750500b94f
2 changed files with 13 additions and 21 deletions
mods/ITEMS/vl_hollow_logs

View file

@ -6,15 +6,15 @@ Hollow logs mostly have a decorative function, but some of them can be used in r
## Functions:
### ```vl_hollow_logs.register_hollow_log(defs)```
This is the function that registers the hollow trunk.
For a hollow log to be registered, the <span style="color:firebrick"> defs </span> parameter must be a table that contains up to 5 values, which are, in this order, the <span style="color:firebrick"> itemstring </span> of the hollow log, the <span style="color:firebrick"> itemstring </span> of the stripped hollow log, the <span style="color:firebrick"> description </span> of the hollow log, the <span style="color:firebrick"> description </span> of the stripped hollow log and, optionally, a <span style="color:turquoise"> boolean </span> to inform whether this trunk is NOT flammable. If the hollow log is defined as flammable, it becomes part of the <span style="color:springgreen"> hollow_log_flammable </span> group, which allows the log to be used as fuel for furnaces and also allows it to be an ingredient for chacoal.
For a hollow log to be registered, the <span style="color:firebrick"> defs </span> parameter must be a table that contains up to 5 values, which are, in this order, the <span style="color:firebrick"> itemstring </span> of the hollow log, the <span style="color:firebrick"> itemstring </span> of the stripped hollow log, the <span style="color:firebrick"> description </span> of the hollow log, the <span style="color:firebrick"> description </span> of the stripped hollow log and, optionally, a <span style="color:turquoise"> boolean </span> to inform whether this trunk is NOT flammable. If the hollow log is defined as flammable, it becomes part of the <span style="color:springgreen"> hollow_log_burnable </span> group, which allows the log to be used as fuel for furnaces and also allows it to be an ingredient for chacoal.
Examples:
```lua
-- Flammable
{"tree", "stripped_oak", "Hollow Oak Log", "Stripped Hollow Oak Log"}
{"tree", "stripped_oak", S("Hollow Oak Log"), S("Stripped Hollow Oak Log")}
-- Not flammable
{"crimson_hyphae", "stripped_crimson_hyphae", "Hollow Crimson Stem", "Stripped Hollow Crimson Stem", true}
{"crimson_hyphae", "stripped_crimson_hyphae", S("Hollow Crimson Stem"), S("Stripped Hollow Crimson Stem"), true}
```
### ```vl_hollow_logs.register_craft(material, result)```

View file

@ -46,7 +46,7 @@ function vl_hollow_logs.register_hollow_log(defs)
table.update(groups, {fire_encouragement = 5, fire_flammability = 5, flammable = 2, hollow_log_burnable = 1})
end
minetest.register_node(modname .. ":"..name.."_hollow", {
local hollow_log_def = {
collision_box = collisionbox,
description = desc,
drawtype = "mesh",
@ -62,24 +62,16 @@ function vl_hollow_logs.register_hollow_log(defs)
_mcl_blast_resistance = 2,
_mcl_hardness = 2,
_mcl_stripped_variant = modname .. ":"..stripped_name.."_hollow"
})
}
minetest.register_node(modname .. ":"..stripped_name.."_hollow", {
collision_box = collisionbox,
description = stripped_desc,
drawtype = "mesh",
groups = groups,
mesh = "vl_hollow_logs_log.obj",
on_place = mcl_util.rotate_axis,
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = "clip",
sounds = mcl_sounds.node_sound_wood_defaults(),
sunlight_propagates = true,
tiles = {modname .. "_stripped_"..name..".png"},
_mcl_blast_resistance = 2,
_mcl_hardness = 2
})
local stripped_hollow_log_def = table.copy(hollow_log_def)
stripped_hollow_log_def.description = stripped_desc
stripped_hollow_log_def.tiles = {modname .. "_stripped_"..name..".png"}
stripped_hollow_log_def._mcl_stripped_variant = nil
minetest.register_node(modname .. ":"..name.."_hollow", hollow_log_def)
minetest.register_node(modname .. ":"..stripped_name.."_hollow", stripped_hollow_log_def)
end
vl_hollow_logs.logs = {