summaryrefslogtreecommitdiff
path: root/castle_masonry/pillars.lua
blob: 96d76a30e5aaf9973252f88ae15c6d5093890fc8 (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
302
303
304
305
306
307
308
309
310
311
312
313
314
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")

castle_masonry.register_pillar = function(material)
	local composition_def, burn_time, tile, desc = castle_masonry.get_material_properties(material)
	local crossbrace_connectable_groups = {}
	for group, val in pairs(composition_def.groups) do
		crossbrace_connectable_groups[group] = val
	end	
	crossbrace_connectable_groups.crossbrace_connectable = 1

	local mod_name = minetest.get_current_modname()
	
	-- Node Definition
	minetest.register_node(mod_name..":pillar_"..material.name.."_bottom", {
		drawtype = "nodebox",
		description = S("@1 Pillar Base", desc),
		tiles = tile,
		groups = crossbrace_connectable_groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.5,-0.5,-0.5,0.5,-0.375,0.5},
				{-0.375,-0.375,-0.375,0.375,-0.125,0.375},
				{-0.25,-0.125,-0.25,0.25,0.5,0.25}, 
			},
		},
	})

	minetest.register_node(mod_name..":pillar_"..material.name.."_bottom_half", {
		drawtype = "nodebox",
		description = S("@1 Half Pillar Base", desc),
		tiles = tile,
		groups = composition_def.groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.5, -0.5, 0, 0.5, -0.375, 0.5},
				{-0.375, -0.375, 0.125, 0.375, -0.125, 0.5},
				{-0.25, -0.125, 0.25, 0.25, 0.5, 0.5},
			},
		},
	})
	
	minetest.register_node(mod_name..":pillar_"..material.name.."_top", {
		drawtype = "nodebox",
		description = S("@1 Pillar Top", desc),
		tiles = tile,
		groups = crossbrace_connectable_groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.5,0.3125,-0.5,0.5,0.5,0.5}, 
				{-0.375,0.0625,-0.375,0.375,0.3125,0.375}, 
				{-0.25,-0.5,-0.25,0.25,0.0625,0.25},
			},
		},
	})

	minetest.register_node(mod_name..":pillar_"..material.name.."_top_half", {
		drawtype = "nodebox",
		description = S("@1 Half Pillar Top", desc),
		tiles = tile,
		groups = composition_def.groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.5, 0.3125, 0, 0.5, 0.5, 0.5},
				{-0.375, 0.0625, 0.125, 0.375, 0.3125, 0.5},
				{-0.25, -0.5, 0.25, 0.25, 0.0625, 0.5},
			},
		},
	})	

	minetest.register_node(mod_name..":pillar_"..material.name.."_middle", {
		drawtype = "nodebox",
		description = S("@1 Pillar Middle", desc),
		tiles = tile,
		groups = crossbrace_connectable_groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.25,-0.5,-0.25,0.25,0.5,0.25},
			},
		},
	})

	minetest.register_node(mod_name..":pillar_"..material.name.."_middle_half", {
		drawtype = "nodebox",
		description = S("@1 Half Pillar Middle", desc),
		tiles = tile,
		groups = composition_def.groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "fixed",
			fixed = {
				{-0.25, -0.5, 0.25, 0.25, 0.5, 0.5},
			},
		},
	})
	
	minetest.register_node(mod_name..":pillar_"..material.name.."_crossbrace",
	{
		drawtype = "nodebox",
		description = S("@1 Crossbrace", desc),
		tiles = tile,
		groups = composition_def.groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "connected",
			fixed = {-0.25,0.25,-0.25,0.25,0.5,0.25},
			connect_front = {-0.25,0.25,-0.75,0.25,0.5,-0.25}, -- -Z
			connect_left = {-0.25,0.25,-0.25,-0.75,0.5,0.25}, -- -X
			connect_back = {-0.25,0.25,0.25,0.25,0.5,0.75}, -- +Z
			connect_right = {0.25,0.25,-0.25,0.75,0.5,0.25}, -- +X
		},
		connects_to = {
			mod_name..":pillar_"..material.name.."_crossbrace",
			mod_name..":pillar_"..material.name.."_extended_crossbrace",
			"group:crossbrace_connectable"},
		connect_sides = { "front", "left", "back", "right" },
	})
	
	minetest.register_node(mod_name..":pillar_"..material.name.."_extended_crossbrace",
	{
		drawtype = "nodebox",
		description = S("@1 Extended Crossbrace", desc),
		tiles = tile,
		groups = composition_def.groups,
		sounds = composition_def.sounds,
		paramtype = "light",
		paramtype2 = "facedir",
		node_box = {
			type = "fixed",
			fixed = {-1.25,0.25,-0.25,1.25,0.5,0.25},
		},
	})
	
	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_bottom 4",
		recipe = {
			{"",material.craft_material,""},
			{"",material.craft_material,""},
			{material.craft_material,material.craft_material,material.craft_material} },
	})

	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_top 4",
		recipe = {
			{material.craft_material,material.craft_material,material.craft_material},
			{"",material.craft_material,""},
			{"",material.craft_material,""} },
	})

	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_middle 4",
		recipe = {
			{material.craft_material,material.craft_material},
			{material.craft_material,material.craft_material},
			{material.craft_material,material.craft_material} },
	})
	
	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_crossbrace 10",
		recipe = {
			{material.craft_material,"",material.craft_material},
			{"",material.craft_material,""},
			{material.craft_material,"",material.craft_material} },
	})
	
	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_middle_half 2",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_middle"},
	})
	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_middle",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_middle_half", mod_name..":pillar_"..material.name.."_middle_half"},
	})

	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_top_half 2",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_top"},
	})
	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_top",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_top_half", mod_name..":pillar_"..material.name.."_top_half"},
	})

	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_bottom_half 2",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_bottom"},
	})
	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_bottom",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_bottom_half", mod_name..":pillar_"..material.name.."_bottom_half"},
	})
	
	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_extended_crossbrace",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_crossbrace"},
	})

	minetest.register_craft({
		output = mod_name..":pillar_"..material.name.."_crossbrace",
		type="shapeless",
		recipe = {mod_name..":pillar_"..material.name.."_extended_crossbrace"},
	})
	
	if burn_time > 0 then
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_top",
			burntime = burn_time*5/4,
		})	
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_top_half",
			burntime = burn_time*5/8,
		})
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_bottom",
			burntime = burn_time*5/4,
		})	
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_bottom_half",
			burntime = burn_time*5/8,
		})	
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_middle",
			burntime = burn_time*6/4,
		})
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_middle_half",
			burntime = burn_time*6/8,
		})
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_crossbrace",
			burntime = burn_time*5/10,
		})
		minetest.register_craft({
			type = "fuel",
			recipe = mod_name..":pillar_"..material.name.."_extended_crossbrace",
			burntime = burn_time*5/10,
		})
	end
	
