ShadowNinja
2013-10-03 cda054a9368643e97c514eea43ff43a3e34dc2ab
commit | author | age
82cba9 1 chest_groups1 = {snappy=2,choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1}
R 2 chest_groups2 = {snappy=2,choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1}
3
4 tubes_properties = {insert_object=function(pos,node,stack,direction)
5                     local meta=minetest.env:get_meta(pos)
6                     local inv=meta:get_inventory()
7                     return inv:add_item("main",stack)
8                 end,
9                 can_insert=function(pos,node,stack,direction)
10                     local meta=minetest.env:get_meta(pos)
11                     local inv=meta:get_inventory()
12                     return inv:room_for_item("main",stack)
13                 end,
2e4d98 14                 input_inventory="main",
H 15                 connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1},
16 }
17
82cba9 18 chest_can_dig = function(pos,player)
R 19 local meta = minetest.env:get_meta(pos);
20 local inv = meta:get_inventory()
21 return inv:is_empty("main")
22 end
23
24 def_allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
25 local meta = minetest.env:get_meta(pos)
26 if not has_locked_chest_privilege(meta, player) then
27     minetest.log("action", player:get_player_name()..
28     " tried to access a locked chest belonging to "..
29     meta:get_string("owner").." at "..
30     minetest.pos_to_string(pos))
31     return 0
32     end
33     return count
34 end
35
36 def_allow_metadata_inventory_put = function(pos, listname, index, stack, player)
37 local meta = minetest.env:get_meta(pos)
38 if not has_locked_chest_privilege(meta, player) then
39     minetest.log("action", player:get_player_name()..
40     " tried to access a locked chest belonging to "..
41     meta:get_string("owner").." at "..
42     minetest.pos_to_string(pos))
43     return 0
44 end
45 return stack:get_count()
46 end
47
48 def_allow_metadata_inventory_take = function(pos, listname, index, stack, player)
49 local meta = minetest.env:get_meta(pos)
50 if not has_locked_chest_privilege(meta, player) then
51     minetest.log("action", player:get_player_name()..
52     " tried to access a locked chest belonging to "..
53     meta:get_string("owner").." at "..
54     minetest.pos_to_string(pos))
55     return 0
56     end
57 return stack:get_count()
58 end
59
60 def_on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
61     minetest.log("action", player:get_player_name()..
62     " moves stuff in locked chest at "..minetest.pos_to_string(pos))
63 end
64
65 def_on_metadata_inventory_put = function(pos, listname, index, stack, player)
66     minetest.log("action", player:get_player_name()..
67     " moves stuff to locked chest at "..minetest.pos_to_string(pos))
68 end
69
70 def_on_metadata_inventory_take = function(pos, listname, index, stack, player)
71     minetest.log("action", player:get_player_name()..
72     " takes stuff from locked chest at "..minetest.pos_to_string(pos))
73 end
74
75 function has_locked_chest_privilege(meta, player)
55caa1 76     return player:get_player_name() == meta:get_string("owner")
82cba9 77 end