commit | author | age
|
167434
|
1 |
local chest_mark_colors = { |
MK |
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 |
|
|
45 |
minetest.register_craftitem("technic:gold_chest", { |
|
46 |
description = "Gold Chest", |
|
47 |
stack_max = 99, |
|
48 |
}) |
|
49 |
minetest.register_craftitem("technic:gold_locked_chest", { |
|
50 |
description = "Gold Locked Chest", |
|
51 |
stack_max = 99, |
|
52 |
}) |
|
53 |
|
14506c
|
54 |
minetest.register_node("technic:gold_chest", { |
MK |
55 |
description = "Gold Chest", |
|
56 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
57 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front.png"}, |
|
58 |
paramtype2 = "facedir", |
|
59 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, |
|
60 |
legacy_facedir_simple = true, |
|
61 |
sounds = default.node_sound_wood_defaults(), |
|
62 |
on_construct = function(pos) |
|
63 |
local meta = minetest.env:get_meta(pos) |
|
64 |
meta:set_string("formspec", |
|
65 |
"invsize[12,9;]".. |
|
66 |
"list[current_name;main;0,0;12,4;]".. |
|
67 |
"list[current_player;main;0,5;8,4;]") |
|
68 |
meta:set_string("infotext", "Gold Chest") |
|
69 |
local inv = meta:get_inventory() |
|
70 |
inv:set_size("main", 12*4) |
|
71 |
end, |
|
72 |
|
|
73 |
can_dig = function(pos,player) |
|
74 |
local meta = minetest.env:get_meta(pos); |
|
75 |
local inv = meta:get_inventory() |
|
76 |
return inv:is_empty("main") |
|
77 |
end, |
|
78 |
|
|
79 |
on_punch = function (pos, node, puncher) |
|
80 |
chest_punched (pos,node,puncher); |
|
81 |
end, |
|
82 |
|
|
83 |
on_receive_fields = function(pos, formname, fields, sender) |
|
84 |
local meta = minetest.env:get_meta(pos); |
|
85 |
fields.text = fields.text or "" |
|
86 |
meta:set_string("text", fields.text) |
|
87 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
88 |
|
|
89 |
meta:set_string("formspec", |
|
90 |
"invsize[12,9;]".. |
|
91 |
"list[current_name;main;0,0;12,4;]".. |
|
92 |
"list[current_player;main;0,5;8,4;]") |
|
93 |
end, |
|
94 |
|
|
95 |
on_metadata_inventory_move = function(pos, from_list, from_index, |
|
96 |
to_list, to_index, count, player) |
|
97 |
minetest.log("action", player:get_player_name().. |
|
98 |
" moves stuff in chest at "..minetest.pos_to_string(pos)) |
|
99 |
return minetest.node_metadata_inventory_move_allow_all( |
|
100 |
pos, from_list, from_index, to_list, to_index, count, player) |
|
101 |
end, |
|
102 |
on_metadata_inventory_offer = function(pos, listname, index, stack, player) |
|
103 |
minetest.log("action", player:get_player_name().. |
|
104 |
" moves stuff to chest at "..minetest.pos_to_string(pos)) |
|
105 |
return minetest.node_metadata_inventory_offer_allow_all( |
|
106 |
pos, listname, index, stack, player) |
|
107 |
end, |
|
108 |
on_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
109 |
minetest.log("action", player:get_player_name().. |
|
110 |
" takes stuff from chest at "..minetest.pos_to_string(pos)) |
|
111 |
end, |
|
112 |
}) |
|
113 |
|
167434
|
114 |
for i, state in ipairs(chest_mark_colors) do |
MK |
115 |
minetest.register_node("technic:gold_chest".. state, { |
|
116 |
description = "Gold Chest", |
|
117 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
118 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_front"..state..".png"}, |
|
119 |
paramtype2 = "facedir", |
14506c
|
120 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, not_in_creative_inventory=1}, |
167434
|
121 |
legacy_facedir_simple = true, |
MK |
122 |
sounds = default.node_sound_wood_defaults(), |
14506c
|
123 |
drop = "technic:gold_chest", |
167434
|
124 |
on_construct = function(pos) |
MK |
125 |
local meta = minetest.env:get_meta(pos) |
|
126 |
meta:set_string("formspec", |
|
127 |
"invsize[12,9;]".. |
|
128 |
"list[current_name;main;0,0;12,4;]".. |
|
129 |
"list[current_player;main;0,5;8,4;]") |
|
130 |
meta:set_string("infotext", "Gold Chest") |
|
131 |
local inv = meta:get_inventory() |
|
132 |
inv:set_size("main", 12*4) |
|
133 |
end, |
|
134 |
|
|
135 |
can_dig = function(pos,player) |
|
136 |
local meta = minetest.env:get_meta(pos); |
|
137 |
local inv = meta:get_inventory() |
|
138 |
return inv:is_empty("main") |
|
139 |
end, |
|
140 |
|
|
141 |
on_punch = function (pos, node, puncher) |
|
142 |
chest_punched (pos,node,puncher); |
|
143 |
end, |
|
144 |
|
|
145 |
on_receive_fields = function(pos, formname, fields, sender) |
|
146 |
local meta = minetest.env:get_meta(pos); |
|
147 |
fields.text = fields.text or "" |
|
148 |
meta:set_string("text", fields.text) |
|
149 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
150 |
|
|
151 |
meta:set_string("formspec", |
|
152 |
"invsize[12,9;]".. |
|
153 |
"list[current_name;main;0,0;12,4;]".. |
|
154 |
"list[current_player;main;0,5;8,4;]") |
|
155 |
end, |
|
156 |
|
|
157 |
on_metadata_inventory_move = function(pos, from_list, from_index, |
|
158 |
to_list, to_index, count, player) |
|
159 |
minetest.log("action", player:get_player_name().. |
|
160 |
" moves stuff in chest at "..minetest.pos_to_string(pos)) |
|
161 |
return minetest.node_metadata_inventory_move_allow_all( |
|
162 |
pos, from_list, from_index, to_list, to_index, count, player) |
|
163 |
end, |
|
164 |
on_metadata_inventory_offer = function(pos, listname, index, stack, player) |
|
165 |
minetest.log("action", player:get_player_name().. |
|
166 |
" moves stuff to chest at "..minetest.pos_to_string(pos)) |
|
167 |
return minetest.node_metadata_inventory_offer_allow_all( |
|
168 |
pos, listname, index, stack, player) |
|
169 |
end, |
|
170 |
on_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
171 |
minetest.log("action", player:get_player_name().. |
|
172 |
" takes stuff from chest at "..minetest.pos_to_string(pos)) |
|
173 |
end, |
|
174 |
}) |
|
175 |
end |
|
176 |
|
|
177 |
|
|
178 |
local function has_locked_chest_privilege(meta, player) |
|
179 |
if player:get_player_name() ~= meta:get_string("owner") then |
|
180 |
return false |
|
181 |
end |
|
182 |
return true |
|
183 |
end |
|
184 |
|
14506c
|
185 |
minetest.register_node("technic:gold_locked_chest", { |
MK |
186 |
description = "Gold Locked Chest", |
|
187 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
188 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked.png"}, |
|
189 |
paramtype2 = "facedir", |
|
190 |
drop = "technic:gold_chest", |
|
191 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, |
|
192 |
legacy_facedir_simple = true, |
|
193 |
sounds = default.node_sound_wood_defaults(), |
|
194 |
after_place_node = function(pos, placer) |
|
195 |
local meta = minetest.env:get_meta(pos) |
|
196 |
meta:set_string("owner", placer:get_player_name() or "") |
|
197 |
meta:set_string("infotext", "Gold Locked Chest (owned by ".. |
|
198 |
meta:get_string("owner")..")") |
|
199 |
end, |
|
200 |
on_construct = function(pos) |
|
201 |
local meta = minetest.env:get_meta(pos) |
|
202 |
meta:set_string("formspec", |
|
203 |
"invsize[12,9;]".. |
|
204 |
"list[current_name;main;0,0;12,4;]".. |
|
205 |
"list[current_player;main;0,5;8,4;]") |
|
206 |
meta:set_string("infotext", "Gold Locked Chest") |
|
207 |
meta:set_string("owner", "") |
|
208 |
local inv = meta:get_inventory() |
|
209 |
inv:set_size("main", 12*4) |
|
210 |
end, |
|
211 |
can_dig = function(pos,player) |
|
212 |
local meta = minetest.env:get_meta(pos); |
|
213 |
local inv = meta:get_inventory() |
|
214 |
return inv:is_empty("main") |
|
215 |
end, |
|
216 |
|
|
217 |
on_punch = function (pos, node, puncher) |
|
218 |
local meta = minetest.env:get_meta(pos); |
|
219 |
if (has_locked_chest_privilege(meta, puncher)) then |
|
220 |
locked_chest_punched (pos,node,puncher); |
|
221 |
end |
|
222 |
end, |
|
223 |
|
|
224 |
on_receive_fields = function(pos, formname, fields, sender) |
|
225 |
local meta = minetest.env:get_meta(pos); |
|
226 |
fields.text = fields.text or "" |
|
227 |
meta:set_string("text", fields.text) |
|
228 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
229 |
|
|
230 |
meta:set_string("formspec", |
|
231 |
"invsize[12,9;]".. |
|
232 |
"list[current_name;main;0,0;12,4;]".. |
|
233 |
"list[current_player;main;0,5;8,4;]") |
|
234 |
end, |
|
235 |
|
|
236 |
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
|
237 |
local meta = minetest.env:get_meta(pos) |
|
238 |
if not has_locked_chest_privilege(meta, player) then |
|
239 |
minetest.log("action", player:get_player_name().. |
|
240 |
" tried to access a locked chest belonging to ".. |
|
241 |
meta:get_string("owner").." at ".. |
|
242 |
minetest.pos_to_string(pos)) |
|
243 |
return 0 |
|
244 |
end |
|
245 |
return count |
|
246 |
end, |
|
247 |
allow_metadata_inventory_put = function(pos, listname, index, stack, player) |
|
248 |
local meta = minetest.env:get_meta(pos) |
|
249 |
if not has_locked_chest_privilege(meta, player) then |
|
250 |
minetest.log("action", player:get_player_name().. |
|
251 |
" tried to access a locked chest belonging to ".. |
|
252 |
meta:get_string("owner").." at ".. |
|
253 |
minetest.pos_to_string(pos)) |
|
254 |
return 0 |
|
255 |
end |
|
256 |
return stack:get_count() |
|
257 |
end, |
|
258 |
allow_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
259 |
local meta = minetest.env:get_meta(pos) |
|
260 |
if not has_locked_chest_privilege(meta, player) then |
|
261 |
minetest.log("action", player:get_player_name().. |
|
262 |
" tried to access a locked chest belonging to ".. |
|
263 |
meta:get_string("owner").." at ".. |
|
264 |
minetest.pos_to_string(pos)) |
|
265 |
return 0 |
|
266 |
end |
|
267 |
return stack:get_count() |
|
268 |
end, |
|
269 |
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
|
270 |
minetest.log("action", player:get_player_name().. |
|
271 |
" moves stuff in locked chest at "..minetest.pos_to_string(pos)) |
|
272 |
end, |
|
273 |
on_metadata_inventory_put = function(pos, listname, index, stack, player) |
|
274 |
minetest.log("action", player:get_player_name().. |
|
275 |
" moves stuff to locked chest at "..minetest.pos_to_string(pos)) |
|
276 |
end, |
|
277 |
on_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
278 |
minetest.log("action", player:get_player_name().. |
|
279 |
" takes stuff from locked chest at "..minetest.pos_to_string(pos)) |
|
280 |
end, |
|
281 |
}) |
|
282 |
|
167434
|
283 |
for i, state in ipairs(chest_mark_colors) do |
MK |
284 |
minetest.register_node("technic:gold_locked_chest".. state, { |
|
285 |
description = "Gold Locked Chest", |
|
286 |
tiles = {"technic_gold_chest_top.png", "technic_gold_chest_top.png", "technic_gold_chest_side.png", |
|
287 |
"technic_gold_chest_side.png", "technic_gold_chest_side.png", "technic_gold_chest_locked"..state..".png"}, |
|
288 |
paramtype2 = "facedir", |
14506c
|
289 |
drop = "technic:gold_chest", |
MK |
290 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, not_in_creative_inventory=1}, |
167434
|
291 |
legacy_facedir_simple = true, |
MK |
292 |
sounds = default.node_sound_wood_defaults(), |
|
293 |
after_place_node = function(pos, placer) |
|
294 |
local meta = minetest.env:get_meta(pos) |
|
295 |
meta:set_string("owner", placer:get_player_name() or "") |
|
296 |
meta:set_string("infotext", "Gold Locked Chest (owned by ".. |
|
297 |
meta:get_string("owner")..")") |
|
298 |
end, |
|
299 |
on_construct = function(pos) |
|
300 |
local meta = minetest.env:get_meta(pos) |
|
301 |
meta:set_string("formspec", |
|
302 |
"invsize[12,9;]".. |
|
303 |
"list[current_name;main;0,0;12,4;]".. |
|
304 |
"list[current_player;main;0,5;8,4;]") |
|
305 |
meta:set_string("infotext", "Gold Locked Chest") |
|
306 |
meta:set_string("owner", "") |
|
307 |
local inv = meta:get_inventory() |
|
308 |
inv:set_size("main", 12*4) |
|
309 |
end, |
|
310 |
can_dig = function(pos,player) |
|
311 |
local meta = minetest.env:get_meta(pos); |
|
312 |
local inv = meta:get_inventory() |
|
313 |
return inv:is_empty("main") |
|
314 |
end, |
|
315 |
|
|
316 |
on_punch = function (pos, node, puncher) |
|
317 |
local meta = minetest.env:get_meta(pos); |
|
318 |
if (has_locked_chest_privilege(meta, puncher)) then |
|
319 |
locked_chest_punched (pos,node,puncher); |
|
320 |
end |
|
321 |
end, |
|
322 |
|
|
323 |
on_receive_fields = function(pos, formname, fields, sender) |
|
324 |
local meta = minetest.env:get_meta(pos); |
|
325 |
fields.text = fields.text or "" |
|
326 |
meta:set_string("text", fields.text) |
|
327 |
meta:set_string("infotext", '"'..fields.text..'"') |
|
328 |
|
|
329 |
meta:set_string("formspec", |
|
330 |
"invsize[12,9;]".. |
|
331 |
"list[current_name;main;0,0;12,4;]".. |
|
332 |
"list[current_player;main;0,5;8,4;]") |
|
333 |
end, |
|
334 |
|
|
335 |
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
|
336 |
local meta = minetest.env:get_meta(pos) |
|
337 |
if not has_locked_chest_privilege(meta, player) then |
|
338 |
minetest.log("action", player:get_player_name().. |
|
339 |
" tried to access a locked chest belonging to ".. |
|
340 |
meta:get_string("owner").." at ".. |
|
341 |
minetest.pos_to_string(pos)) |
|
342 |
return 0 |
|
343 |
end |
|
344 |
return count |
|
345 |
end, |
|
346 |
allow_metadata_inventory_put = function(pos, listname, index, stack, player) |
|
347 |
local meta = minetest.env:get_meta(pos) |
|
348 |
if not has_locked_chest_privilege(meta, player) then |
|
349 |
minetest.log("action", player:get_player_name().. |
|
350 |
" tried to access a locked chest belonging to ".. |
|
351 |
meta:get_string("owner").." at ".. |
|
352 |
minetest.pos_to_string(pos)) |
|
353 |
return 0 |
|
354 |
end |
|
355 |
return stack:get_count() |
|
356 |
end, |
|
357 |
allow_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
358 |
local meta = minetest.env:get_meta(pos) |
|
359 |
if not has_locked_chest_privilege(meta, player) then |
|
360 |
minetest.log("action", player:get_player_name().. |
|
361 |
" tried to access a locked chest belonging to ".. |
|
362 |
meta:get_string("owner").." at ".. |
|
363 |
minetest.pos_to_string(pos)) |
|
364 |
return 0 |
|
365 |
end |
|
366 |
return stack:get_count() |
|
367 |
end, |
|
368 |
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
|
369 |
minetest.log("action", player:get_player_name().. |
|
370 |
" moves stuff in locked chest at "..minetest.pos_to_string(pos)) |
|
371 |
end, |
|
372 |
on_metadata_inventory_put = function(pos, listname, index, stack, player) |
|
373 |
minetest.log("action", player:get_player_name().. |
|
374 |
" moves stuff to locked chest at "..minetest.pos_to_string(pos)) |
|
375 |
end, |
|
376 |
on_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
377 |
minetest.log("action", player:get_player_name().. |
|
378 |
" takes stuff from locked chest at "..minetest.pos_to_string(pos)) |
|
379 |
end, |
|
380 |
}) |
|
381 |
end |
|
382 |
|
|
383 |
function chest_punched (pos,node,puncher) |
|
384 |
|
|
385 |
local player_tool = puncher:get_wielded_item(); |
|
386 |
local item=player_tool:get_name(); |
|
387 |
if item == "dye:black" then |
|
388 |
if (hacky_swap_node(pos,"technic:gold_chest_black")) then |
|
389 |
player_tool:take_item(1); |
|
390 |
puncher:set_wielded_item(player_tool); |
|
391 |
return |
|
392 |
end |
|
393 |
end |
|
394 |
if item == "dye:blue" then |
|
395 |
if (hacky_swap_node(pos,"technic:gold_chest_blue")) then |
|
396 |
player_tool:take_item(1); |
|
397 |
puncher:set_wielded_item(player_tool); |
|
398 |
return |
|
399 |
end |
|
400 |
end |
|
401 |
if item == "dye:brown" then |
|
402 |
if (hacky_swap_node(pos,"technic:gold_chest_brown")) then |
|
403 |
player_tool:take_item(1); |
|
404 |
puncher:set_wielded_item(player_tool); |
|
405 |
return |
|
406 |
end |
|
407 |
end |
|
408 |
if item == "dye:cyan" then |
|
409 |
if (hacky_swap_node(pos,"technic:gold_chest_cyan")) then |
|
410 |
player_tool:take_item(1); |
|
411 |
puncher:set_wielded_item(player_tool); |
|
412 |
return |
|
413 |
end |
|
414 |
end |
|
415 |
if item == "dye:dark_green" then |
|
416 |
if (hacky_swap_node(pos,"technic:gold_chest_dark_green")) then |
|
417 |
player_tool:take_item(1); |
|
418 |
puncher:set_wielded_item(player_tool); |
|
419 |
return |
|
420 |
end |
|
421 |
end |
|
422 |
if item == "dye:dark_grey" then |
|
423 |
if (hacky_swap_node(pos,"technic:gold_chest_dark_grey")) then |
|
424 |
player_tool:take_item(1); |
|
425 |
puncher:set_wielded_item(player_tool); |
|
426 |
return |
|
427 |
end |
|
428 |
end |
|
429 |
if item == "dye:green" then |
|
430 |
if (hacky_swap_node(pos,"technic:gold_chest_green")) then |
|
431 |
player_tool:take_item(1); |
|
432 |
puncher:set_wielded_item(player_tool); |
|
433 |
return |
|
434 |
end |
|
435 |
end |
|
436 |
if item == "dye:grey" then |
|
437 |
if (hacky_swap_node(pos,"technic:gold_chest_grey")) then |
|
438 |
player_tool:take_item(1); |
|
439 |
puncher:set_wielded_item(player_tool); |
|
440 |
return |
|
441 |
end |
|
442 |
end |
|
443 |
if item == "dye:magenta" then |
|
444 |
if (hacky_swap_node(pos,"technic:gold_chest_magenta")) then |
|
445 |
player_tool:take_item(1); |
|
446 |
puncher:set_wielded_item(player_tool); |
|
447 |
return |
|
448 |
end |
|
449 |
end |
|
450 |
if item == "dye:orange" then |
|
451 |
if (hacky_swap_node(pos,"technic:gold_chest_orange")) then |
|
452 |
player_tool:take_item(1); |
|
453 |
puncher:set_wielded_item(player_tool); |
|
454 |
return |
|
455 |
end |
|
456 |
end |
|
457 |
if item == "dye:pink" then |
|
458 |
if (hacky_swap_node(pos,"technic:gold_chest_pink")) then |
|
459 |
player_tool:take_item(1); |
|
460 |
puncher:set_wielded_item(player_tool); |
|
461 |
return |
|
462 |
end |
|
463 |
end |
|
464 |
if item == "dye:red" then |
|
465 |
if (hacky_swap_node(pos,"technic:gold_chest_red")) then |
|
466 |
player_tool:take_item(1); |
|
467 |
puncher:set_wielded_item(player_tool); |
|
468 |
return |
|
469 |
end |
|
470 |
end |
|
471 |
if item == "dye:violet" then |
|
472 |
if (hacky_swap_node(pos,"technic:gold_chest_violet")) then |
|
473 |
player_tool:take_item(1); |
|
474 |
puncher:set_wielded_item(player_tool); |
|
475 |
return |
|
476 |
end |
|
477 |
end |
|
478 |
if item == "dye:white" then |
|
479 |
if (hacky_swap_node(pos,"technic:gold_chest_white")) then |
|
480 |
player_tool:take_item(1); |
|
481 |
puncher:set_wielded_item(player_tool); |
|
482 |
return |
|
483 |
end |
|
484 |
end |
|
485 |
if item == "dye:yellow" then |
|
486 |
if (hacky_swap_node(pos,"technic:gold_chest_yellow")) then |
|
487 |
player_tool:take_item(1); |
|
488 |
puncher:set_wielded_item(player_tool); |
|
489 |
return |
|
490 |
end |
|
491 |
end |
|
492 |
|
|
493 |
local meta = minetest.env:get_meta(pos); |
|
494 |
meta:set_string("formspec", "hack:sign_text_input") |
|
495 |
end |
|
496 |
|
|
497 |
|
|
498 |
function locked_chest_punched (pos,node,puncher) |
|
499 |
|
|
500 |
local player_tool = puncher:get_wielded_item(); |
|
501 |
local item=player_tool:get_name(); |
|
502 |
if item == "dye:black" then |
|
503 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_black")) then |
|
504 |
player_tool:take_item(1); |
|
505 |
puncher:set_wielded_item(player_tool); |
|
506 |
return |
|
507 |
end |
|
508 |
end |
|
509 |
if item == "dye:blue" then |
|
510 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_blue")) then |
|
511 |
player_tool:take_item(1); |
|
512 |
puncher:set_wielded_item(player_tool); |
|
513 |
return |
|
514 |
end |
|
515 |
end |
|
516 |
if item == "dye:brown" then |
|
517 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_brown")) then |
|
518 |
player_tool:take_item(1); |
|
519 |
puncher:set_wielded_item(player_tool); |
|
520 |
return |
|
521 |
end |
|
522 |
end |
|
523 |
if item == "dye:cyan" then |
|
524 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_cyan")) then |
|
525 |
player_tool:take_item(1); |
|
526 |
puncher:set_wielded_item(player_tool); |
|
527 |
return |
|
528 |
end |
|
529 |
end |
|
530 |
if item == "dye:dark_green" then |
|
531 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_green")) then |
|
532 |
player_tool:take_item(1); |
|
533 |
puncher:set_wielded_item(player_tool); |
|
534 |
return |
|
535 |
end |
|
536 |
end |
|
537 |
if item == "dye:dark_grey" then |
|
538 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_dark_grey")) then |
|
539 |
player_tool:take_item(1); |
|
540 |
puncher:set_wielded_item(player_tool); |
|
541 |
return |
|
542 |
end |
|
543 |
end |
|
544 |
if item == "dye:green" then |
|
545 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_green")) then |
|
546 |
player_tool:take_item(1); |
|
547 |
puncher:set_wielded_item(player_tool); |
|
548 |
return |
|
549 |
end |
|
550 |
end |
|
551 |
if item == "dye:grey" then |
|
552 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_grey")) then |
|
553 |
player_tool:take_item(1); |
|
554 |
puncher:set_wielded_item(player_tool); |
|
555 |
return |
|
556 |
end |
|
557 |
end |
|
558 |
if item == "dye:magenta" then |
|
559 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_magenta")) then |
|
560 |
player_tool:take_item(1); |
|
561 |
puncher:set_wielded_item(player_tool); |
|
562 |
return |
|
563 |
end |
|
564 |
end |
|
565 |
if item == "dye:orange" then |
|
566 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_orange")) then |
|
567 |
player_tool:take_item(1); |
|
568 |
puncher:set_wielded_item(player_tool); |
|
569 |
return |
|
570 |
end |
|
571 |
end |
|
572 |
if item == "dye:pink" then |
|
573 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_pink")) then |
|
574 |
player_tool:take_item(1); |
|
575 |
puncher:set_wielded_item(player_tool); |
|
576 |
return |
|
577 |
end |
|
578 |
end |
|
579 |
if item == "dye:red" then |
|
580 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_red")) then |
|
581 |
player_tool:take_item(1); |
|
582 |
puncher:set_wielded_item(player_tool); |
|
583 |
return |
|
584 |
end |
|
585 |
end |
|
586 |
if item == "dye:violet" then |
|
587 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_violet")) then |
|
588 |
player_tool:take_item(1); |
|
589 |
puncher:set_wielded_item(player_tool); |
|
590 |
return |
|
591 |
end |
|
592 |
end |
|
593 |
if item == "dye:white" then |
|
594 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_white")) then |
|
595 |
player_tool:take_item(1); |
|
596 |
puncher:set_wielded_item(player_tool); |
|
597 |
return |
|
598 |
end |
|
599 |
end |
|
600 |
if item == "dye:yellow" then |
|
601 |
if (hacky_swap_node(pos,"technic:gold_locked_chest_yellow")) then |
|
602 |
player_tool:take_item(1); |
|
603 |
puncher:set_wielded_item(player_tool); |
|
604 |
return |
|
605 |
end |
|
606 |
end |
|
607 |
|
|
608 |
local meta = minetest.env:get_meta(pos); |
|
609 |
meta:set_string("formspec", "hack:sign_text_input") |
|
610 |
end |
|
611 |
|