summaryrefslogtreecommitdiff
path: root/castle_gates/gates.lua
blob: ce471760db73661d94effa0aa28e092b8fcdda0c (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
-- internationalization boilerplate
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua")

minetest.register_alias("castle_gates:gate_edge",				"castle_gates:wood_gate_edge")
minetest.register_alias("castle_gates:gate_edge_handle",		"castle_gates:wood_gate_edge_handle")
minetest.register_alias("castle_gates:gate_hinge",				"castle_gates:wood_gate_hinge")
minetest.register_alias("castle_gates:gate_panel",				"castle_gates:wood_gate_panel")
minetest.register_alias("castle_gates:portcullis_bars",			"castle_gates:wood_portcullis_bars")
minetest.register_alias("castle_gates:portcullis_bars_bottom",	"castle_gates:wood_portcullis_bars_bottom")

local register_gates = function(node_prefix, material_description, material_texture, gate_groups, gate_sounds, portcullis_recipe, panel_recipe)

local portcullis_groups = {castle_gate = 1, flow_through = 1}
local panel_groups = {castle_gate = 1}
for group, val in pairs(gate_groups) do
	portcullis_groups[group] = val
	panel_groups[group] = val
end

minetest.register_node("castle_gates:"..node_prefix.."_portcullis_bars", {
	drawtype = "nodebox",
	description = S("@1 Portcullis Bars", material_description),
	_doc_items_longdesc = castle_gates.doc.portcullis_bars_longdesc,
	_doc_items_usagehelp = castle_gates.doc.portcullis_bars_usagehelp,
	groups = portcullis_groups,
	tiles = {
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		},
	sounds = gate_sounds,
	paramtype = "light",
	paramtype2 = "facedir",
	node_box = {
		type = "fixed",
		fixed = {
			{-0.125, -0.5, -0.5, 0.125, 0.5, -0.25}, -- middle bar
			{-0.5, -0.5, -0.5, -0.375, 0.5, -0.25}, -- side bar
			{0.375, -0.5, -0.5, 0.5, 0.5, -0.25}, -- side bar
			{-0.375, 0.1875, -0.4375, 0.375, 0.3125, -0.3125}, -- crosspiece
			{-0.375, -0.3125, -0.4375, 0.375, -0.1875, -0.3125}, -- crosspiece
		}
	},
	on_rightclick = castle_gates.trigger_gate,
})

minetest.register_node("castle_gates:"..node_prefix.."_portcullis_bars_bottom", {
	drawtype = "nodebox",
	description = S("@1 Portcullis Bottom", material_description),
	_doc_items_longdesc = castle_gates.doc.portcullis_bars_bottom_longdesc,
	_doc_items_usagehelp = castle_gates.doc.portcullis_bars_bottom_usagehelp,
	groups = portcullis_groups,
	tiles = {
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_portcullis_mask.png)",
		},
	sounds = gate_sounds,
	paramtype = "light",
	paramtype2 = "facedir",
		node_box = {
		type = "fixed",
		fixed = {
			{-0.125, -0.5, -0.5, 0.125, 0.5, -0.25}, -- middle bar
			{-0.5, -0.5, -0.5, -0.375, 0.5, -0.25}, -- side bar
			{0.375, -0.5, -0.5, 0.5, 0.5, -0.25}, -- side bar
			{-0.375, 0.1875, -0.4375, 0.375, 0.3125, -0.3125}, -- crosspiece
			{-0.375, -0.3125, -0.4375, 0.375, -0.1875, -0.3125}, -- crosspiece
			{-0.0625, -0.5, -0.4375, 0.0625, -0.625, -0.3125}, -- peg
			{0.4375, -0.5, -0.4375, 0.5, -0.625, -0.3125}, -- peg
			{-0.5, -0.5, -0.4375, -0.4375, -0.625, -0.3125}, -- peg
		}
	},
	_gate_edges = {bottom=true},
	on_rightclick = castle_gates.trigger_gate,
})

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_portcullis_bars 3",
	recipe = portcullis_recipe,
})

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_portcullis_bars",
	recipe = {
		{"castle_gates:"..node_prefix.."_portcullis_bars_bottom"}
	},
})

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_portcullis_bars_bottom",
	recipe = {
		{"castle_gates:"..node_prefix.."_portcullis_bars"}
	},
})

--------------------------------------------------------------------------------------------------------------

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_gate_panel 8",
	recipe = panel_recipe,
})

minetest.register_node("castle_gates:"..node_prefix.."_gate_panel", {
	drawtype = "nodebox",
	description = S("@1 Gate Door", material_description),
	_doc_items_longdesc = castle_gates.doc.gate_panel_longdesc,
	_doc_items_usagehelp = castle_gates.doc.gate_panel_usagehelp,
	groups = panel_groups,
	tiles = {
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		},
	sounds = gate_sounds,
	paramtype = "light",
	paramtype2 = "facedir",
		node_box = {
		type = "fixed",
		fixed = {
			{-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
		}
	},
	on_rightclick = castle_gates.trigger_gate,
})

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_gate_edge",
	type = "shapeless",
	recipe = {"castle_gates:"..node_prefix.."_gate_panel"},
})

