summaryrefslogtreecommitdiff
path: root/coloredwood/fence.lua
blob: fd6c31255d5a3929c6c6397e0696634f2160701e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
-- Fences portion of Colored Wood mod by Vanessa Ezekowitz  ~~  2012-07-17
-- based on my unified dyes modding template.
--
-- License: WTFPL

local colored_block_modname = "coloredwood"
local colored_block_description = "Wooden Fence"
local neutral_block = "default:fence_wood"
local colored_block_sunlight = "false"
local colored_block_walkable = "true"
local colored_block_groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2, not_in_creative_inventory=1}
local colored_block_sound = "default.node_sound_wood_defaults()"

for shade = 1, 3 do

	local shadename = coloredwood.shades[shade]
	local shadename2 = coloredwood.shades2[shade]

	for hue = 1, 12 do

		local huename = coloredwood.hues[hue]
		local huename2 = coloredwood.hues2[hue]

		local colorname     = colored_block_modname..":fence_"..shadename..huename
		local pngnameinv    = colored_block_modname.."_fence_"..shadename..huename..".png"
		local pngname       = colored_block_modname.."_wood_"..shadename..huename..".png"
		local nodedesc      = shadename2..huename2..colored_block_description
		local stickname     = colored_block_modname..":stick_"..shadename..huename

		local s50colorname  = colored_block_modname..":fence_"..shadename..huename.."_s50"
		local s50pngname    = colored_block_modname.."_wood_"..shadename..huename.."_s50.png"
		local s50pngnameinv = colored_block_modname.."_fence_"..shadename..huename.."_s50.png"
		local s50nodedesc   = shadename2..huename2..colored_block_description.." (50% Saturation)"
		local s50stickname  = colored_block_modname..":stick_"..shadename..huename.."_s50"

		minetest.register_node(colorname, {
			drawtype = "fencelike",
			description = nodedesc,
			tiles = { pngname },
			inventory_image = pngnameinv, 
			wield_image = pngnameinv,
			sunlight_propagates = colored_block_sunlight,
			paramtype = "light",
			walkable = colored_block_walkable,
			groups = colored_block_groups,
			sounds = colored_block_sound,
			selection_box = {
				type = "fixed",
				fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
			},
		})

		minetest.register_node(s50colorname, {
			drawtype = "fencelike",
			description = s50nodedesc,
			tiles = { s50pngname },
			inventory_image = s50pngnameinv, 
			wield_image = s50pngnameinv,
			sunlight_propagates = colored_block_sunlight,
			paramtype = "light",
			walkable = colored_block_walkable,
			groups = colored_block_groups,
			sounds = colored_block_sound,
			selection_box = {
				type = "fixed",
				fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
			},
		})

		minetest.register_craft({
		        type = "fuel",
		        recipe = colorname,
		        burntime = 7,
		})

		minetest.register_craft({
		        type = "fuel",
		        recipe = s50colorname,
		        burntime = 7,
		})

		minetest.register_craft({
		        output = colorname.." 2" ,
		        recipe = {
		                {stickname, stickname, stickname },
		                {stickname, stickname, stickname }
		        }
		})

		minetest.register_craft({
		        output = s50colorname.." 2",
		        recipe = {
		                {s50stickname, s50stickname, s50stickname },
		                {s50stickname, s50stickname, s50stickname }
		        }
		})

		minetest.register_craft({
		        output = colorname.." 2",
			recipe = {
				{ "unifieddyes:"..shadename..huename, "", "" },
		                {"group:stick", "group:stick", "group:stick"},
		                {"group:stick", "group:stick", "group:stick"},
		        },
		})

		minetest.register_craft({
		        output = s50colorname.." 2",
			recipe = {
				{ "unifieddyes:"..shadename..huename.."_s50", "", "" },
		                {"group:stick", "group:stick", "group:stick"},
		                {"group:stick", "group:stick", "group:stick"},
		        },
		})

		minetest.register_craft( {
			type = "shapeless",
			output = colorname.." 2",
			recipe = {
				neutral_block,
				neutral_block,
				"unifieddyes:"..shadename..huename
			},
		})

		minetest.register_craft( {
			type = "shapeless",
			output = colorname.." 2",
			recipe = {
				neutral_block,
				neutral_block,
				"unifieddyes:"..shadename..huename.."_s50"
			},
		})

	end
end

-- Generate the "light" shades separately, since they don"t have a low-sat version.

