minetest_colorcubes/init.lua

127 lines
5.3 KiB
Lua

local cc = {}
cc.colors = { "white", "yellow", "orange", "red", "redviolet", "magenta", "violet", "blue", "skyblue", "cyan", "aqua", "green", "lime", "pink", "brown", "dark_green", "light_gray", "dark_gray", "black" }
cc.dyecolors = { "unicolor_white", "unicolor_yellow", "unicolor_orange", "unicolor_red", "unicolor_red_violet", "unicolor_magenta", "unicolor_violet", "unicolor_blue", "unicolor_sky_blue", "unicolor_cyan", "unicolor_aqua", "unicolor_green", "unicolor_lime", "unicolor_light_red", "unicolor_dark_orange", "unicolor_dark_green", "unicolor_grey", "unicolor_darkgrey", "unicolor_black" }
cc.human_colors = { "white", "yellow", "orange", "red", "red-violet", "magenta", "violet", "blue", "skyblue", "cyan", "aqua", "green", "lime", "pink", "brown", "dark green", "light gray", "dark gray", "black" }
local light_level = 14
for i=1,#cc.colors do
local c = cc.colors[i]
local h = cc.human_colors[i]
local nodedef1 = {
description = h.." abstract block",
tiles = { "colorcubes_1_"..c..".png" },
groups = { dig_immediate = 2 },
sounds = { footstep = { name = "colorcubes_block_footstep", gain = 0.5 } }
}
local nodedef_window = {
description = h.." abstract window block",
tiles = { "colorcubes_window_"..c..".png" },
inventory_image = minetest.inventorycube("colorcubes_window_"..c..".png"),
groups = { dig_immediate = 2 },
use_texture_alpha = true,
drawtype = "glasslike",
sunlight_propagates = true,
paramtype = "light",
sounds = { footstep = { name = "colorcubes_block_footstep", gain = 0.5 } }
}
local nodedef4 = {
description = h.." tiled abstract block",
tiles = { "colorcubes_4_"..c..".png" },
groups = { dig_immediate = 2 },
sounds = { footstep = { name = "colorcubes_block_footstep", gain = 0.5 } }
}
local nodedef_inward = {
description = h.." inward abstract block",
tiles = { "colorcubes_inward_"..c..".png" },
groups = { dig_immediate = 2 },
sounds = { footstep = { name = "colorcubes_block_footstep", gain = 0.5 } }
}
if light_level > 1 then
local nodedef_light = {
description = h.." abstract lamp",
tiles = { "colorcubes_light_"..c..".png" },
groups = { dig_immediate = 2 },
sounds = { footstep = { name = "colorcubes_block_footstep", gain = 0.5 } },
light_source = light_level,
}
minetest.register_node("colorcubes:"..c.."_light", nodedef_light)
light_level = light_level - 1
end
minetest.register_node("colorcubes:"..c.."_single", nodedef1)
minetest.register_node("colorcubes:"..c.."_window", nodedef_window)
minetest.register_node("colorcubes:"..c.."_tiled", nodedef4)
minetest.register_node("colorcubes:"..c.."_inward", nodedef_inward)
--[[ If the paint_roller mod is installed, register the nodes to it ]]
if(minetest.get_modpath("paint_roller") ~= nil) then
local d = cc.dyecolors[i]
paint_roller.register_one("colorcubes:"..c.."_single", d, "Simple Abstract Blocks" )
paint_roller.register_one("colorcubes:"..c.."_tiled", d, "Tiled Abstract Blocks" )
paint_roller.register_one("colorcubes:"..c.."_inward", d, "Inwardly-Patterend Abstract Blocks" )
paint_roller.register_one("colorcubes:"..c.."_window", d, "Abstract Window Block" )
end
minetest.register_craft({
output = "colorcubes:"..c.."_tiled",
recipe = {
{"colorcubes:"..c.."_single", "colorcubes:"..c.."_single" },
{"colorcubes:"..c.."_single", "colorcubes:"..c.."_single" },
},
})
minetest.register_craft({
output = "colorcubes:"..c.."_inward",
recipe = {
{"colorcubes:"..c.."_single", "colorcubes:"..c.."_single", "colorcubes:"..c.."_single" },
{"colorcubes:"..c.."_single", "", "colorcubes:"..c.."_single" },
{"colorcubes:"..c.."_single", "colorcubes:"..c.."_single", "colorcubes:"..c.."_single" },
},
})
minetest.register_craft({
output = "colorcubes:"..c.."_single 8",
recipe = {
{"colorcubes:"..c.."_inward" }
},
})
minetest.register_craft({
output = "colorcubes:"..c.."_single 4",
recipe = {
{"colorcubes:"..c.."_tiled" }
},
})
end
local complementary = { { "yellow", "blue"}, {"aqua", "redviolet"}, {"red", "cyan"}, {"light_gray", "dark_gray"}, {"green", "magenta"}, {"orange", "skyblue"}, {"lime", "violet"}, {"black", "white"}, {"orange", "brown"} }
local complementary_names = { "yellow/blue tiled abstract block", "aqua/red-violet tiled abstract block", "red/cyan tiled abstract block", "light/dark gray tiled abstract block", "green/magenta tiled abstract block", "orange/skyblue tiled abstract block", "lime/violet tiled abstract block", "black/white tiled abstract block", "orange/brown tiled abstract block" }
for i=1,#complementary do
local c1, c2
c1 = complementary[i][1]
c2 = complementary[i][2]
local nodeid = "colorcubes:"..c1.."_"..c2.."_tiled"
local tex = "colorcubes_4c_"..c1.."_"..c2..".png"
local texR90 = tex .. "^[transformR90"
minetest.register_node(nodeid, {
description = complementary_names[i],
tiles = { tex, tex, tex, tex, texR90, texR90 },
groups = { dig_immediate = 2 },
sounds = { footstep = { name = "colorcubes_block_footstep", gain = 0.5 } }
})
minetest.register_craft({
output = nodeid,
recipe = {
{"colorcubes:"..c1.."_single", "colorcubes:"..c2.."_single" },
{"colorcubes:"..c2.."_single", "colorcubes:"..c1.."_single" },
},
})
minetest.register_craft({
output = nodeid,
recipe = {
{"colorcubes:"..c2.."_single", "colorcubes:"..c1.."_single" },
{"colorcubes:"..c1.."_single", "colorcubes:"..c2.."_single" },
},
})
end