tidy code

This commit is contained in:
tenplus1 2022-10-03 16:40:43 +01:00
parent b6d5742ba8
commit ea02095433

View File

@ -3,7 +3,6 @@ local stairs_mod = minetest.get_modpath("stairs")
local stairsplus_mod = minetest.global_exists("stairsplus") local stairsplus_mod = minetest.global_exists("stairsplus")
local ethereal_mod = minetest.get_modpath("ethereal") local ethereal_mod = minetest.get_modpath("ethereal")
local colours = { local colours = {
{"black", "Black", "#000000b0"}, {"black", "Black", "#000000b0"},
{"blue", "Blue", "#015dbb70"}, {"blue", "Blue", "#015dbb70"},
@ -94,11 +93,11 @@ local function set_alias(col, name)
end end
for i = 1, #colours, 1 do for i = 1, #colours do
-- stone brick -- stone brick
cblocks_stairs("cblocks:stonebrick_" .. colours[i][1], { cblocks_stairs("cblocks:stonebrick_" .. colours[i][1], {
description = colours[i][2] .. " Stone Brick", description = colours[i][2] .. " Stone Brick",
tiles = {"default_stone_brick.png^[colorize:" .. colours[i][3]}, tiles = {"default_stone_brick.png^[colorize:" .. colours[i][3]},
paramtype = "light", paramtype = "light",
@ -107,20 +106,20 @@ cblocks_stairs("cblocks:stonebrick_" .. colours[i][1], {
groups = {cracky = 2, stone = 1}, groups = {cracky = 2, stone = 1},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = minetest.rotate_node, on_place = minetest.rotate_node
}) })
minetest.register_craft({ minetest.register_craft({
output = "cblocks:stonebrick_".. colours[i][1] .. " 2", output = "cblocks:stonebrick_" .. colours[i][1] .. " 2",
recipe = { recipe = {
{"default:stonebrick","default:stonebrick", "dye:" .. colours[i][1]} {"default:stonebrick","default:stonebrick", "dye:" .. colours[i][1]}
} }
}) })
-- glass (no stairs unless stairs redo active because default stairs mod -- glass (no stairs unless stairs redo active because default stairs mod
-- does not support transparent stairs) -- does not support transparent stairs)
if stairs_mod and stairs and stairs.mod and stairs.mod == "redo" then if stairs_mod and stairs and stairs.mod and stairs.mod == "redo" then
cblocks_stairs("cblocks:glass_" .. colours[i][1], { cblocks_stairs("cblocks:glass_" .. colours[i][1], {
description = colours[i][2] .. " Glass", description = colours[i][2] .. " Glass",
@ -135,7 +134,7 @@ if stairs_mod and stairs and stairs.mod and stairs.mod == "redo" then
}) })
set_alias(colours[i][1], "glass") set_alias(colours[i][1], "glass")
else else
minetest.register_node("cblocks:glass_" .. colours[i][1], { minetest.register_node("cblocks:glass_" .. colours[i][1], {
description = colours[i][2] .. " Glass", description = colours[i][2] .. " Glass",
tiles = {"cblocks.png^[colorize:" .. colours[i][3]}, tiles = {"cblocks.png^[colorize:" .. colours[i][3]},
@ -147,25 +146,25 @@ else
groups = {cracky = 3, oddly_breakable_by_hand = 3}, groups = {cracky = 3, oddly_breakable_by_hand = 3},
sounds = default.node_sound_glass_defaults() sounds = default.node_sound_glass_defaults()
}) })
end end
minetest.register_craft({ minetest.register_craft({
output = "cblocks:glass_".. colours[i][1] .. " 2", output = "cblocks:glass_".. colours[i][1] .. " 2",
recipe = { recipe = {
{"default:glass","default:glass", "dye:" .. colours[i][1]}, {"default:glass","default:glass", "dye:" .. colours[i][1]},
} }
}) })
-- wood -- wood
local col = colours[i][1] local col = colours[i][1]
-- ethereal already has yellow wood so rename to yellow2 -- ethereal already has yellow wood so rename to yellow2
if ethereal_mod and col == "yellow" then if ethereal_mod and col == "yellow" then
col = "yellow2" col = "yellow2"
end end
cblocks_stairs("cblocks:wood_" .. col, { cblocks_stairs("cblocks:wood_" .. col, {
description = colours[i][2] .. " Wooden Planks", description = colours[i][2] .. " Wooden Planks",
tiles = {"default_wood.png^[colorize:" .. colours[i][3]}, tiles = {"default_wood.png^[colorize:" .. colours[i][3]},
paramtype = "light", paramtype = "light",
@ -174,29 +173,29 @@ cblocks_stairs("cblocks:wood_" .. col, {
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1}, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, wood = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir", paramtype2 = "facedir",
on_place = minetest.rotate_node, on_place = minetest.rotate_node
}) })
set_alias(colours[i][1], "wood") set_alias(colours[i][1], "wood")
minetest.register_craft({ minetest.register_craft({
output = "cblocks:wood_".. col .. " 2", output = "cblocks:wood_" .. col .. " 2",
recipe = { recipe = {
{"group:wood","group:wood", "dye:" .. colours[i][1]} {"group:wood","group:wood", "dye:" .. colours[i][1]}
} }
}) })
end end
-- add lucky blocks -- add lucky blocks
if minetest.get_modpath("lucky_block") then if minetest.get_modpath("lucky_block") then
lucky_block:add_blocks({
lucky_block:add_blocks({
{"dro", {"cblocks:wood_"}, 10, true}, {"dro", {"cblocks:wood_"}, 10, true},
{"dro", {"cblocks:stonebrick_"}, 10, true}, {"dro", {"cblocks:stonebrick_"}, 10, true},
{"dro", {"cblocks:glass_"}, 10, true}, {"dro", {"cblocks:glass_"}, 10, true},
{"exp"} {"exp"}
}) })
end end