end

-- The original castle mod had "pillars_", plural, which didn't match the arrowslit and murderhole standard.
castle_masonry.register_pillar_alias = function(old_mod_name, old_material_name, new_mod_name, new_material_name)
	minetest.register_alias(old_mod_name..":pillars_"..old_material_name.."_bottom",		new_mod_name..":pillar_"..new_material_name.."_bottom")
	minetest.register_alias(old_mod_name..":pillars_"..old_material_name.."_bottom_half",	new_mod_name..":pillar_"..new_material_name.."_bottom_half")
	minetest.register_alias(old_mod_name..":pillars_"..old_material_name.."_crossbrace",	new_mod_name..":pillar_"..new_material_name.."_crossbrace")
	minetest.register_alias(old_mod_name..":pillars_"..old_material_name.."_middle",		new_mod_name..":pillar_"..new_material_name.."_middle")
	minetest.register_alias(old_mod_name..":pillars_"..old_material_name.."_middle_half",	new_mod_name..":pillar_"..new_material_name.."_middle_half")
	minetest.register_alias(old_mod_name..":pillars_"..old_material_name.."_top",			new_mod_name..":pillar_"..new_material_name.."_top")
	minetest.register_alias(old_mod_name..":pillars_"..old_material_name.."_top_half",		new_mod_name..":pillar_"..new_material_name.."_top_half")
	minetest.register_alias(old_mod_name..":pillar_"..old_material_name.."_bottom",			new_mod_name..":pillar_"..new_material_name.."_bottom")
	minetest.register_alias(old_mod_name..":pillar_"..old_material_name.."_bottom_half",	new_mod_name..":pillar_"..new_material_name.."_bottom_half")
	minetest.register_alias(old_mod_name..":pillar_"..old_material_name.."_crossbrace",		new_mod_name..":pillar_"..new_material_name.."_crossbrace")
	minetest.register_alias(old_mod_name..":pillar_"..old_material_name.."_middle",			new_mod_name..":pillar_"..new_material_name.."_middle")
	minetest.register_alias(old_mod_name..":pillar_"..old_material_name.."_middle_half",	new_mod_name..":pillar_"..new_material_name.."_middle_half")
	minetest.register_alias(old_mod_name..":pillar_"..old_material_name.."_top",			new_mod_name..":pillar_"..new_material_name.."_top")
	minetest.register_alias(old_mod_name..":pillar_"..old_material_name.."_top_half",		new_mod_name..":pillar_"..new_material_name.."_top_half")