minetest.register_node("castle_gates:"..node_prefix.."_gate_edge", {
	drawtype = "nodebox",
	description = S("@1 Gate Door Edge", material_description),
	_doc_items_longdesc = castle_gates.doc.gate_edge_longdesc,
	_doc_items_usagehelp = castle_gates.doc.gate_edge_usagehelp,
	groups = panel_groups,
	tiles = {
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90",
		material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png^[transformFX)",
		material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png)",
		},
	sounds = gate_sounds,
	paramtype = "light",
	paramtype2 = "facedir",
		node_box = {
		type = "fixed",
		fixed = {
			{-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
		}
	},
	_gate_edges = {right=true},
	on_rightclick = castle_gates.trigger_gate,
})

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_gate_edge_handle",
	type = "shapeless",
	recipe = {"castle_gates:"..node_prefix.."_gate_edge"},
})

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_gate_panel",
	type = "shapeless",
	recipe = {"castle_gates:"..node_prefix.."_gate_edge_handle"},
})

minetest.register_node("castle_gates:"..node_prefix.."_gate_edge_handle", {
	drawtype = "nodebox",
	description = S("@1 Gate Door With Handle", material_description),
	_doc_items_longdesc = castle_gates.doc.gate_edge_handle_longdesc,
	_doc_items_usagehelp = castle_gates.doc.gate_edge_handle_usagehelp,
	groups = panel_groups,
	tiles = {
		"castle_steel.png^("..material_texture.."^[mask:castle_door_side_mask.png^[transformR90)",
		"castle_steel.png^("..material_texture.."^[mask:castle_door_side_mask.png^[transformR270)",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:castle_door_side_mask.png)",
		"castle_steel.png^("..material_texture.."^[transformR90^[mask:(castle_door_side_mask.png^[transformFX))",
		material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png^[transformFX)^(castle_steel.png^[mask:castle_door_handle_mask.png^[transformFX)",
		material_texture.."^[transformR90^(default_coal_block.png^[mask:castle_door_edge_mask.png)^(castle_steel.png^[mask:castle_door_handle_mask.png)",
		},
	sounds = gate_sounds,
	paramtype = "light",
	paramtype2 = "facedir",
		node_box = {
		type = "fixed",
		fixed = {
			{-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
			{4/16, -4/16, -2/16, 6/16, 4/16, -3/16},
			{4/16, -4/16, -9/16, 6/16, 4/16, -10/16},
			{4/16, -4/16, -9/16, 6/16, -3/16, -3/16},
			{4/16, 4/16, -9/16, 6/16, 3/16, -3/16},
		}
	},
	_gate_edges = {right=true},
	on_rightclick = castle_gates.trigger_gate,
})


------------------------------------------------------------------------------

minetest.register_craft({
	output = "castle_gates:"..node_prefix.."_gate_hinge 3",
	recipe = {
		{"", "castle_gates:"..node_prefix.."_gate_panel", ""},
		{"default:steel_ingot", "castle_gates:"..node_prefix.."_gate_panel", ""},
		{"", "castle_gates:"..node_prefix.."_gate_panel", ""}
	},
})

minetest.register_node("castle_gates:"..node_prefix.."_gate_hinge", {
	drawtype = "nodebox",
	description = S("@1 Gate Door With Hinge", material_description),
	_doc_items_longdesc = castle_gates.doc.gate_hinge_longdesc,
	_doc_items_usagehelp = castle_gates.doc.gate_hinge_usagehelp,
	groups = panel_groups,
	tiles = {
		material_texture.."^[transformR90",
		},
	sounds = gate_sounds,
	paramtype = "light",
	paramtype2 = "facedir",
	
	node_box = {
		type = "fixed",
		fixed = {
			{-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
			{-10/16, -4/16, -10/16, -6/16, 4/16, -6/16},
		}
	},
	collision_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, -0.25},
	},
	
	_gate_hinge = {axis="top", offset={"front","left"}},
	on_rightclick = castle_gates.trigger_gate,
})

end

register_gates("wood", S("Wooden"), "default_wood.png", {choppy = 1}, default.node_sound_wood_defaults(),
	{
		{"group:wood","default:steel_ingot","group:wood" },
		{"group:wood","default:steel_ingot","group:wood" },
		{"group:wood","default:steel_ingot","group:wood" },
	},
	{
		{"stairs:slab_wood","stairs:slab_wood", ""},
		{"stairs:slab_wood","stairs:slab_wood", ""},
	}
)

register_gates("steel", S("Steel"), "default_steel_block.png", {cracky = 1, level = 2}, default.node_sound_metal_defaults(),
	{
		{"","default:steel_ingot","" },
		{"default:steel_ingot","default:steel_ingot","default:steel_ingot" },
		{"","default:steel_ingot","" },
	},
	{
		{"stairs:slab_steelblock","stairs:slab_steelblock", ""},
		{"stairs:slab_steelblock","stairs:slab_steelblock", ""},
	}
)