Use tables for registering wooden nodes (fix of #2, p2)

unsure if will merge to indev; code just became bigger and without api at all (what if someone's mod adds new type of wood, why can't author of mod just add support for mine?)
This commit is contained in:
Mikita Wiśniewski 2022-05-01 14:06:21 +07:00
parent 4f43fcf650
commit 2989f4c616
1 changed files with 45 additions and 33 deletions

View File

@ -2,8 +2,23 @@
local S = minetest.get_translator(minetest.get_current_modname())
--=-- API --=--
function mcl_decor.register_chair_and_table(name, desc, desc2, material, tiles, group)
mcl_decor.woods = {
-- name, chair desc, table desc, slabtable desc, planks, texture
{"wooden", S("Oak Chair"), S("Oak Table"), S("Oak Slab Table"), "mcl_core:wood", "default_wood"},
{"dark_oak", S("Dark Oak Chair"), S("Dark Oak Table"), S("Dark Oak Slab Table"), "mcl_core:darkwood", "mcl_core_planks_big_oak"},
{"jungle", S("Jungle Chair"), S("Jungle Table"), S("Jungle Slab Table"), "mcl_core:junglewood", "default_junglewood"},
{"spruce", S("Spruce Chair"), S("Spruce Table"), S("Spruce Slab Table"), "mcl_core:sprucewood", "mcl_core_planks_spruce"},
{"acacia", S("Acacia Chair"), S("Acacia Table"), S("Acacia Slab Table"), "mcl_core:acaciawood", "default_acacia_wood"},
{"birch", S("Birch Chair"), S("Birch Table"), S("Birch Slab Table"), "mcl_core:birchwood", "mcl_core_planks_birch"},
}
mcl_decor.netherwoods = {
-- name, chair desc, table desc, slabtable desc, planks, texture
{"crimson", S("Crimson Chair"), S("Crimson Table"), S("Crimson Slab Table"), "mcl_mushroom:crimson_hyphae_wood", "crimson_hyphae_wood", "1"},
{"warped", S("Warped Chair"), S("Warped Table"), S("Warped Slab Table"), "mcl_mushroom:warped_hyphae_wood", "warped_hyphae_wood", "1"},
}
-- combined wooden stuff registering function
mcl_decor.register_wooden_stuff = function(name, desc, desc2, desc3, material, tiles, group)
if group == nil then
group = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1}
else
@ -25,7 +40,7 @@ function mcl_decor.register_chair_and_table(name, desc, desc2, material, tiles,
{-0.25, -0.5, -0.25, -0.125, -0.125, -0.125},
}
},
tiles = {tiles},
tiles = {tiles..".png"},
is_ground_content = false,
paramtype = "light",
paramtype2 = "facedir",
@ -81,7 +96,7 @@ function mcl_decor.register_chair_and_table(name, desc, desc2, material, tiles,
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
},
tiles = {tiles},
tiles = {tiles..".png"},
is_ground_content = false,
paramtype = "light",
stack_max = 64,
@ -104,16 +119,10 @@ function mcl_decor.register_chair_and_table(name, desc, desc2, material, tiles,
recipe = "mcl_decor:"..name.."_table",
burntime = 10,
})
end
function mcl_decor.register_slab_table(name, desc, material, tiles, group)
if group == nil then
group = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1}
else
group = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1}
end
-- slab table part
minetest.register_node("mcl_decor:"..name.."_stable", {
description = desc,
description = desc3,
drawtype = "nodebox",
node_box = {
type = "fixed",
@ -122,7 +131,7 @@ function mcl_decor.register_slab_table(name, desc, material, tiles, group)
{-0.5, 0, -0.5, 0.5, 0.5, 0.5},
}
},
tiles = {tiles},
tiles = {tiles..".png"},
is_ground_content = false,
paramtype = "light",
stack_max = 64,
@ -148,25 +157,28 @@ end
--=-- REGISTER --=--
mcl_decor.register_chair_and_table("wooden", S("Oak Chair"), S("Oak Table"), "mcl_core:wood", "default_wood.png")
mcl_decor.register_chair_and_table("dark_oak", S("Dark Oak Chair"), S("Dark Oak Table"), "mcl_core:darkwood", "mcl_core_planks_big_oak.png")
mcl_decor.register_chair_and_table("jungle", S("Jungle Chair"), S("Jungle Table"), "mcl_core:junglewood", "default_junglewood.png")
mcl_decor.register_chair_and_table("spruce", S("Spruce Chair"), S("Spruce Table"), "mcl_core:sprucewood", "mcl_core_planks_spruce.png")
mcl_decor.register_chair_and_table("acacia", S("Acacia Chair"), S("Acacia Table"), "mcl_core:acaciawood", "default_acacia_wood.png")
mcl_decor.register_chair_and_table("birch", S("Birch Chair"), S("Birch Table"), "mcl_core:birchwood", "mcl_core_planks_birch.png")
mcl_decor.register_slab_table("wooden", S("Oak Slab Table"), "mcl_core:wood", "default_wood.png")
mcl_decor.register_slab_table("dark_oak", S("Dark Oak Slab Table"), "mcl_core:darkwood", "mcl_core_planks_big_oak.png")
mcl_decor.register_slab_table("jungle", S("Jungle Slab Table"), "mcl_core:junglewood", "default_junglewood.png")
mcl_decor.register_slab_table("spruce", S("Spruce Slab Table"), "mcl_core:sprucewood", "mcl_core_planks_spruce.png")
mcl_decor.register_slab_table("acacia", S("Acacia Slab Table"), "mcl_core:acaciawood", "default_acacia_wood.png")
mcl_decor.register_slab_table("birch", S("Birch Slab Table"), "mcl_core:birchwood", "mcl_core_planks_birch.png")
for _, row in ipairs(mcl_decor.woods) do
-- define rows
local name = row[1]
local desc = row[2]
local desc2 = row[3]
local desc3 = row[4]
local material = row[5]
local tiles = row[6]
local group = row[7]
mcl_decor.register_wooden_stuff(name, desc, desc2, desc3, material, tiles, group)
end
-- support for MineClone 5
if minetest.get_modpath("mcl_mushroom") then
mcl_decor.register_chair_and_table("crimson", S("Crimson Chair"), S("Crimson Table"), "mcl_mushroom:crimson_hyphae_wood", "crimson_hyphae_wood.png", "1")
mcl_decor.register_chair_and_table("warped", S("Warped Chair"), S("Warped Table"), "mcl_mushroom:warped_hyphae_wood", "warped_hyphae_wood.png", "1")
mcl_decor.register_slab_table("crimson", S("Crimson Slab Table"), "mcl_mushroom:crimson_hyphae_wood", "crimson_hyphae_wood.png", "1")
mcl_decor.register_slab_table("warped", S("Warped Slab Table"), "mcl_mushroom:warped_hyphae_wood", "warped_hyphae_wood.png", "1")
for _, row in ipairs(mcl_decor.netherwoods) do
-- define rows
local name = row[1]
local desc = row[2]
local desc2 = row[3]
local desc3 = row[4]
local material = row[5]
local tiles = row[6]
local group = row[7]
mcl_decor.register_wooden_stuff(name, desc, desc2, desc3, material, tiles, group)
end
end