Dont allow to place not-fuel items in the fuel field in the furnace and dont allow...
authorPilzAdam <PilzAdam@gmx.de>
Thu, 10 Jan 2013 18:28:50 +0000 (19:28 +0100)
committerPilzAdam <pilzadam@minetest.net>
Mon, 18 Mar 2013 22:47:39 +0000 (23:47 +0100)
mods/default/init.lua

index cb56181ab771f170a92eead65440db291886a4e8..a481d37e22426b9d3ee0fad389d50193b870f355 100644 (file)
@@ -1491,6 +1491,33 @@ minetest.register_node("default:furnace", {
                end
                return true
        end,
+       allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+               if listname == "fuel" then
+                       if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+                               return stack:get_count()
+                       else
+                               return 0
+                       end
+               elseif listname == "src" then
+                       return stack:get_count()
+               elseif listname == "dst" then
+                       return 0
+               end
+       end,
+       allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+               local stack = ItemStack(minetest.env:get_meta(pos):get_inventory():get_stack(from_list, from_index))
+               if to_list == "fuel" then
+                       if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+                               return count
+                       else
+                               return 0
+                       end
+               elseif to_list == "src" then
+                       return count
+               elseif to_list == "dst" then
+                       return 0
+               end
+       end,
 })
 
 minetest.register_node("default:furnace_active", {
@@ -1524,6 +1551,33 @@ minetest.register_node("default:furnace_active", {
                end
                return true
        end,
+       allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+               if listname == "fuel" then
+                       if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+                               return stack:get_count()
+                       else
+                               return 0
+                       end
+               elseif listname == "src" then
+                       return stack:get_count()
+               elseif listname == "dst" then
+                       return 0
+               end
+       end,
+       allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+               local stack = ItemStack(minetest.env:get_meta(pos):get_inventory():get_stack(from_list, from_index))
+               if to_list == "fuel" then
+                       if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
+                               return count
+                       else
+                               return 0
+                       end
+               elseif to_list == "src" then
+                       return count
+               elseif to_list == "dst" then
+                       return 0
+               end
+       end,
 })
 
 function hacky_swap_node(pos,name)