refactor log registration.

rename log and sapling textures to be more clear. rewrite node
registration code to account for this, and to be overall cleaner.
This commit is contained in:
trans_soup 2023-10-17 11:23:32 +02:00
parent 5a3d81787c
commit 19d63efcf5
3 changed files with 23 additions and 27 deletions

View File

@ -1,39 +1,35 @@
local modname = minetest.get_current_modname()
blockgame.register_node(modname .. ":log", {
description = "Log",
tiles = {
modname .. "_log_top.png",
modname .. "_log_top.png",
modname .. "_log.png",
},
groups = {
local function reg_log (name, def)
def = def or {}
def.description = def.description or "Log"
local texture = def.texture or name
def.tiles = blockgame.underride(def.tiles, {
modname .. "_" .. texture .. "_top.png",
modname .. "_" .. texture .. "_top.png",
modname .. "_" .. texture .. ".png",
})
def.groups = blockgame.underride(def.groups, {
woody = 1,
},
})
blockgame.register_node(modname .. ":log_alive", {
description = "Living Log",
tiles = {
modname .. "_log_top.png",
modname .. "_log_top.png",
modname .. "_log.png",
},
supports_leaves = 1,
})
blockgame.register_node(modname .. ":" .. name, def)
end
reg_log("log")
reg_log("log_alive", {
groups = {
woody = 1,
planty = 1,
},
texture = "log",
drop = modname .. ":log",
})
blockgame.register_node(modname .. ":sapling", {
description = "Growing Log",
tiles = {
modname .. "_log_top_alive.png",
modname .. "_log_top_alive.png",
modname .. "_log_alive.png",
},
reg_log("sapling", {
groups = {
woody = 1,
planty = 1,
},
drop = modname .. ":log",

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB