RealBadAngel
2013-02-02 fdc0562b3abeb76b133537f2908940f04ee720c6
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
27 minetest.register_node("technic:mithril_chest", {
28     description = "Mithril Chest",
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",
38                 "invsize[13,9;]"..
39                 "list[current_name;main;0,0;13,4;]"..
40                 "list[current_player;main;0,5;8,4;]")
41         meta:set_string("infotext", "Mithril Chest")
42         local inv = meta:get_inventory()
43         inv:set_size("main", 13*4)
44     end,
45     can_dig = function(pos,player)
46         local meta = minetest.env:get_meta(pos);
47         local inv = meta:get_inventory()
48         return inv:is_empty("main")
49     end,
50
51     on_metadata_inventory_move = function(pos, from_list, from_index,
52             to_list, to_index, count, player)
53         minetest.log("action", player:get_player_name()..
54                 " moves stuff in chest at "..minetest.pos_to_string(pos))
55         return minetest.node_metadata_inventory_move_allow_all(
56                 pos, from_list, from_index, to_list, to_index, count, player)
57     end,
58     on_metadata_inventory_offer = function(pos, listname, index, stack, player)
59         minetest.log("action", player:get_player_name()..
60                 " moves stuff to chest at "..minetest.pos_to_string(pos))
61         return minetest.node_metadata_inventory_offer_allow_all(
62                 pos, listname, index, stack, player)
63     end,
64     on_metadata_inventory_take = function(pos, listname, index, stack, player)
65         minetest.log("action", player:get_player_name()..
66                 " takes stuff from chest at "..minetest.pos_to_string(pos))
67     end,
68 })
69
70 minetest.register_node("technic:mithril_locked_chest", {
71     description = "Mithril Locked Chest",
72     tiles = {"technic_mithril_chest_top.png", "technic_mithril_chest_top.png", "technic_mithril_chest_side.png",
73         "technic_mithril_chest_side.png", "technic_mithril_chest_side.png", "technic_mithril_chest_locked.png"},
74     paramtype2 = "facedir",
75     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
76     legacy_facedir_simple = true,
77     sounds = default.node_sound_wood_defaults(),
78     after_place_node = function(pos, placer)
79         local meta = minetest.env:get_meta(pos)
80         meta:set_string("owner", placer:get_player_name() or "")
81         meta:set_string("infotext", "Mithril Locked Chest (owned by "..
82                 meta:get_string("owner")..")")
83     end,
84 on_construct = function(pos)
85         local meta = minetest.env:get_meta(pos)
86         meta:set_string("formspec",
87                 "invsize[13,9;]"..
88                 "list[current_name;main;0,0;13,4;]"..
89                 "list[current_player;main;0,5;8,4;]")
90         meta:set_string("infotext", "Mithril Locked Chest")
91         meta:set_string("owner", "")
92         local inv = meta:get_inventory()
93         inv:set_size("main", 13*4)
94     end,
95     can_dig = function(pos,player)
96         local meta = minetest.env:get_meta(pos);
97         local inv = meta:get_inventory()
98         return inv:is_empty("main")
99     end,
100     allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
101         local meta = minetest.env:get_meta(pos)
102         if not has_locked_chest_privilege(meta, player) then
103             minetest.log("action", player:get_player_name()..
104                     " tried to access a locked chest belonging to "..
105                     meta:get_string("owner").." at "..
106                     minetest.pos_to_string(pos))
107             return 0
108         end
109         return count
110     end,
111     allow_metadata_inventory_put = function(pos, listname, index, stack, player)
112         local meta = minetest.env:get_meta(pos)
113         if not has_locked_chest_privilege(meta, player) then
114             minetest.log("action", player:get_player_name()..
115                     " tried to access a locked chest belonging to "..
116                     meta:get_string("owner").." at "..
117                     minetest.pos_to_string(pos))
118             return 0
119         end
120         return stack:get_count()
121     end,
122     allow_metadata_inventory_take = function(pos, listname, index, stack, player)
123         local meta = minetest.env:get_meta(pos)
124         if not has_locked_chest_privilege(meta, player) then
125             minetest.log("action", player:get_player_name()..
126                     " tried to access a locked chest belonging to "..
127                     meta:get_string("owner").." at "..
128                     minetest.pos_to_string(pos))
129             return 0
130         end
131         return stack:get_count()
132     end,
133     on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
134         minetest.log("action", player:get_player_name()..
135                 " moves stuff in locked chest at "..minetest.pos_to_string(pos))
136     end,
137     on_metadata_inventory_put = function(pos, listname, index, stack, player)
138         minetest.log("action", player:get_player_name()..
139                 " moves stuff to locked chest at "..minetest.pos_to_string(pos))
140     end,
141     on_metadata_inventory_take = function(pos, listname, index, stack, player)
142         minetest.log("action", player:get_player_name()..
143                 " takes stuff from locked chest at "..minetest.pos_to_string(pos))
144     end,
145 })