Fix stairsplus crash, optimise code

This commit is contained in:
Craig Davison 2017-07-24 17:48:24 +01:00
parent 9ffe5e94bd
commit dc71b951c4
No known key found for this signature in database
GPG Key ID: B22B44578F8BBB74
2 changed files with 38 additions and 55 deletions

View File

@ -1,3 +1,4 @@
default default
dye dye
stairs?
stairsplus? stairsplus?

View File

@ -1,72 +1,54 @@
local COLOURS = { local colours = {
"Black", {"black", "Black"},
"Cyan", {"cyan", "Cyan"},
"Brown", {"brown", "Brown"},
"Dark Blue", {"dark_blue", "Dark Blue"},
"Dark Green", {"dark_green", "Dark Green"},
"Dark Grey", {"dark_grey", "Dark Grey"},
"Dark Pink", {"dark_pink", "Dark Pink"},
"Green", {"green", "Green"},
"Grey", {"grey", "Grey"},
"Orange", {"orange", "Orange"},
"Pink", {"pink", "Pink"},
"Purple", {"purple", "Purple"},
"Red", {"red", "Red"},
"White", {"white", "White"},
"Yellow" {"yellow", "Yellow"}
} }
local COLOURS2 = { for _, row in ipairs(colours) do
"black",
"cyan",
"brown",
"dark_blue",
"dark_green",
"dark_grey",
"dark_pink",
"green",
"grey",
"orange",
"pink",
"purple",
"red",
"white",
"yellow"
}
for number = 1, 15 do local name = row[1]
local description = row[2]
local colour = COLOURS[number] minetest.register_node("colouredstonebricks:"..name, {
local colour2 = COLOURS2[number] description = description.." Stone Brick",
tiles = {"colouredstonebricks_"..name..".png"},
minetest.register_node("colouredstonebricks:"..colour2, {
description = colour.." Stone Brick",
tiles = {"colouredstonebricks_"..colour2..".png"},
groups = {cracky=3}, groups = {cracky=3},
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless", type = "shapeless",
output = 'colouredstonebricks:'..colour2, output = 'colouredstonebricks:'..name,
recipe = { recipe = {
'dye:'..colour2, 'default:stonebrick', 'dye:'..name, 'default:stonebrick',
} }
}) })
-- Support for stairsplus mod -- Support for stairsplus mod
if minetest.get_modpath("moreblocks") then
stairsplus:register_all("colouredstonebricks", colour2, "colouredstonebricks:"..colour2, { stairsplus:register_all("colouredstonebricks", name, "colouredstonebricks:"..name, {
description = colour.." Stone Brick", description = description.." Stone Brick",
tiles = {"colouredstonebricks_"..colour2..".png"}, tiles = {"colouredstonebricks_"..name..".png"},
groups = {cracky=3}, groups = {cracky=3},
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),
sunlight_propagates = true, sunlight_propagates = true,
}) })
end
end end
-- We don't have blue, violet or magenta coloured stone bricks (yet)
--minetest.register_alias("dye:dark_blue","dye:blue")
minetest.register_alias("dye:dark_blue","dye:blue") --minetest.register_alias("dye:dark_pink","dye:magenta")
minetest.register_alias("dye:dark_pink","dye:magenta") --minetest.register_alias("dye:purple","dye:violet")
minetest.register_alias("dye:purple","dye:violet")