RealBadAngel
2013-02-03 fd26a83fcf953fd955dca3967205304c30e77b60
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,
14                 input_inventory="main"}
15                 
16 chest_can_dig = function(pos,player)
17 local meta = minetest.env:get_meta(pos);
18 local inv = meta:get_inventory()
19 return inv:is_empty("main")
20 end
21
22 def_allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
23 local meta = minetest.env:get_meta(pos)
24 if not has_locked_chest_privilege(meta, player) then
25     minetest.log("action", player:get_player_name()..
26     " tried to access a locked chest belonging to "..
27     meta:get_string("owner").." at "..
28     minetest.pos_to_string(pos))
29     return 0
30     end
31     return count
32 end
33
34 def_allow_metadata_inventory_put = function(pos, listname, index, stack, player)
35 local meta = minetest.env:get_meta(pos)
36 if not has_locked_chest_privilege(meta, player) then
37     minetest.log("action", player:get_player_name()..
38     " tried to access a locked chest belonging to "..
39     meta:get_string("owner").." at "..
40     minetest.pos_to_string(pos))
41     return 0
42 end
43 return stack:get_count()
44 end
45
46 def_allow_metadata_inventory_take = function(pos, listname, index, stack, player)
47 local meta = minetest.env:get_meta(pos)
48 if not has_locked_chest_privilege(meta, player) then
49     minetest.log("action", player:get_player_name()..
50     " tried to access a locked chest belonging to "..
51     meta:get_string("owner").." at "..
52     minetest.pos_to_string(pos))
53     return 0
54     end
55 return stack:get_count()
56 end
57
58 def_on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
59     minetest.log("action", player:get_player_name()..
60     " moves stuff in locked chest at "..minetest.pos_to_string(pos))
61 end
62
63 def_on_metadata_inventory_put = function(pos, listname, index, stack, player)
64     minetest.log("action", player:get_player_name()..
65     " moves stuff to locked chest at "..minetest.pos_to_string(pos))
66 end
67
68 def_on_metadata_inventory_take = function(pos, listname, index, stack, player)
69     minetest.log("action", player:get_player_name()..
70     " takes stuff from locked chest at "..minetest.pos_to_string(pos))
71 end
72
73 function has_locked_chest_privilege(meta, player)
74     if player:get_player_name() ~= meta:get_string("owner") then
75         return false
76     end
77     return true
78 end