for hue = 1, 12 do
	local huename = coloredwood.hues[hue]
	local huename2 = coloredwood.hues2[hue]
	local colorname    = colored_block_modname..":fence_light_"..huename
	local pngname      = colored_block_modname.."_wood_light_"..huename..".png"
	local pngnameinv   = colored_block_modname.."_fence_light_"..huename..".png"
	local nodedesc     = "Light "..huename2..colored_block_description
	local stickname    = colored_block_modname..":stick_light_"..huename

	minetest.register_node(colorname, {
		drawtype = "fencelike",
		description = nodedesc,
		tiles = { pngname },
		inventory_image = pngnameinv, 
		wield_image = pngnameinv,
		sunlight_propagates = colored_block_sunlight,
		paramtype = "light",
		walkable = colored_block_walkable,
		groups = colored_block_groups,
		sounds = colored_block_sound,
		selection_box = {
			type = "fixed",
			fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
		},
	})

	minetest.register_craft({
	        type = "fuel",
	        recipe = colorname,
	        burntime = 7,
	})

	minetest.register_craft({
	        output = colorname.." 2",
	        recipe = {
	                {stickname, stickname, stickname },
	                {stickname, stickname, stickname }
	        }
	})

	minetest.register_craft({
	        output = colorname.." 2",
		recipe = {
			{ "unifieddyes:light_"..huename, "", "" },
	                {"group:stick", "group:stick", "group:stick"},
	                {"group:stick", "group:stick", "group:stick"},
	        },
	})

	minetest.register_craft( {
		type = "shapeless",
		output = colorname.." 2",
		recipe = {
			neutral_block,
			neutral_block,
			"unifieddyes:light_"..huename
		},
	})
end

-- extra recipes for default dye colors.

for _, color in ipairs(coloredwood.default_hues) do
	minetest.register_craft({
		output = "coloredwood:fence_"..color.." 2",
		recipe = {
			{ "dye:"..color, "", "" },
			{"group:stick", "group:stick", "group:stick"},
			{"group:stick", "group:stick", "group:stick"},
		},
	})
end

minetest.register_craft({
	output = "coloredwood:fence_light_red 2",
	recipe = {
		{ "dye:pink", "", "" },
		{"group:stick", "group:stick", "group:stick"},
		{"group:stick", "group:stick", "group:stick"},
	},
})

minetest.register_craft({
	output = "coloredwood:fence_dark_orange 2",
	recipe = {
		{ "dye:brown", "", "" },
		{"group:stick", "group:stick", "group:stick"},
		{"group:stick", "group:stick", "group:stick"},
	},
})

-- ============================================================
-- The 5 levels of greyscale.
--
-- Oficially these are 0, 25, 50, 75, and 100% relative to white,
-- but in practice, they"re actually 7.5%, 25%, 50%, 75%, and 95%.
-- (otherwise black and white would wash out).

for grey = 1,5 do

	local greyname = coloredwood.greys[grey]
	local greyname2 = coloredwood.greys2[grey]
	local greyname3 = coloredwood.greys3[grey]

	local greyshadename = colored_block_modname..":fence_"..greyname
	local pngname       = colored_block_modname.."_wood_"..greyname..".png"
	local pngnameinv    = colored_block_modname.."_fence_"..greyname..".png"
	local nodedesc      = greyname2..colored_block_description
	local stickname     = colored_block_modname..":stick_"..greyname

	minetest.register_node(greyshadename, {
		drawtype = "fencelike",
		description = nodedesc,
		tiles = { pngname },
		inventory_image = pngnameinv, 
		wield_image = pngnameinv,
		sunlight_propagates = colored_block_sunlight,
		paramtype = "light",
		walkable = colored_block_walkable,
		groups = colored_block_groups,
		sounds = colored_block_sound,
		selection_box = {
			type = "fixed",
			fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
		},
	})

	minetest.register_craft({
	        type = "fuel",
	        recipe = greyshadename,
	        burntime = 7,
	})

	minetest.register_craft({
	        output = greyshadename.." 2",
	        recipe = {
	                {stickname, stickname, stickname },
	                {stickname, stickname, stickname }
	        }
	})

	minetest.register_craft({
	        output = greyshadename.." 2",
		recipe = {
			{ greyname3, "", "" },
	                {"group:stick", "group:stick", "group:stick"},
	                {"group:stick", "group:stick", "group:stick"},
	        },
	})

	minetest.register_craft( {
		type = "shapeless",
		output = greyshadename.." 2",
		recipe = {
			neutral_block,
			neutral_block,
			greyname3
		},
	})

end