]> git.lizzy.rs Git - xdecor.git/commitdiff
Various clean-ups and update inv size on clicking on [Guide] button instead
authorkilbith <jeanpatrick.guerrero@gmail.com>
Mon, 4 Jan 2016 10:41:15 +0000 (11:41 +0100)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Mon, 4 Jan 2016 14:35:15 +0000 (15:35 +0100)
after constructing

crafts.lua
worktable.lua

index b35ea560ccc51d4a693a4a7ad1d94765751db786..84f8bef6b50d7030aeb50311c3ce4914300b717a 100644 (file)
@@ -403,7 +403,7 @@ minetest.register_craft({
        output = "xdecor:wood_tile 2",
        recipe = {
                {"", "group:wood", ""},
-               {"group:wood", "group:wood", "group:wood"},
+               {"group:wood", "", "group:wood"},
                {"", "group:wood", ""}
        }
 })
index 9e7a7510ca96e649c3b80ad56d927812f38f0ea1..c6c576ad72656249e9f1368c0aee40ea05fb382c 100644 (file)
@@ -67,19 +67,15 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
                local stack_items = minetest.get_all_craft_recipes(stackname)[recipe_num].items
                local stack_type = minetest.get_all_craft_recipes(stackname)[recipe_num].type
                local stack_output = minetest.get_all_craft_recipes(stackname)[recipe_num].output
-               local stack_count = stack_output:match("%s(%d+)")
+               local stack_count = stack_output:match("%s(%d+)") or 1
+
+               inv:set_stack("item_craft_input", 1, stackname.." "..stack_count)
 
                if items_num > 1 then
                        formspec = formspec.."button[0,5.7;1.6,1;alternate;Alternate]"..
                                        "label[0,5.2;Recipe "..recipe_num.." of "..items_num.."]"
                end
 
-               if stack_count then
-                       inv:set_stack("item_craft_input", 1, stackname.." "..stack_count)
-               else
-                       inv:set_stack("item_craft_input", 1, stackname)
-               end
-
                if stack_type == "cooking" or table.maxn(stack_items) == 1 then
                        if stack_type == "cooking" then
                                formspec = formspec.."image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png]"
@@ -107,20 +103,18 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
                        if def and def:find("^group:") then
                                if def:find("wool$") or def:find("dye$") then
                                        def = def:match(":([%w_]+)")..":white"
+                               elseif minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
+                                       def = def:gsub("group", "default")
                                else
-                                       if minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
-                                               def = def:gsub("group", "default")
-                                       else
-                                               for node, definition in pairs(minetest.registered_items) do
-                                               for group in pairs(definition.groups) do
-                                                       if def:match("^group:"..group.."$") or
-                                                                       ((def:find("dye") or def:find("flower")) and
-                                                                       group == def:match("^group:.*,("..group..")")) then
-                                                               def = node
-                                                       end
-                                               end
+                                       for node, definition in pairs(minetest.registered_items) do
+                                       for group in pairs(definition.groups) do
+                                               if def:match("^group:"..group.."$") or
+                                                               ((def:find("dye") or def:find("flower")) and
+                                                               group == def:match("^group:.*,("..group..")")) then
+                                                       def = node
                                                end
                                        end
+                                       end
                                end
                        end
 
@@ -220,7 +214,6 @@ function worktable.construct(pos)
        meta:set_string("infotext", "Work Table")
 
        worktable.main(pos)
-       worktable.craftguide_update(pos, nil)
 end
 
 function worktable.fields(pos, _, fields, sender)
@@ -241,7 +234,6 @@ function worktable.fields(pos, _, fields, sender)
                end
                worktable.crafting(pos)
        elseif fields.craftguide then
-               if not meta:to_table().inventory.inv_items_list then return end -- legacy code
                worktable.craftguide_update(pos, nil)
                worktable.craft_output_recipe(pos, 0, 1, nil, 1, "")
        elseif fields.alternate then