]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/utility/chest.lua
Remove nil pointing to metadata take for furnaces
[Crafter.git] / mods / utility / chest.lua
index 797bc6ef7158722b0f41154a443065c33404cd46..cdf8718ca3155631c3c192a67b1c5f2918289f87 100644 (file)
@@ -8,7 +8,7 @@ function chest.get_chest_formspec(pos)
                "background[-0.19,-0.25;9.41,9.49;gui_hb_bg.png]"..
                "list[nodemeta:" .. spos .. ";main;0,0.3;9,4;]" ..
                "list[current_player;main;0,4.5;9,1;]" ..
-               "list[current_player;main;0,6.08;9,3;8]" ..
+               "list[current_player;main;0,6.08;9,3;9]" ..
                "listring[nodemeta:" .. spos .. ";main]" ..
                "listring[current_player;main]" --..
                --default.get_hotbar_bg(0,4.85)
@@ -29,10 +29,13 @@ function chest.chest_lid_close(pn)
        end
 
        local node = minetest.get_node(pos)
-       minetest.after(0.2, minetest.swap_node, pos, { name = "utility:" .. swap,
-                       param2 = node.param2 })
-       minetest.sound_play(sound, {gain = 0.3, pos = pos,
-               max_hear_distance = 10}, true)
+       minetest.after(0.2, function(pos,swap,node)
+               if minetest.get_node(pos).name == "utility:chest_open" then
+                       minetest.swap_node(pos,{name = "utility:"..swap,param2=node.param2})
+                       minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10},true)
+               end
+               redstone.collect_info(pos)
+       end,pos,swap,node)
 end
 
 chest.open_chests = {}
@@ -130,6 +133,7 @@ function chest.register_chest(name, d)
                         minetest.show_formspec(clicker:get_player_name(),"utility:chest", chest.get_chest_formspec(pos))
                        chest.open_chests[clicker:get_player_name()] = { pos = pos,
                                        sound = def.sound_close, swap = name }
+                       
                end
                def.on_blast = function() end
                def.on_key_use = function(pos, player)
@@ -185,14 +189,15 @@ function chest.register_chest(name, d)
                end
                
                def.on_rightclick = function(pos, node, clicker)
-                       minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos,
-                                       max_hear_distance = 10}, true)
-                               minetest.swap_node(pos, {
-                                               name = "utility:" .. name .. "_open",
-                                               param2 = node.param2 })
-                        minetest.show_formspec(clicker:get_player_name(),"utility:chest", chest.get_chest_formspec(pos))
-                       chest.open_chests[clicker:get_player_name()] = { pos = pos,
-                                       sound = def.sound_close, swap = name }
+                       if minetest.get_node(pos).name ~= "utility:chest" and  minetest.get_node(pos).name ~= "utility:chest_open" then
+                               return
+                       end
+                       minetest.sound_play(def.sound_open, {gain = 0.3, pos = pos, max_hear_distance = 10}, true)      
+                       minetest.swap_node(pos, {name = "utility:" .. name .. "_open", param2 = node.param2 })
+                               
+                       minetest.show_formspec(clicker:get_player_name(),"utility:chest", chest.get_chest_formspec(pos))
+                       chest.open_chests[clicker:get_player_name()] = { pos = pos,sound = def.sound_close, swap = name }
+                       redstone.collect_info(pos)
                end
                def.on_blast = function(pos)
                        local drops = {}
@@ -202,22 +207,6 @@ function chest.register_chest(name, d)
                        return drops
                end
        end
-
-       def.on_metadata_inventory_move = function(pos, from_list, from_index,
-                       to_list, to_index, count, player)
-               minetest.log("action", player:get_player_name() ..
-                       " moves stuff in chest at " .. minetest.pos_to_string(pos))
-       end
-       def.on_metadata_inventory_put = function(pos, listname, index, stack, player)
-               minetest.log("action", player:get_player_name() ..
-                       " moves " .. stack:get_name() ..
-                       " to chest at " .. minetest.pos_to_string(pos))
-       end
-       def.on_metadata_inventory_take = function(pos, listname, index, stack, player)
-               minetest.log("action", player:get_player_name() ..
-                       " takes " .. stack:get_name() ..
-                       " from chest at " .. minetest.pos_to_string(pos))
-       end
        
        def.on_destruct = function(pos)
                destroy_chest(pos)
@@ -273,9 +262,9 @@ chest.register_chest("chest", {
 minetest.register_craft({
        output = "utility:chest",
        recipe = {
-               {"group:wood", "group:wood", "group:wood"},
-               {"group:wood", "",                          "group:wood"},
-               {"group:wood", "group:wood", "group:wood"},
+               {"main:wood", "main:wood", "main:wood"},
+               {"main:wood", "",          "main:wood"},
+               {"main:wood", "main:wood", "main:wood"},
        }
 })
 
@@ -285,3 +274,11 @@ minetest.register_craft({
        recipe = "utility:chest",
        burntime = 5,
 })
+
+
+local groups = minetest.registered_nodes["utility:chest_open"].groups
+groups["redstone_torch"]=1
+groups["redstone_power"]=9
+minetest.override_item("utility:chest_open", {
+       groups = groups 
+})