Simplify register functions in api.lua

and modify register.lua for this too, of course
This commit is contained in:
Mikita Wiśniewski 2022-04-24 13:06:30 +07:00
parent 8dc358688c
commit ceeb4366c3
2 changed files with 82 additions and 80 deletions

74
api.lua
View File

@ -108,18 +108,18 @@ end
function mcl_decor.register_chair_and_table(name, desc, name2, desc2, material, tiles)
-- chair part
minetest.register_node(name, {
minetest.register_node("mcl_decor:"..name.."_chair", {
description = desc,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.25, 0, 0.125, 0.25, 0.5, 0.25}, -- back
{-0.25, -0.125, -0.25, 0.25, 0, 0.25}, -- seat
{-0.25, -0.5, 0.125, -0.125, -0.125, 0.25}, -- 1st leg
{0.125, -0.5, -0.25, 0.25, -0.125, -0.125}, -- 2nd leg
{0.125, -0.5, 0.125, 0.25, -0.125, 0.25}, -- 3rd leg
{-0.25, -0.5, -0.25, -0.125, -0.125, -0.125}, -- 4th leg
{-0.25, 0, 0.125, 0.25, 0.5, 0.25},
{-0.25, -0.125, -0.25, 0.25, 0, 0.25},
{-0.25, -0.5, 0.125, -0.125, -0.125, 0.25},
{0.125, -0.5, -0.25, 0.25, -0.125, -0.125},
{0.125, -0.5, 0.125, 0.25, -0.125, 0.25},
{-0.25, -0.5, -0.25, -0.125, -0.125, -0.125},
}
},
tiles = {tiles},
@ -139,7 +139,7 @@ function mcl_decor.register_chair_and_table(name, desc, name2, desc2, material,
on_rightclick = mcl_decor.sit
})
minetest.register_craft({
output = name,
output = "mcl_decor:"..name.."_chair",
recipe = {
{"", "", "mcl_core:stick"},
{material, material, material},
@ -147,7 +147,7 @@ function mcl_decor.register_chair_and_table(name, desc, name2, desc2, material,
}
})
minetest.register_craft({
output = name,
output = "mcl_decor:"..name.."_chair",
recipe = {
{"mcl_core:stick", "", ""},
{material, material, material},
@ -156,22 +156,22 @@ function mcl_decor.register_chair_and_table(name, desc, name2, desc2, material,
})
minetest.register_craft({
type = "fuel",
recipe = name,
recipe = "mcl_decor:"..name.."_chair",
burntime = 8,
})
-- table part
minetest.register_node(name2, {
minetest.register_node("mcl_decor:"..name2.."_table", {
description = desc2,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{ -0.5, 0.375, -0.5, 0.5, 0.5, 0.5 }, -- top
{ -0.4375, -0.5, -0.4375, -0.3125, 0.375, -0.3125 }, -- 1st leg
{ 0.3125, -0.5, -0.4375, 0.4375, 0.375, -0.3125 }, -- 2nd leg
{ 0.3125, -0.5, 0.3125, 0.4375, 0.375, 0.4375 }, -- 3rd leg
{ -0.4375, -0.5, 0.3125, -0.3125, 0.375, 0.4375 }, -- 4th leg
{ -0.5, 0.375, -0.5, 0.5, 0.5, 0.5 },
{ -0.4375, -0.5, -0.4375, -0.3125, 0.375, -0.3125 },
{ 0.3125, -0.5, -0.4375, 0.4375, 0.375, -0.3125 },
{ 0.3125, -0.5, 0.3125, 0.4375, 0.375, 0.4375 },
{ -0.4375, -0.5, 0.3125, -0.3125, 0.375, 0.4375 },
}
},
selection_box = {
@ -189,7 +189,7 @@ function mcl_decor.register_chair_and_table(name, desc, name2, desc2, material,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = name2.." 2",
output = "mcl_decor:"..name2.."_table".." 2",
recipe = {
{material, material, material},
{"mcl_core:stick", "", "mcl_core:stick"},
@ -198,13 +198,13 @@ function mcl_decor.register_chair_and_table(name, desc, name2, desc2, material,
})
minetest.register_craft({
type = "fuel",
recipe = name2,
recipe = "mcl_decor:"..name2.."_table",
burntime = 10,
})
end
function mcl_decor.register_slab_table(name, desc, material, tiles)
minetest.register_node(name, {
minetest.register_node("mcl_decor:"..name.."_stable", {
description = desc,
drawtype = "nodebox",
node_box = {
@ -225,7 +225,7 @@ function mcl_decor.register_slab_table(name, desc, material, tiles)
sounds = mcl_sounds.node_sound_wood_defaults(),
})
minetest.register_craft({
output = name.." 3",
output = "mcl_decor:"..name.."_stable".." 3",
recipe = {
{material, material, material},
{"", "mcl_core:stick", ""}
@ -233,13 +233,13 @@ function mcl_decor.register_slab_table(name, desc, material, tiles)
})
minetest.register_craft({
type = "fuel",
recipe = name,
recipe = "mcl_decor:"..name.."_stable",
burntime = 10,
})
end
function mcl_decor.register_armchair(name, desc, material, tiles, dye, colorgroup)
minetest.register_node(name, {
function mcl_decor.register_armchair(color, desc, tiles, dye, colorgroup)
minetest.register_node("mcl_decor:"..color.."_armchair", {
description = desc,
drawtype = "nodebox",
node_box = {
@ -268,35 +268,35 @@ function mcl_decor.register_armchair(name, desc, material, tiles, dye, colorgrou
on_rightclick = mcl_decor.sit
})
minetest.register_craft({
output = name,
output = "mcl_decor:"..color.."_armchair",
recipe = {
{"", "", material},
{material, material, material},
{"", "", "mcl_wool:"..color},
{"mcl_wool:"..color, "mcl_wool:"..color, "mcl_wool:"..color},
{"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}
}
})
minetest.register_craft({
output = name,
output = "mcl_decor:"..color.."_armchair",
recipe = {
{material, "", ""},
{material, material, material},
{"mcl_wool:"..color, "", ""},
{"mcl_wool:"..color, "mcl_wool:"..color, "mcl_wool:"..color},
{"mcl_core:stick", "mcl_core:stick", "mcl_core:stick"}
}
})
minetest.register_craft({
type = "shapeless",
output = name,
recipe = {"group:armchair", "mcl_dye:" .. dye},
output = "mcl_decor:"..color.."_armchair",
recipe = {"group:armchair", "mcl_dye:"..dye},
})
minetest.register_craft({
type = "fuel",
recipe = name,
recipe = "mcl_decor:"..color.."_armchair",
burntime = 10,
})
end
function mcl_decor.register_dyed_planks(name, desc, hexcolor, dye, colorgroup)
minetest.register_node("mcl_decor:"..name, {
function mcl_decor.register_dyed_planks(color, desc, hexcolor, dye, colorgroup)
minetest.register_node("mcl_decor:"..color.."_planks", {
description = desc,
tiles = {"mcl_decor_dyed_planks.png^[colorize:" .. hexcolor .. ":125"},
stack_max = 64,
@ -308,11 +308,13 @@ function mcl_decor.register_dyed_planks(name, desc, hexcolor, dye, colorgroup)
})
minetest.register_craft({
type = "shapeless",
output = "mcl_decor:"..name,
output = "mcl_decor:"..color.."_planks",
recipe = {"group:wood", "mcl_dye:"..dye}
})
-- maybe descriptions of slabs/stairs after that workaround will be VERY CRAPPY (especially with translations via locales), but at least it works
mcl_stairs.register_stair_and_slab_simple(name, "mcl_decor:"..name, desc..S(" Stair"), desc..S(" Slab"), S("Double")..desc..S(" Slab"), "woodlike")
mcl_stairs.register_stair_and_slab_simple(
color.."_planks", "mcl_decor:"..color.."_planks", desc..S(" Stair"), desc..S(" Slab"), S("Double")..desc..S(" Slab"), "woodlike"
)
end
-- FIXME: curtains can be placed infinitely just like in creative mode

View File

@ -127,39 +127,39 @@ minetest.register_craft({
--- Tables and Chairs ---
mcl_decor.register_chair_and_table("mcl_decor:wooden_chair", S("Oak Chair"), "mcl_decor:wooden_table", S("Oak Table"), "mcl_core:wood", "default_wood.png")
mcl_decor.register_chair_and_table("mcl_decor:dark_oak_chair", S("Dark Oak Chair"), "mcl_decor:dark_oak_table", S("Dark Oak Table"), "mcl_core:darkwood", "mcl_core_planks_big_oak.png")
mcl_decor.register_chair_and_table("mcl_decor:jungle_chair", S("Jungle Chair"), "mcl_decor:jungle_table", S("Jungle Table"), "mcl_core:junglewood", "default_junglewood.png")
mcl_decor.register_chair_and_table("mcl_decor:spruce_chair", S("Spruce Chair"), "mcl_decor:spruce_table", S("Spruce Table"), "mcl_core:sprucewood", "mcl_core_planks_spruce.png")
mcl_decor.register_chair_and_table("mcl_decor:acacia_chair", S("Acacia Chair"), "mcl_decor:acacia_table", S("Acacia Table"), "mcl_core:acaciawood", "default_acacia_wood.png")
mcl_decor.register_chair_and_table("mcl_decor:birch_chair", S("Birch Chair"), "mcl_decor:birch_table", S("Birch Table"), "mcl_core:birchwood", "mcl_core_planks_birch.png")
mcl_decor.register_chair_and_table("wooden", S("Oak Chair"), "wooden", S("Oak Table"), "mcl_core:wood", "default_wood.png")
mcl_decor.register_chair_and_table("dark_oak", S("Dark Oak Chair"), "dark_oak", S("Dark Oak Table"), "mcl_core:darkwood", "mcl_core_planks_big_oak.png")
mcl_decor.register_chair_and_table("jungle", S("Jungle Chair"), "jungle", S("Jungle Table"), "mcl_core:junglewood", "default_junglewood.png")
mcl_decor.register_chair_and_table("spruce", S("Spruce Chair"), "spruce", S("Spruce Table"), "mcl_core:sprucewood", "mcl_core_planks_spruce.png")
mcl_decor.register_chair_and_table("acacia", S("Acacia Chair"), "acacia", S("Acacia Table"), "mcl_core:acaciawood", "default_acacia_wood.png")
mcl_decor.register_chair_and_table("birch", S("Birch Chair"), "birch", S("Birch Table"), "mcl_core:birchwood", "mcl_core_planks_birch.png")
mcl_decor.register_slab_table("mcl_decor:wooden_stable", S("Oak Slab Table"), "mcl_core:wood", "default_wood.png")
mcl_decor.register_slab_table("mcl_decor:dark_oak_stable", S("Dark Oak Slab Table"), "mcl_core:darkwood", "mcl_core_planks_big_oak.png")
mcl_decor.register_slab_table("mcl_decor:jungle_stable", S("Jungle Slab Table"), "mcl_core:junglewood", "default_junglewood.png")
mcl_decor.register_slab_table("mcl_decor:spruce_stable", S("Spruce Slab Table"), "mcl_core:sprucewood", "mcl_core_planks_spruce.png")
mcl_decor.register_slab_table("mcl_decor:acacia_stable", S("Acacia Slab Table"), "mcl_core:acaciawood", "default_acacia_wood.png")
mcl_decor.register_slab_table("mcl_decor:birch_stable", S("Birch Slab 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")
--- Armchairs ---
mcl_decor.register_armchair("mcl_decor:white_armchair", S("White Armchair"), "mcl_wool:white", "wool_white.png", "white", "unicolor_white")
mcl_decor.register_armchair("mcl_decor:grey_armchair", S("Grey Armchair"), "mcl_wool:grey", "wool_dark_grey.png", "dark_grey", "unicolor_darkgrey")
mcl_decor.register_armchair("mcl_decor:silver_armchair", S("Light Grey Armchair"), "mcl_wool:silver", "wool_grey.png", "grey", "unicolor_grey")
mcl_decor.register_armchair("mcl_decor:black_armchair", S("Black Armchair"), "mcl_wool:black", "wool_black.png", "black", "unicolor_black")
mcl_decor.register_armchair("mcl_decor:red_armchair", S("Red Armchair"), "mcl_wool:red", "wool_red.png", "red", "unicolor_red")
mcl_decor.register_armchair("mcl_decor:yellow_armchair", S("Yellow Armchair"), "mcl_wool:yellow", "wool_yellow.png", "yellow", "unicolor_yellow")
mcl_decor.register_armchair("mcl_decor:green_armchair", S("Green Armchair"), "mcl_wool:green", "wool_dark_green.png", "dark_green", "unicolor_dark_green")
mcl_decor.register_armchair("mcl_decor:cyan_armchair", S("Cyan Armchair"), "mcl_wool:cyan", "wool_cyan.png", "cyan", "unicolor_cyan")
mcl_decor.register_armchair("mcl_decor:blue_armchair", S("Blue Armchair"), "mcl_wool:blue", "wool_blue.png", "blue", "unicolor_blue")
mcl_decor.register_armchair("mcl_decor:magenta_armchair", S("Magenta Armchair"), "mcl_wool:magenta", "wool_magenta.png", "magenta", "unicolor_red_violet")
mcl_decor.register_armchair("mcl_decor:orange_armchair", S("Orange Armchair"), "mcl_wool:orange", "wool_orange.png", "orange", "unicolor_orange")
mcl_decor.register_armchair("mcl_decor:purple_armchair", S("Purple Armchair"), "mcl_wool:purple", "wool_violet.png", "violet", "unicolor_violet")
mcl_decor.register_armchair("mcl_decor:brown_armchair", S("Brown Armchair"), "mcl_wool:brown", "wool_brown.png", "brown", "unicolor_dark_orange")
mcl_decor.register_armchair("mcl_decor:pink_armchair", S("Pink Armchair"), "mcl_wool:pink", "wool_pink.png", "pink", "unicolor_light_red")
mcl_decor.register_armchair("mcl_decor:lime_armchair", S("Lime Armchair"), "mcl_wool:lime", "mcl_wool_lime.png", "green", "unicolor_green")
mcl_decor.register_armchair("mcl_decor:light_blue_armchair", S("Light Blue Armchair"), "mcl_wool:light_blue", "mcl_wool_light_blue.png", "lightblue", "unicolor_light_blue")
mcl_decor.register_armchair("white", S("White Armchair"), "wool_white.png", "white", "unicolor_white")
mcl_decor.register_armchair("grey", S("Grey Armchair"), "wool_dark_grey.png", "dark_grey", "unicolor_darkgrey")
mcl_decor.register_armchair("silver", S("Light Grey Armchair"), "wool_grey.png", "grey", "unicolor_grey")
mcl_decor.register_armchair("black", S("Black Armchair"), "wool_black.png", "black", "unicolor_black")
mcl_decor.register_armchair("red", S("Red Armchair"), "wool_red.png", "red", "unicolor_red")
mcl_decor.register_armchair("yellow", S("Yellow Armchair"), "wool_yellow.png", "yellow", "unicolor_yellow")
mcl_decor.register_armchair("green", S("Green Armchair"), "wool_dark_green.png", "dark_green", "unicolor_dark_green")
mcl_decor.register_armchair("cyan", S("Cyan Armchair"), "wool_cyan.png", "cyan", "unicolor_cyan")
mcl_decor.register_armchair("blue", S("Blue Armchair"), "wool_blue.png", "blue", "unicolor_blue")
mcl_decor.register_armchair("magenta", S("Magenta Armchair"), "wool_magenta.png", "magenta", "unicolor_red_violet")
mcl_decor.register_armchair("orange", S("Orange Armchair"), "wool_orange.png", "orange", "unicolor_orange")
mcl_decor.register_armchair("purple", S("Purple Armchair"), "wool_violet.png", "violet", "unicolor_violet")
mcl_decor.register_armchair("brown", S("Brown Armchair"), "wool_brown.png", "brown", "unicolor_dark_orange")
mcl_decor.register_armchair("pink", S("Pink Armchair"), "wool_pink.png", "pink", "unicolor_light_red")
mcl_decor.register_armchair("lime", S("Lime Armchair"), "mcl_wool_lime.png", "green", "unicolor_green")
mcl_decor.register_armchair("light_blue", S("Light Blue Armchair"), "mcl_wool_light_blue.png", "lightblue", "unicolor_light_blue")
@ -184,19 +184,19 @@ mcl_decor.register_curtains("light_blue", S("Light Blue Curtains"), "mcl_wool:li
--- Dyed Planks ---
mcl_decor.register_dyed_planks("white_planks", S("White Planks"), "#EDEDED", "white", "unicolor_white")
mcl_decor.register_dyed_planks("grey_planks", S("Grey Planks"), "#5F5F5F", "dark_grey", "unicolor_darkgrey")
mcl_decor.register_dyed_planks("silver_planks", S("Light Grey Planks"), "#8C8C8C", "grey", "unicolor_grey")
mcl_decor.register_dyed_planks("black_planks", S("Black Planks"), "#030303", "black", "unicolor_black")
mcl_decor.register_dyed_planks("red_planks", S("Red Planks"), "#BD0000", "red", "unicolor_red")
mcl_decor.register_dyed_planks("yellow_planks", S("Yellow Planks"), "#EBD800", "yellow", "unicolor_yellow")
mcl_decor.register_dyed_planks("green_planks", S("Green Planks"), "#086400", "dark_green", "unicolor_dark_green")
mcl_decor.register_dyed_planks("cyan_planks", S("Cyan Planks"), "#00C4B4", "cyan", "unicolor_cyan")
mcl_decor.register_dyed_planks("blue_planks", S("Blue Planks"), "#0B1E80", "blue", "unicolor_blue")
mcl_decor.register_dyed_planks("magenta_planks", S("Magenta Planks"), "#954395", "magenta", "unicolor_red_violet")
mcl_decor.register_dyed_planks("orange_planks", S("Orange Planks"), "#E68200", "orange", "unicolor_orange")
mcl_decor.register_dyed_planks("purple_planks", S("Purple Planks"), "#461A6D", "violet", "unicolor_violet")
mcl_decor.register_dyed_planks("brown_planks", S("Brown Planks"), "#432209", "brown", "unicolor_dark_orange")
mcl_decor.register_dyed_planks("pink_planks", S("Pink Planks"), "#ED9BB4", "pink", "unicolor_light_red")
mcl_decor.register_dyed_planks("lime_planks", S("Lime Planks"), "#B3DF86", "green", "unicolor_green")
mcl_decor.register_dyed_planks("light_blue_planks", S("Light Blue Planks"), "#72A4D4", "lightblue", "unicolor_light_blue")
mcl_decor.register_dyed_planks("white", S("White Planks"), "#EDEDED", "white", "unicolor_white")
mcl_decor.register_dyed_planks("grey", S("Grey Planks"), "#5F5F5F", "dark_grey", "unicolor_darkgrey")
mcl_decor.register_dyed_planks("silver", S("Light Grey Planks"), "#8C8C8C", "grey", "unicolor_grey")
mcl_decor.register_dyed_planks("black", S("Black Planks"), "#030303", "black", "unicolor_black")
mcl_decor.register_dyed_planks("red", S("Red Planks"), "#BD0000", "red", "unicolor_red")
mcl_decor.register_dyed_planks("yellow", S("Yellow Planks"), "#EBD800", "yellow", "unicolor_yellow")
mcl_decor.register_dyed_planks("green", S("Green Planks"), "#086400", "dark_green", "unicolor_dark_green")
mcl_decor.register_dyed_planks("cyan", S("Cyan Planks"), "#00C4B4", "cyan", "unicolor_cyan")
mcl_decor.register_dyed_planks("blue", S("Blue Planks"), "#0B1E80", "blue", "unicolor_blue")
mcl_decor.register_dyed_planks("magenta", S("Magenta Planks"), "#954395", "magenta", "unicolor_red_violet")
mcl_decor.register_dyed_planks("orange", S("Orange Planks"), "#E68200", "orange", "unicolor_orange")
mcl_decor.register_dyed_planks("purple", S("Purple Planks"), "#461A6D", "violet", "unicolor_violet")
mcl_decor.register_dyed_planks("brown", S("Brown Planks"), "#432209", "brown", "unicolor_dark_orange")
mcl_decor.register_dyed_planks("pink", S("Pink Planks"), "#ED9BB4", "pink", "unicolor_light_red")
mcl_decor.register_dyed_planks("lime", S("Lime Planks"), "#B3DF86", "green", "unicolor_green")
mcl_decor.register_dyed_planks("light_blue", S("Light Blue Planks"), "#72A4D4", "lightblue", "unicolor_light_blue")