API refactoring: make chairs/tables registation simplier

and get rid of the iron ones because they look silly and i don't think anybody would use 'em in their buildings
This commit is contained in:
Mikita Wiśniewski 2022-02-25 19:51:18 +07:00
parent 1b28bc08eb
commit d429d73ae0
4 changed files with 62 additions and 338 deletions

71
api.lua
View File

@ -52,9 +52,9 @@ end
function mcl_decor:register_chair(name, def) function mcl_decor.register_chair(name, desc, material, tiles)
minetest.register_node(name, { minetest.register_node(name, {
description = def.description, description = desc,
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -67,7 +67,7 @@ function mcl_decor:register_chair(name, def)
{-0.25, -0.5, -0.25, -0.125, -0.125, -0.125}, -- 4th leg {-0.25, -0.5, -0.25, -0.125, -0.125, -0.125}, -- 4th leg
} }
}, },
tiles = def.tiles, tiles = {tiles},
is_ground_content = false, is_ground_content = false,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
@ -77,23 +77,38 @@ function mcl_decor:register_chair(name, def)
type = "fixed", type = "fixed",
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }, fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 },
}, },
--[[ groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
collision_box = { _mcl_hardness = 2,
type = "fixed", _mcl_blast_resistance = 3,
fixed = { -0.25, -0.5, -0.25, 0.25, 0.5, 0.25 }, sounds = mcl_sounds.node_sound_wood_defaults(),
},
]]
groups = def.groups,
_mcl_hardness = def._mcl_hardness,
_mcl_blast_resistance = def._mcl_blast_resistance,
sounds = def.sounds,
on_rightclick = mcl_decor.sit on_rightclick = mcl_decor.sit
}) })
minetest.register_craft({
output = name,
recipe = {
{"", "", "mcl_core:stick"},
{material, material, material},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
output = name,
recipe = {
{"mcl_core:stick", "", ""},
{material, material, material},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = name,
burntime = 8,
})
end end
function mcl_decor:register_table(name, def) function mcl_decor.register_table(name, desc, material, tiles)
minetest.register_node(name, { minetest.register_node(name, {
description = def.description, description = desc,
drawtype = "nodebox", drawtype = "nodebox",
node_box = { node_box = {
type = "fixed", type = "fixed",
@ -107,17 +122,29 @@ function mcl_decor:register_table(name, def)
}, },
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, -- default 1x1 selection box (to override that weird selection of just the nodebox itself) fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 },
}, },
tiles = def.tiles, tiles = {tiles},
is_ground_content = false, is_ground_content = false,
paramtype = "light", paramtype = "light",
stack_max = 64, stack_max = 64,
sunlight_propagates = true, sunlight_propagates = true,
groups = def.groups, groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = def._mcl_hardness, _mcl_hardness = 2,
_mcl_blast_resistance = def._mcl_blast_resistance, _mcl_blast_resistance = 3,
sounds = def.sounds, sounds = mcl_sounds.node_sound_wood_defaults(),
-- TODO: make tables connect with each other??? })
minetest.register_craft({
output = name,
recipe = {
{material, material, material},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = name,
burntime = 10,
}) })
end end

View File

@ -9,11 +9,9 @@ Birch Chair=Берёзовый стул
Dark Oak Chair=Стул из тёмного дуба Dark Oak Chair=Стул из тёмного дуба
Jungle Chair=Стул из тропического дерева Jungle Chair=Стул из тропического дерева
Spruce Chair=Еловый стул Spruce Chair=Еловый стул
Iron Chair=Железный стул
Oak Table=Дубовый стол Oak Table=Дубовый стол
Acacia Table=Стол из акации Acacia Table=Стол из акации
Birch Table=Берёзовый стол Birch Table=Берёзовый стол
Dark Oak Table=Стол из тёмного дуба Dark Oak Table=Стол из тёмного дуба
Jungle Table=Стол из тропического дерева Jungle Table=Стол из тропического дерева
Spruce Table=Еловый стол Spruce Table=Еловый стол
Iron Table=Железый стол

View File

