]> git.lizzy.rs Git - xdecor.git/commitdiff
Work Table : better ordering of functions
authorkilbith <jeanpatrick.guerrero@gmail.com>
Wed, 3 Feb 2016 19:24:24 +0000 (20:24 +0100)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Wed, 3 Feb 2016 19:24:24 +0000 (20:24 +0100)
worktable.lua

index 0a26f8cf498add945ea9832f7ec2c4281cb9caca..ed1fb4a9648faf5a5d3a65ad9691eaee87808b0c 100644 (file)
@@ -143,6 +143,21 @@ function worktable.craftguide_items(meta, filter)
        return items_list
 end
 
+function worktable.get_output(inv, input, name)
+       if inv:is_empty("input") then
+               inv:set_list("forms", {}) return
+       end
+
+       local output = {}
+       for _, n in pairs(worktable.defs) do
+               local count = math.min(n[2] * input:get_count(), input:get_stack_max())
+               local item = name.."_"..n[1]
+               if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
+               output[#output+1] = item.." "..count
+       end
+       inv:set_list("forms", output)
+end
+
 worktable.formspecs = {
        crafting = function(meta)
                meta:set_string("formspec", [[ size[8,7;]
@@ -268,31 +283,12 @@ function worktable.take(_, listname, _, stack, player)
        return stack:get_count()
 end
 
-function worktable.on_move(pos, _, _, to_list, _, count)
-       local inv = minetest.get_meta(pos):get_inventory()
-       if to_list == "trash" then inv:set_list("trash", {}) end
-end
 
 function worktable.move(pos, _, _, to_list, _, count)
        if to_list == "storage" or to_list == "trash" then return count end
        return 0
 end
 
-function worktable.get_output(inv, input, name)
-       if inv:is_empty("input") then
-               inv:set_list("forms", {}) return
-       end
-
-       local output = {}
-       for _, n in pairs(worktable.defs) do
-               local count = math.min(n[2] * input:get_count(), input:get_stack_max())
-               local item = name.."_"..n[1]
-               if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
-               output[#output+1] = item.." "..count
-       end
-       inv:set_list("forms", output)
-end
-
 function worktable.on_put(pos, listname, _, stack)
        local inv = minetest.get_meta(pos):get_inventory()
        if listname == "input" then
@@ -318,6 +314,11 @@ function worktable.on_take(pos, listname, index, stack)
        end
 end
 
+function worktable.on_move(pos, _, _, to_list, _, count)
+       local inv = minetest.get_meta(pos):get_inventory()
+       if to_list == "trash" then inv:set_list("trash", {}) end
+end
+
 xdecor.register("worktable", {
        description = "Work Table",
        groups = {cracky=2, choppy=2, oddly_breakable_by_hand=1},