commit | author | age
|
82cba9
|
1 |
minetest.register_craft({ |
R |
2 |
output = 'technic:mithril_chest 1', |
|
3 |
recipe = { |
|
4 |
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, |
|
5 |
{'moreores:mithril_ingot','technic:gold_chest','moreores:mithril_ingot'}, |
|
6 |
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, |
|
7 |
} |
|
8 |
}) |
|
9 |
|
|
10 |
minetest.register_craft({ |
|
11 |
output = 'technic:mithril_locked_chest 1', |
|
12 |
recipe = { |
|
13 |
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, |
|
14 |
{'moreores:mithril_ingot','technic:gold_locked_chest','moreores:mithril_ingot'}, |
|
15 |
{'moreores:mithril_ingot','moreores:mithril_ingot','moreores:mithril_ingot'}, |
|
16 |
} |
|
17 |
}) |
|
18 |
|
|
19 |
minetest.register_craft({ |
|
20 |
output = 'technic:mithril_locked_chest 1', |
|
21 |
recipe = { |
|
22 |
{'default:steel_ingot'}, |
|
23 |
{'technic:mithril_chest'}, |
|
24 |
} |
|
25 |
}) |
|
26 |
|
fd3f25
|
27 |
minetest.register_node(":technic:mithril_chest", { |
82cba9
|
28 |
description = "Mithril Chest", |
R |
29 |
tiles = {"technic_mithril_chest_top.png", "technic_mithril_chest_top.png", "technic_mithril_chest_side.png", |
|
30 |
"technic_mithril_chest_side.png", "technic_mithril_chest_side.png", "technic_mithril_chest_front.png"}, |
|
31 |
paramtype2 = "facedir", |
|
32 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, |
|
33 |
legacy_facedir_simple = true, |
|
34 |
sounds = default.node_sound_wood_defaults(), |
|
35 |
on_construct = function(pos) |
|
36 |
local meta = minetest.env:get_meta(pos) |
|
37 |
meta:set_string("formspec", |
3a3700
|
38 |
"invsize[13,10;]".. |
R |
39 |
"label[0,0;Mithril Chest]".. |
|
40 |
"list[current_name;main;0,1;13,4;]".. |
|
41 |
"list[current_player;main;0,6;8,4;]".. |
|
42 |
"background[-0.19,-0.25;13.4,10.75;ui_form_bg.png]".. |
|
43 |
"background[0,1;13,4;ui_mithril_chest_inventory.png]".. |
|
44 |
"background[0,6;8,4;ui_main_inventory.png]") |
82cba9
|
45 |
meta:set_string("infotext", "Mithril Chest") |
R |
46 |
local inv = meta:get_inventory() |
|
47 |
inv:set_size("main", 13*4) |
|
48 |
end, |
|
49 |
can_dig = function(pos,player) |
|
50 |
local meta = minetest.env:get_meta(pos); |
|
51 |
local inv = meta:get_inventory() |
|
52 |
return inv:is_empty("main") |
|
53 |
end, |
|
54 |
|
|
55 |
on_metadata_inventory_move = function(pos, from_list, from_index, |
|
56 |
to_list, to_index, count, player) |
|
57 |
minetest.log("action", player:get_player_name().. |
|
58 |
" moves stuff in chest at "..minetest.pos_to_string(pos)) |
|
59 |
return minetest.node_metadata_inventory_move_allow_all( |
|
60 |
pos, from_list, from_index, to_list, to_index, count, player) |
|
61 |
end, |
|
62 |
on_metadata_inventory_offer = function(pos, listname, index, stack, player) |
|
63 |
minetest.log("action", player:get_player_name().. |
|
64 |
" moves stuff to chest at "..minetest.pos_to_string(pos)) |
|
65 |
return minetest.node_metadata_inventory_offer_allow_all( |
|
66 |
pos, listname, index, stack, player) |
|
67 |
end, |
|
68 |
on_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
69 |
minetest.log("action", player:get_player_name().. |
|
70 |
" takes stuff from chest at "..minetest.pos_to_string(pos)) |
|
71 |
end, |
|
72 |
}) |
|
73 |
|
fd3f25
|
74 |
minetest.register_node(":technic:mithril_locked_chest", { |
82cba9
|
75 |
description = "Mithril Locked Chest", |
R |
76 |
tiles = {"technic_mithril_chest_top.png", "technic_mithril_chest_top.png", "technic_mithril_chest_side.png", |
|
77 |
"technic_mithril_chest_side.png", "technic_mithril_chest_side.png", "technic_mithril_chest_locked.png"}, |
|
78 |
paramtype2 = "facedir", |
|
79 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, |
|
80 |
legacy_facedir_simple = true, |
|
81 |
sounds = default.node_sound_wood_defaults(), |
|
82 |
after_place_node = function(pos, placer) |
|
83 |
local meta = minetest.env:get_meta(pos) |
|
84 |
meta:set_string("owner", placer:get_player_name() or "") |
|
85 |
meta:set_string("infotext", "Mithril Locked Chest (owned by ".. |
|
86 |
meta:get_string("owner")..")") |
|
87 |
end, |
|
88 |
on_construct = function(pos) |
|
89 |
local meta = minetest.env:get_meta(pos) |
|
90 |
meta:set_string("formspec", |
3a3700
|
91 |
"invsize[13,10;]".. |
R |
92 |
"label[0,0;Mithril Locked Chest]".. |
|
93 |
"list[current_name;main;0,1;13,4;]".. |
|
94 |
"list[current_player;main;0,6;8,4;]".. |
|
95 |
"background[-0.19,-0.25;13.4,10.75;ui_form_bg.png]".. |
|
96 |
"background[0,1;13,4;ui_mithril_chest_inventory.png]".. |
|
97 |
"background[0,6;8,4;ui_main_inventory.png]") |
82cba9
|
98 |
meta:set_string("infotext", "Mithril Locked Chest") |
R |
99 |
meta:set_string("owner", "") |
|
100 |
local inv = meta:get_inventory() |
|
101 |
inv:set_size("main", 13*4) |
|
102 |
end, |
|
103 |
can_dig = function(pos,player) |
|
104 |
local meta = minetest.env:get_meta(pos); |
|
105 |
local inv = meta:get_inventory() |
|
106 |
return inv:is_empty("main") |
|
107 |
end, |
|
108 |
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
|
109 |
local meta = minetest.env:get_meta(pos) |
|
110 |
if not has_locked_chest_privilege(meta, player) then |
|
111 |
minetest.log("action", player:get_player_name().. |
|
112 |
" tried to access a locked chest belonging to ".. |
|
113 |
meta:get_string("owner").." at ".. |
|
114 |
minetest.pos_to_string(pos)) |
|
115 |
return 0 |
|
116 |
end |
|
117 |
return count |
|
118 |
end, |
|
119 |
allow_metadata_inventory_put = function(pos, listname, index, stack, player) |
|
120 |
local meta = minetest.env:get_meta(pos) |
|
121 |
if not has_locked_chest_privilege(meta, player) then |
|
122 |
minetest.log("action", player:get_player_name().. |
|
123 |
" tried to access a locked chest belonging to ".. |
|
124 |
meta:get_string("owner").." at ".. |
|
125 |
minetest.pos_to_string(pos)) |
|
126 |
return 0 |
|
127 |
end |
|
128 |
return stack:get_count() |
|
129 |
end, |
|
130 |
allow_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
131 |
local meta = minetest.env:get_meta(pos) |
|
132 |
if not has_locked_chest_privilege(meta, player) then |
|
133 |
minetest.log("action", player:get_player_name().. |
|
134 |
" tried to access a locked chest belonging to ".. |
|
135 |
meta:get_string("owner").." at ".. |
|
136 |
minetest.pos_to_string(pos)) |
|
137 |
return 0 |
|
138 |
end |
|
139 |
return stack:get_count() |
|
140 |
end, |
|
141 |
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) |
|
142 |
minetest.log("action", player:get_player_name().. |
|
143 |
" moves stuff in locked chest at "..minetest.pos_to_string(pos)) |
|
144 |
end, |
|
145 |
on_metadata_inventory_put = function(pos, listname, index, stack, player) |
|
146 |
minetest.log("action", player:get_player_name().. |
|
147 |
" moves stuff to locked chest at "..minetest.pos_to_string(pos)) |
|
148 |
end, |
|
149 |
on_metadata_inventory_take = function(pos, listname, index, stack, player) |
|
150 |
minetest.log("action", player:get_player_name().. |
|
151 |
" takes stuff from locked chest at "..minetest.pos_to_string(pos)) |
|
152 |
end, |
|
153 |
}) |