@ -9,11 +9,9 @@ Birch Chair=
Dark Oak Chair= Dark Oak Chair=
Jungle Chair= Jungle Chair=
Spruce Chair= Spruce Chair=
Iron Chair=
Oak Table= Oak Table=
Acacia Table= Acacia Table=
Birch Table= Birch Table=
Dark Oak Table= Dark Oak Table=
Jungle Table= Jungle Table=
Spruce Table= Spruce Table=
Iron Table=

View File

@ -102,316 +102,17 @@ minetest.register_craft({
--- Oak Chair --- --- Tables and Chairs ---
mcl_decor:register_chair("mcl_decor:wooden_chair", { mcl_decor.register_chair("mcl_decor:wooden_chair", S("Oak Chair"), "mcl_core:wood", "default_wood.png")
description = S("Oak Chair"), mcl_decor.register_chair("mcl_decor:dark_oak_chair", S("Dark Oak Chair"), "mcl_core:darkwood", "mcl_core_planks_big_oak.png")
tiles = {"default_wood.png"}, mcl_decor.register_chair("mcl_decor:jungle_chair", S("Jungle Chair"), "mcl_core:junglewood", "default_junglewood.png")
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1}, mcl_decor.register_chair("mcl_decor:spruce_chair", S("Spruce Chair"), "mcl_core:sprucewood", "mcl_core_planks_spruce.png")
_mcl_hardness = 3, mcl_decor.register_chair("mcl_decor:acacia_chair", S("Acacia Chair"), "mcl_core:acaciawood", "default_acacia_wood.png")
_mcl_blast_resistance = 3, mcl_decor.register_chair("mcl_decor:birch_chair", S("Birch Chair"), "mcl_core:birchwood", "mcl_core_planks_birch.png")
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:wooden_chair 2",
recipe = {
{"", "", "mcl_core:stick"},
{"mcl_core:wood", "mcl_core:wood", "mcl_core:wood"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:wooden_chair",
burntime = 8,
})
--- Acacia Chair --- mcl_decor.register_table("mcl_decor:wooden_table", S("Oak Table"), "mcl_core:wood", "default_wood.png")
mcl_decor:register_chair("mcl_decor:acacia_chair", { mcl_decor.register_table("mcl_decor:dark_oak_table", S("Dark Oak Table"), "mcl_core:darkwood", "mcl_core_planks_big_oak.png")
description = S("Acacia Chair"), mcl_decor.register_table("mcl_decor:jungle_table", S("Jungle Table"), "mcl_core:junglewood", "default_junglewood.png")
tiles = {"default_acacia_wood.png"}, mcl_decor.register_table("mcl_decor:spruce_table", S("Spruce Table"), "mcl_core:sprucewood", "default_wood.png")
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1}, mcl_decor.register_table("mcl_decor:acacia_table", S("Acacia Table"), "mcl_core:acaciawood", "default_acacia_wood.png")
_mcl_hardness = 3, mcl_decor.register_table("mcl_decor:birch_table", S("Birch Table"), "mcl_core:birchwood", "mcl_core_planks_birch.png")
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:acacia_chair 2",
recipe = {
{"", "", "mcl_core:stick"},
{"mcl_core:acaciawood", "mcl_core:acaciawood", "mcl_core:acaciawood"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:acacia_chair",
burntime = 8,
})
--- Birch Chair ---
mcl_decor:register_chair("mcl_decor:birch_chair", {
description = S("Birch Chair"),
tiles = {"mcl_core_planks_birch.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:birch_chair 2",
recipe = {
{"", "", "mcl_core:stick"},
{"mcl_core:birchwood", "mcl_core:birchwood", "mcl_core:birchwood"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:birch_chair",
burntime = 8,
})
--- Dark Oak Chair ---
mcl_decor:register_chair("mcl_decor:dark_oak_chair", {
description = S("Dark Oak Chair"),
tiles = {"mcl_core_planks_big_oak.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:dark_oak_chair 2",
recipe = {
{"", "", "mcl_core:stick"},
{"mcl_core:darkwood", "mcl_core:darkwood", "mcl_core:darkwood"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:dark_oak_chair",
burntime = 8,
})
--- Jungle Chair ---
mcl_decor:register_chair("mcl_decor:jungle_chair", {
description = S("Jungle Chair"),
tiles = {"default_junglewood.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:jungle_chair 2",
recipe = {
{"", "", "mcl_core:stick"},
{"mcl_core:junglewood", "mcl_core:junglewood", "mcl_core:junglewood"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:jungle_chair",
burntime = 8,
})
--- Spruce Chair ---
mcl_decor:register_chair("mcl_decor:spruce_chair", {
description = S("Spruce Chair"),
tiles = {"mcl_core_planks_spruce.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:spruce_chair 2",
recipe = {
{"", "", "mcl_core:stick"},
{"mcl_core:sprucewood", "mcl_core:sprucewood", "mcl_core:sprucewood"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:spruce_chair",
burntime = 8,
})
--- Iron Chair ---
mcl_decor:register_chair("mcl_decor:iron_chair", {
description = S("Iron Chair"),
tiles = {"default_steel_block.png"},
groups = {pickaxey=2, attached_node=1, deco_block=1},
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
sounds = mcl_sounds.node_sound_metal_defaults(),
})
minetest.register_craft({
output = "mcl_decor:iron_chair 2",
recipe = {
{"", "", "mcl_core:stick"},
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
--- Oak Table ---
mcl_decor:register_table("mcl_decor:wooden_table", {
description = S("Oak Table"),
tiles = {"default_wood.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:wooden_table",
recipe = {
{"mcl_core:wood", "mcl_core:wood", "mcl_core:wood"},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:wooden_table",
burntime = 10,
})
--- Acacia Table ---
mcl_decor:register_table("mcl_decor:acacia_table", {
description = S("Acacia Table"),
tiles = {"default_acacia_wood.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:acacia_table",
recipe = {
{"mcl_core:acaciawood", "mcl_core:acaciawood", "mcl_core:acaciawood"},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:acacia_table",
burntime = 10,
})
--- Birch Table ---
mcl_decor:register_table("mcl_decor:birch_table", {
description = S("Birch Table"),
tiles = {"mcl_core_planks_birch.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:birch_table",
recipe = {
{"mcl_core:birchwood", "mcl_core:birchwood", "mcl_core:birchwood"},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:birch_table",
burntime = 10,
})
--- Dark Oak Table ---
mcl_decor:register_table("mcl_decor:dark_oak_table", {
description = S("Dark Oak Table"),
tiles = {"mcl_core_planks_big_oak.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:dark_oak_table",
recipe = {
{"mcl_core:darkwood", "mcl_core:darkwood", "mcl_core:darkwood"},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:dark_oak_table",
burntime = 10,
})
--- Jungle Table ---
mcl_decor:register_table("mcl_decor:jungle_table", {
description = S("Jungle Table"),
tiles = {"default_junglewood.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:jungle_table",
recipe = {
{"mcl_core:junglewood", "mcl_core:junglewood", "mcl_core:junglewood"},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:jungle_table",
burntime = 10,
})
--- Spruce Table ---
mcl_decor:register_table("mcl_decor:spruce_table", {
description = S("Spruce Table"),
tiles = {"mcl_core_planks_spruce.png"},
groups = {handy=1, axey=1, attached_node=1, material_wood=1, deco_block=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "mcl_decor:spruce_table",
recipe = {
{"mcl_core:sprucewood", "mcl_core:sprucewood", "mcl_core:sprucewood"},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "fuel",
recipe = "mcl_decor:spruce_table",
burntime = 10,
})
--- Iron Table ---
mcl_decor:register_table("mcl_decor:iron_table", {
description = S("Iron Table"),
tiles = {"default_steel_block.png"},
groups = {pickaxey=2, attached_node=1, deco_block=1},
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
sounds = mcl_sounds.node_sound_metal_defaults(),
})
minetest.register_craft({
output = "mcl_decor:iron_table",
recipe = {
{"mcl_core:iron_ingot", "mcl_core:iron_ingot", "mcl_core:iron_ingot"},
{"mcl_core:stick", "", "mcl_core:stick"},
{"mcl_core:stick", "", "mcl_core:stick"}
}
})