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