commit | author | age
|
82cba9
|
1 |
local chest_mark_colors = { |
R |
2 |
'_black', |
|
3 |
'_blue', |
|
4 |
'_brown', |
|
5 |
'_cyan', |
|
6 |
'_dark_green', |
|
7 |
'_dark_grey', |
|
8 |
'_green', |
|
9 |
'_grey', |
|
10 |
'_magenta', |
|
11 |
'_orange', |
|
12 |
'_pink', |
|
13 |
'_red', |
|
14 |
'_violet', |
|
15 |
'_white', |
|
16 |
'_yellow', |
|
17 |
} |
|
18 |
|
|
19 |
minetest.register_craft({ |
|
20 |
output = 'technic:gold_chest 1', |
|
21 |
recipe = { |
|
22 |
{'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, |
|
23 |
{'moreores:gold_ingot','technic:silver_chest','moreores:gold_ingot'}, |
|
24 |
{'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, |
|
25 |
} |
|
26 |
}) |
|
27 |
|
|
28 |
minetest.register_craft({ |
|
29 |
output = 'technic:gold_locked_chest 1', |
|
30 |
recipe = { |
|
31 |
{'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, |
|
32 |
{'moreores:gold_ingot','technic:silver_locked_chest','moreores:gold_ingot'}, |
|
33 |
{'moreores:gold_ingot','moreores:gold_ingot','moreores:gold_ingot'}, |
|
34 |
} |
|
35 |
}) |
|
36 |
|
|
37 |
minetest.register_craft({ |
|
38 |
output = 'technic:gold_locked_chest 1', |
|
39 |
recipe = { |
|
40 |
{'default:steel_ingot'}, |
|
41 |
{'technic:gold_chest'}, |
|
42 |
} |
|
43 |
}) |
|
44 |
|
fd3f25
|
45 |
minetest.register_craftitem(":technic:gold_chest", { |
82cba9
|
46 |
description = "Gold Chest", |
R |
47 |
stack_max = 99, |
|
48 |
}) |
fd3f25
|
49 |
minetest.register_craftitem(":technic:gold_locked_chest", { |
82cba9
|
50 |
description = "Gold Locked Chest", |
R |
51 |
stack_max = 99, |
|
52 |
}) |
|
53 |
|
|
54 |
gold_chest_formspec = "invsize[12,9;]".. |
|
55 |
"list[current_name;main;0,0;12,4;]".. |
|
56 |
"list[current_player;main;0,5;8,4;]" |
|
57 |
|
|
58 |
gold_chest_inv_size = 12*4 |
|
59 |
|
fd3f25
|
60 |
minetest.register_node(":technic:gold_chest", { |
82cba9
|
61 |
description = "Gold Chest", |
R |
62 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
63 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front.png"}, |
|
64 |
paramtype2 = "facedir", |
|
65 |
groups = chest_groups1, |
|
66 |
tube = tubes_properties, |
|
67 |
legacy_facedir_simple = true, |
|
68 |
sounds = default.node_sound_wood_defaults(), |
|
69 |
|
|
70 |
on_construct = function(pos) |
|
71 |
local meta = minetest.env:get_meta(pos) |
|
72 |
meta:set_string("formspec",gold_chest_formspec) |
|
73 |
meta:set_string("infotext", "Gold Chest") |
|
74 |
local inv = meta:get_inventory() |
|
75 |
inv:set_size("main", gold_chest_inv_size) |
|
76 |
end, |
|
77 |
|
|
78 |
can_dig = chest_can_dig, |
|
79 |
|
|
80 |
on_punch = function (pos, node, puncher) |
|
81 |
chest_punched (pos,node,puncher); |
|
82 |
end, |
|
83 |
|
|
84 |
on_receive_fields = function(pos, formname, fields, sender) |
|
85 |
local meta = minetest.env:get_meta(pos); |
|
86 |
fields.text = fields.text or "" |
|
87 |
meta:set_string("text", fields.text) |
|
88 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
89 |
meta:set_string("formspec",gold_chest_formspec) |
|
90 |
end, |
|
91 |
|
|
92 |
on_metadata_inventory_move = def_on_metadata_inventory_move, |
|
93 |
on_metadata_inventory_put = def_on_metadata_inventory_put, |
|
94 |
on_metadata_inventory_take = def_on_metadata_inventory_take |
|
95 |
}) |
|
96 |
|
|
97 |
for i, state in ipairs(chest_mark_colors) do |
fd3f25
|
98 |
minetest.register_node(":technic:gold_chest".. state, { |
82cba9
|
99 |
description = "Gold Chest", |
R |
100 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
101 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front"..state..".png"}, |
|
102 |
paramtype2 = "facedir", |
|
103 |
groups = chest_groups2, |
|
104 |
tube = tubes_properties, |
|
105 |
legacy_facedir_simple = true, |
|
106 |
sounds = default.node_sound_wood_defaults(), |
|
107 |
drop = "technic:gold_chest", |
|
108 |
on_construct = function(pos) |
|
109 |
local meta = minetest.env:get_meta(pos) |
|
110 |
meta:set_string("formspec",gold_chest_formspec) |
|
111 |
meta:set_string("infotext", "Gold Chest") |
|
112 |
local inv = meta:get_inventory() |
|
113 |
inv:set_size("main", gold_chest_inv_size) |
|
114 |
end, |
|
115 |
|
|
116 |
can_dig =chest_can_dig, |
|
117 |
|
|
118 |
on_punch = function (pos, node, puncher) |
|
119 |
chest_punched (pos,node,puncher); |
|
120 |
end, |
|
121 |
|
|
122 |
on_receive_fields = function(pos, formname, fields, sender) |
|
123 |
local meta = minetest.env:get_meta(pos); |
|
124 |
fields.text = fields.text or "" |
|
125 |
meta:set_string("text", fields.text) |
|
126 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
127 |
meta:set_string("formspec",gold_chest_formspec) |
|
128 |
end, |
|
129 |
|
|
130 |
on_metadata_inventory_move = def_on_metadata_inventory_move, |
|
131 |
on_metadata_inventory_put = def_on_metadata_inventory_put, |
|
132 |
on_metadata_inventory_take = def_on_metadata_inventory_take |
|
133 |
}) |
|
134 |
end |
|
135 |
|
fd3f25
|
136 |
minetest.register_node(":technic:gold_locked_chest", { |
82cba9
|
137 |
description = "Gold Locked Chest", |
R |
138 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
139 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked.png"}, |
|
140 |
paramtype2 = "facedir", |
|
141 |
drop = "technic:gold_locked_chest", |
|
142 |
groups = chest_groups1, |
|
143 |
tube = tubes_properties, |
|
144 |
legacy_facedir_simple = true, |
|
145 |
sounds = default.node_sound_wood_defaults(), |
|
146 |
after_place_node = function(pos, placer) |
|
147 |
local meta = minetest.env:get_meta(pos) |
|
148 |
meta:set_string("owner", placer:get_player_name() or "") |
|
149 |
meta:set_string("infotext", "Gold Locked Chest (owned by ".. |
|
150 |
meta:get_string("owner")..")") |
|
151 |
end, |
|
152 |
on_construct = function(pos) |
|
153 |
local meta = minetest.env:get_meta(pos) |
|
154 |
meta:set_string("formspec",gold_chest_formspec) |
|
155 |
meta:set_string("infotext", "Gold Locked Chest") |
|
156 |
meta:set_string("owner", "") |
|
157 |
local inv = meta:get_inventory() |
|
158 |
inv:set_size("main", gold_chest_inv_size) |
|
159 |
end, |
|
160 |
|
|
161 |
can_dig =chest_can_dig, |
|
162 |
|
|
163 |
on_punch = function (pos, node, puncher) |
|
164 |
local meta = minetest.env:get_meta(pos); |
|
165 |
if (has_locked_chest_privilege(meta, puncher)) then |
|
166 |
locked_chest_punched (pos,node,puncher); |
|
167 |
end |
|
168 |
end, |
|
169 |
|
|
170 |
on_receive_fields = function(pos, formname, fields, sender) |
|
171 |
local meta = minetest.env:get_meta(pos); |
|
172 |
fields.text = fields.text or "" |
|
173 |
meta:set_string("text", fields.text) |
|
174 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
175 |
meta:set_string("formspec",gold_chest_formspec) |
|
176 |
end, |
|
177 |
|
|
178 |
allow_metadata_inventory_move = def_allow_metadata_inventory_move, |
|
179 |
allow_metadata_inventory_put = def_allow_metadata_inventory_put, |
|
180 |
allow_metadata_inventory_take = def_allow_metadata_inventory_take, |
|
181 |
on_metadata_inventory_move = def_on_metadata_inventory_move, |
|
182 |
on_metadata_inventory_put = def_on_metadata_inventory_put, |
|
183 |
on_metadata_inventory_take = def_on_metadata_inventory_take |
|
184 |
}) |
|
185 |
|
|
186 |
for i, state in ipairs(chest_mark_colors) do |
fd3f25
|
187 |
minetest.register_node(":technic:gold_locked_chest".. state, { |
82cba9
|
188 |
description = "Gold Locked Chest", |
R |
189 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
190 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked"..state..".png"}, |
|
191 |
paramtype2 = "facedir", |
|
192 |
drop = "technic:gold_locked_chest", |
|
193 |
groups = chest_groups2, |
|
194 |
tube = tubes_properties, |
|
195 |
legacy_facedir_simple = true, |
|
196 |
sounds = default.node_sound_wood_defaults(), |
|
197 |
after_place_node = function(pos, placer) |
|
198 |
local meta = minetest.env:get_meta(pos) |
|
199 |
meta:set_string("owner", placer:get_player_name() or "") |
|
200 |
meta:set_string("infotext", "Gold Locked Chest (owned by ".. |
|
201 |
meta:get_string("owner")..")") |
|
202 |
end, |
|
203 |
on_construct = function(pos) |
|
204 |
local meta = minetest.env:get_meta(pos) |
|
205 |
meta:set_string("formspec",gold_chest_formspec) |
|
206 |
meta:set_string("infotext", "Gold Locked Chest") |
|
207 |
meta:set_string("owner", "") |
|
208 |
local inv = meta:get_inventory() |
|
209 |
inv:set_size("main", gold_chest_inv_size) |
|
210 |
end, |
|
211 |
|
|
212 |
can_dig = chest_can_dig, |
|
213 |
|
|
214 |
on_punch = function (pos, node, puncher) |
|
215 |
local meta = minetest.env:get_meta(pos); |
|
216 |
if (has_locked_chest_privilege(meta, puncher)) then |
|
217 |
locked_chest_punched (pos,node,puncher); |
|
218 |
end |
|
219 |
end, |
|
220 |
|
|
221 |
on_receive_fields = function(pos, formname, fields, sender) |
|
222 |
local meta = minetest.env:get_meta(pos); |
|
223 |
fields.text = fields.text or "" |
|
224 |
meta:set_string("text", fields.text) |
|
225 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
226 |
meta:set_string("formspec",gold_chest_formspec) |
|
227 |
end, |
|
228 |
|
|
229 |
allow_metadata_inventory_move = def_allow_metadata_inventory_move, |
|
230 |
allow_metadata_inventory_put = def_allow_metadata_inventory_put, |
|
231 |
allow_metadata_inventory_take = def_allow_metadata_inventory_take, |
|
232 |
on_metadata_inventory_move = def_on_metadata_inventory_move, |
|
233 |
on_metadata_inventory_put = def_on_metadata_inventory_put, |
|
234 |
on_metadata_inventory_take = def_on_metadata_inventory_take |
|
235 |
}) |
|
236 |
end |
|
237 |
|
|
238 |
function chest_punched (pos,node,puncher) |
|
239 |
|
|
240 |
local player_tool = puncher:get_wielded_item(); |
|
241 |
local item=player_tool:get_name(); |
|
242 |
if item == "dye:black" then |
|
243 |
if (hacky_swap_node(pos,"technic:gold_chest_black")) then |
|
244 |
player_tool:take_item(1); |
|
245 |
puncher:set_wielded_item(player_tool); |
|
246 |
return |
|
247 |
end |
|
248 |
end |
|
249 |
if item == "dye:blue" then |
|
250 |
if (hacky_swap_node(pos,"technic:gold_chest_blue")) then |
|
251 |
player_tool:take_item(1); |
|
252 |
puncher:set_wielded_item(player_tool); |
|
253 |
return |
|
254 |
end |
|
255 |
end |
|
256 |
if item == "dye:brown" then |
|
257 |
if (hacky_swap_node(pos,"technic:gold_chest_brown")) then |
|
258 |
player_tool:take_item(1); |
|
259 |
puncher:set_wielded_item(player_tool); |
|
260 |
return |
|
261 |
end |
|
262 |
end |
|
263 |
if item == "dye:cyan" then |
|
264 |
if (hacky_swap_node(pos,"technic:gold_chest_cyan")) then |
|
265 |
player_tool:take_item(1); |
|
266 |
puncher:set_wielded_item(player_tool); |
|
267 |
return |
|
268 |
end |
|
269 |
end |
|
270 |
if item == "dye:dark_green" then |
|
271 |
if (hacky_swap_node(pos,"technic:gold_chest_dark_green")) then |
|
272 |
player_tool:take_item(1); |
|
273 |
puncher:set_wielded_item(player_tool); |
|
274 |
return |
|
275 |
end |
|
276 |
end |
|
277 |
if item == "dye:dark_grey" then |
|
278 |
if (hacky_swap_node(pos,"technic:gold_chest_dark_grey")) then |
|
279 |
player_tool:take_item(1); |
|
280 |
puncher:set_wielded_item(player_tool); |
|
281 |
return |
|
282 |
end |
|
283 |
end |
|
284 |
if item == "dye:green" then |
|
285 |
if (hacky_swap_node(pos,"technic:gold_chest_green")) then |
|
286 |
player_tool:take_item(1); |
|
287 |
puncher:set_wielded_item(player_tool); |
|
288 |
return |
|
289 |
end |
|
290 |
end |
|
291 |
if item == "dye:grey" then |
|
292 |
if (hacky_swap_node(pos,"technic:gold_chest_grey")) then |
|
293 |
player_tool:take_item(1); |
|
294 |
puncher:set_wielded_item(player_tool); |
|
295 |
return |
|
296 |
end |
|
297 |
end |
|
298 |
if item == "dye:magenta" then |
|
299 |
if (hacky_swap_node(pos,"technic:gold_chest_magenta")) then |
|
300 |
player_tool:take_item(1); |
|
301 |
puncher:set_wielded_item(player_tool); |
|
302 |
return |
|
303 |
end |
|
304 |
end |
|
305 |
if item == "dye:orange" then |
|
306 |
if (hacky_swap_node(pos,"technic:gold_chest_orange")) then |
|
307 |
player_tool:take_item(1); |
|
308 |
puncher:set_wielded_item(player_tool); |
|
309 |
return |
|
310 |
end |
|
311 |
end |
|
312 |
if item == "dye:pink" then |
|
313 |
if (hacky_swap_node(pos,"technic:gold_chest_pink")) then |
|
314 |
player_tool:take_item(1); |
|
315 |
puncher:set_wielded_item(player_tool); |
|
316 |
return |
|
317 |
end |
|
318 |
end |
|
319 |
if item == "dye:red" then |
|
320 |
if (hacky_swap_node(pos,"technic:gold_chest_red")) then |
|
321 |
player_tool:take_item(1); |
|
322 |
puncher:set_wielded_item(player_tool); |
|
323 |
return |
|
324 |
end |
|
325 |
end |
|
326 |
if item == "dye:violet" then |
|
327 |
if (hacky_swap_node(pos,"technic:gold_chest_violet")) then |
|
328 |
player_tool:take_item(1); |
|
329 |
puncher:set_wielded_item(player_tool); |
|
330 |
return |
|
331 |
end |
|
332 |
end |
|
333 |
if item == "dye:white" then |
|
334 |
if (hacky_swap_node(pos,"technic:gold_chest_white")) then |
|
335 |
player_tool:take_item(1); |
|
336 |
puncher:set_wielded_item(player_tool); |
|
337 |
return |
|
338 |
end |
|
339 |
end |
|
340 |
if item == "dye:yellow" then |
|
341 |
if (hacky_swap_node(pos,"technic:gold_chest_yellow")) then |
|
342 |
player_tool:take_item(1); |
|
343 |
puncher:set_wielded_item(player_tool); |
|
344 |
return |
|
345 |
end |
|
346 |
end |
|
347 |
|
|
348 |
local meta = minetest.env:get_meta(pos); |
|
349 |
meta:set_string("formspec", "hack:sign_text_input") |
|
350 |
end |
|
351 |
|
|
352 |
|
|
353 |
function locked_chest_punched (pos,node,puncher) |
|
354 |
|
|
355 |
local player_tool = puncher:get_wielded_item(); |
|
356 |
local item=player_tool:get_name(); |
|
357 |
if item == "dye:black" then |
|
358 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_black")) then |
|
359 |
player_tool:take_item(1); |
|
360 |
puncher:set_wielded_item(player_tool); |
|
361 |
return |
|
362 |
end |
|
363 |
end |
|
364 |
if item == "dye:blue" then |
|
365 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_blue")) then |
|
366 |
player_tool:take_item(1); |
|
367 |
puncher:set_wielded_item(player_tool); |
|
368 |
return |
|
369 |
end |
|
370 |
end |
|
371 |
if item == "dye:brown" then |
|
372 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_brown")) then |
|
373 |
player_tool:take_item(1); |
|
374 |
puncher:set_wielded_item(player_tool); |
|
375 |
return |
|
376 |
end |
|
377 |
end |
|
378 |
if item == "dye:cyan" then |
|
379 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_cyan")) then |
|
380 |
player_tool:take_item(1); |
|
381 |
puncher:set_wielded_item(player_tool); |
|
382 |
return |
|
383 |
end |
|
384 |
end |
|
385 |
if item == "dye:dark_green" then |
|
386 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_green")) then |
|
387 |
player_tool:take_item(1); |
|
388 |
puncher:set_wielded_item(player_tool); |
|
389 |
return |
|
390 |
end |
|
391 |
end |
|
392 |
if item == "dye:dark_grey" then |
|
393 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_grey")) then |
|
394 |
player_tool:take_item(1); |
|
395 |
puncher:set_wielded_item(player_tool); |
|
396 |
return |
|
397 |
end |
|
398 |
end |
|
399 |
if item == "dye:green" then |
|
400 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_green")) then |
|
401 |
player_tool:take_item(1); |
|
402 |
puncher:set_wielded_item(player_tool); |
|
403 |
return |
|
404 |
end |
|
405 |
end |
|
406 |
if item == "dye:grey" then |
|
407 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_grey")) then |
|
408 |
player_tool:take_item(1); |
|
409 |
puncher:set_wielded_item(player_tool); |
|
410 |
return |
|
411 |
end |
|
412 |
end |
|
413 |
if item == "dye:magenta" then |
|
414 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_magenta")) then |
|
415 |
player_tool:take_item(1); |
|
416 |
puncher:set_wielded_item(player_tool); |
|
417 |
return |
|
418 |
end |
|
419 |
end |
|
420 |
if item == "dye:orange" then |
|
421 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_orange")) then |
|
422 |
player_tool:take_item(1); |
|
423 |
puncher:set_wielded_item(player_tool); |
|
424 |
return |
|
425 |
end |
|
426 |
end |
|
427 |
if item == "dye:pink" then |
|
428 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_pink")) then |
|
429 |
player_tool:take_item(1); |
|
430 |
puncher:set_wielded_item(player_tool); |
|
431 |
return |
|
432 |
end |
|
433 |
end |
|
434 |
if item == "dye:red" then |
|
435 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_red")) then |
|
436 |
player_tool:take_item(1); |
|
437 |
puncher:set_wielded_item(player_tool); |
|
438 |
return |
|
439 |
end |
|
440 |
end |
|
441 |
if item == "dye:violet" then |
|
442 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_violet")) then |
|
443 |
player_tool:take_item(1); |
|
444 |
puncher:set_wielded_item(player_tool); |
|
445 |
return |
|
446 |
end |
|
447 |
end |
|
448 |
if item == "dye:white" then |
|
449 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_white")) then |
|
450 |
player_tool:take_item(1); |
|
451 |
puncher:set_wielded_item(player_tool); |
|
452 |
return |
|
453 |
end |
|
454 |
end |
|
455 |
if item == "dye:yellow" then |
|
456 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_yellow")) then |
|
457 |
player_tool:take_item(1); |
|
458 |
puncher:set_wielded_item(player_tool); |
|
459 |
return |
|
460 |
end |
|
461 |
end |
|
462 |
|
|
463 |
local meta = minetest.env:get_meta(pos); |
|
464 |
meta:set_string("formspec", "hack:sign_text_input") |
|
465 |
end |
|
466 |
|