end

castle_masonry.register_arrowslit_alias_force = function(old_mod_name, old_material_name, new_mod_name, new_material_name)
	minetest.register_alias_force(old_mod_name..":pillars_"..old_material_name.."_bottom",		new_mod_name..":pillar_"..new_material_name.."_bottom")
	minetest.register_alias_force(old_mod_name..":pillars_"..old_material_name.."_bottom_half",	new_mod_name..":pillar_"..new_material_name.."_bottom_half")
	minetest.register_alias_force(old_mod_name..":pillars_"..old_material_name.."_crossbrace",	new_mod_name..":pillar_"..new_material_name.."_crossbrace")
	minetest.register_alias_force(old_mod_name..":pillars_"..old_material_name.."_middle",		new_mod_name..":pillar_"..new_material_name.."_middle")
	minetest.register_alias_force(old_mod_name..":pillars_"..old_material_name.."_middle_half",	new_mod_name..":pillar_"..new_material_name.."_middle_half")
	minetest.register_alias_force(old_mod_name..":pillars_"..old_material_name.."_top",			new_mod_name..":pillar_"..new_material_name.."_top")
	minetest.register_alias_force(old_mod_name..":pillars_"..old_material_name.."_top_half",	new_mod_name..":pillar_"..new_material_name.."_top_half")
	minetest.register_alias_force(old_mod_name..":pillar_"..old_material_name.."_bottom",		new_mod_name..":pillar_"..new_material_name.."_bottom")
	minetest.register_alias_force(old_mod_name..":pillar_"..old_material_name.."_bottom_half",	new_mod_name..":pillar_"..new_material_name.."_bottom_half")
	minetest.register_alias_force(old_mod_name..":pillar_"..old_material_name.."_crossbrace",	new_mod_name..":pillar_"..new_material_name.."_crossbrace")
	minetest.register_alias_force(old_mod_name..":pillar_"..old_material_name.."_middle",		new_mod_name..":pillar_"..new_material_name.."_middle")
	minetest.register_alias_force(old_mod_name..":pillar_"..old_material_name.."_middle_half",	new_mod_name..":pillar_"..new_material_name.."_middle_half")
	minetest.register_alias_force(old_mod_name..":pillar_"..old_material_name.."_top",			new_mod_name..":pillar_"..new_material_name.."_top")
	minetest.register_alias_force(old_mod_name..":pillar_"..old_material_name.."_top_half",		new_mod_name..":pillar_"..new_material_name.."_top_half")
end