2 cc
.colors
= { "white", "yellow", "orange", "red", "redviolet", "magenta", "violet", "blue", "skyblue", "cyan", "aqua", "green", "lime", "pink", "brown", "dark_green", "light_gray", "dark_gray", "black" }
4 white
= "unicolor_white", yellow
= "unicolor_yellow", orange
= "unicolor_orange", red
= "unicolor_red", redviolet
= "unicolor_red_violet", magenta
= "unicolor_magenta", violet
= "unicolor_violet", blue
= "unicolor_blue", skyblue
= "unicolor_sky_blue", cyan
= "unicolor_cyan", aqua
= "unicolor_aqua", green
= "unicolor_green", lime
= "unicolor_lime", pink
= "unicolor_light_red", brown
= "unicolor_dark_orange", dark_green
= "unicolor_dark_green", light_gray
= "unicolor_grey", dark_gray
= "unicolor_darkgrey", black
= "unicolor_black" }
5 cc
.human_colors
= { white
= "white", yellow
= "yellow", orange
= "orange", red
= "red", redviolet
= "red-violet", magenta
= "magenta", violet
= "violet", blue
= "blue", skyblue
= "skyblue", cyan
= "cyan", aqua
= "aqua", green
= "green", lime
= "lime", pink
= "pink", brown
= "brown", dark_green
= "dark green", light_gray
= "light gray", dark_gray
= "dark gray", black
= "black" }
9 local soundmaker
= function (mod)
10 if stepgain
== nil then stepgain
= 0 end
12 local scrub
= function(value
)
13 return math
.min(1, math
.max(value
, 0))
16 return { footstep
= { name
= "colorcubes_block_footstep", gain
= scrub(0.25 + mod) },
17 dig
= { name
= "colorcubes_block_dig", gain
= scrub(1) },
18 dug
= { name
= "colorcubes_block_dug", gain
= scrub(0.7 + mod) },
19 place
= { name
= "colorcubes_block_place", gain
= 0.5 }, }
23 local c
= cc
.colors
[i
]
24 local h
= cc
.human_colors
[c
]
25 local d
= cc
.dye_colors
[c
]
26 -- Blocks with a simple square pattern
28 description
= h
.." basic color cube",
29 tiles
= { "colorcubes_1_"..c
..".png" },
30 groups
= { dig_immediate
= 2 },
31 sounds
= soundmaker(0),
33 minetest
.register_node("colorcubes:"..c
.."_single", nodedef1
)
35 local nodedef_window
= {
36 description
= h
.." window color cube",
37 tiles
= { "colorcubes_window_"..c
..".png" },
38 inventory_image
= minetest
.inventorycube("colorcubes_window_"..c
..".png"),
39 groups
= { dig_immediate
= 2 },
40 use_texture_alpha
= true,
41 drawtype
= "glasslike",
42 sunlight_propagates
= true,
44 sounds
= soundmaker(-0.1),
46 minetest
.register_node("colorcubes:"..c
.."_window", nodedef_window
)
47 -- Blocks with a tile pattern (4 tiles)
49 description
= h
.." tiled color cube",
50 tiles
= { "colorcubes_4_"..c
..".png" },
51 groups
= { dig_immediate
= 2 },
52 sounds
= soundmaker(0.1),
54 minetest
.register_node("colorcubes:"..c
.."_tiled", nodedef4
)
55 -- Blocks with a concentric square pattern
56 local nodedef_inward
= {
57 description
= h
.." concentric color cube",
58 tiles
= { "colorcubes_inward_"..c
..".png" },
59 groups
= { dig_immediate
= 2 },
60 sounds
= soundmaker(0.15),
62 minetest
.register_node("colorcubes:"..c
.."_inward", nodedef_inward
)
63 -- Lamps in different brightness levels
64 if light_level
> 1 then
65 local nodedef_light
= {
66 description
= h
.." light color cube",
67 tiles
= { "colorcubes_light_"..c
..".png" },
68 groups
= { dig_immediate
= 2 },
69 sounds
= soundmaker(-0.05),
70 light_source
= light_level
,
72 minetest
.register_node("colorcubes:"..c
.."_light", nodedef_light
)
73 if(minetest
.get_modpath("paint_roller") ~= nil) then
74 paint_roller
.register_one("colorcubes:"..c
.."_light", d
, "light color cubes" )
76 light_level
= light_level
- 1
79 --[[ If the paint_roller mod is installed, register the nodes to it ]]
80 if(minetest
.get_modpath("paint_roller") ~= nil) then
81 paint_roller
.register_one("colorcubes:"..c
.."_single", d
, "basic color cubes" )
82 paint_roller
.register_one("colorcubes:"..c
.."_tiled", d
, "tiled color cubes" )
83 paint_roller
.register_one("colorcubes:"..c
.."_inward", d
, "concentric color cubes" )
84 paint_roller
.register_one("colorcubes:"..c
.."_window", d
, "window color cubes" )
87 -- Register various crafting recipes for convenience
88 minetest
.register_craft({
89 output
= "colorcubes:"..c
.."_tiled",
91 {"colorcubes:"..c
.."_single", "colorcubes:"..c
.."_single" },
92 {"colorcubes:"..c
.."_single", "colorcubes:"..c
.."_single" },
95 minetest
.register_craft({
96 output
= "colorcubes:"..c
.."_inward",
98 {"colorcubes:"..c
.."_single", "colorcubes:"..c
.."_single", "colorcubes:"..c
.."_single" },
99 {"colorcubes:"..c
.."_single", "", "colorcubes:"..c
.."_single" },
100 {"colorcubes:"..c
.."_single", "colorcubes:"..c
.."_single", "colorcubes:"..c
.."_single" },
103 minetest
.register_craft({
104 output
= "colorcubes:"..c
.."_single 8",
106 {"colorcubes:"..c
.."_inward" }
109 minetest
.register_craft({
110 output
= "colorcubes:"..c
.."_single 4",
112 {"colorcubes:"..c
.."_tiled" }
118 --[[ Tiled blocks with 2 differend colors (usuall complementary colors) ]]
120 local complementary
= { { "yellow", "blue"}, {"aqua", "redviolet"}, {"red", "cyan"}, {"light_gray", "dark_gray"}, {"green", "magenta"}, {"orange", "skyblue"}, {"lime", "violet"}, {"black", "white"}, {"orange", "brown"} }
121 local complementary_names
= { "yellow/blue tiled color cube", "aqua/red-violet tiled color cube", "red/cyan tiled color cube", "light/dark gray tiled color cube", "green/magenta tiled color cube", "orange/skyblue tiled color cube", "lime/violet tiled color cube", "black/white tiled color cube", "orange/brown tiled color cube" }
123 for i
=1,#complementary
do
125 c1
= complementary
[i
][1]
126 c2
= complementary
[i
][2]
127 local nodeid
= "colorcubes:"..c1
.."_"..c2
.."_tiled"
128 local tex
= "colorcubes_4c_"..c1
.."_"..c2
..".png"
129 local texR90
= tex
.. "^[transformR90"
130 minetest
.register_node(nodeid
, {
131 description
= complementary_names
[i
],
132 tiles
= { tex
, tex
, tex
, tex
, texR90
, texR90
},
133 groups
= { dig_immediate
= 2 },
134 sounds
= soundmaker(0.1),
137 minetest
.register_craft({
140 {"colorcubes:"..c1
.."_single", "colorcubes:"..c2
.."_single" },
141 {"colorcubes:"..c2
.."_single", "colorcubes:"..c1
.."_single" },
144 minetest
.register_craft({
147 {"colorcubes:"..c2
.."_single", "colorcubes:"..c1
.."_single" },
148 {"colorcubes:"..c1
.."_single", "colorcubes:"..c2
.."_single" },
152 --[[ This register the block to the paint roller mod. Note that this block can
153 only be painted, but it can not be reversed; it will not be possible to paint a
154 tiled block so that it becomes a 2-color block. Thus, we use minor hack by using
155 a fake dye group called “none” to make sure there is no dye to turn a tiled block
156 into a 2-color tiled block. ]]
157 paint_roller
.register_one(nodeid
, "none", "tiled color cubes" )