]> git.lizzy.rs Git - xdecor.git/commitdiff
Craft guide : better output placement
authorkilbith <jeanpatrick.guerrero@gmail.com>
Sun, 3 Jan 2016 23:02:29 +0000 (00:02 +0100)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Mon, 4 Jan 2016 10:33:59 +0000 (11:33 +0100)
crafts.lua
worktable.lua

index cbfdb7abf5a4752a60028b8579d93279d6868275..b35ea560ccc51d4a693a4a7ad1d94765751db786 100644 (file)
@@ -416,3 +416,4 @@ minetest.register_craft({
                {"group:wood", "group:wood"}
        }
 })
+
index 38f689e69ba3f248b4f788a6958beaf8bd78bfb6..9e7a7510ca96e649c3b80ad56d927812f38f0ea1 100644 (file)
@@ -50,14 +50,13 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
                        button[4.6,0.2;0.7,0.5;clearfilter;X]
                        button[0,0;1.5,1;backcraft;< Back]
                        tooltip[search;Search]
-                       tooltip[clearfilter;Reset]
-                       label[3,5.8;Input] ]]..
+                       tooltip[clearfilter;Reset] ]]..
                        "list[context;inv_items_list;0,1;8,4;"..tostring(start_i).."]"..
                        "table[6.1,0.2;1.1,0.5;pagenum;#FFFF00,"..tostring(math.floor(pagenum))..
                        ",#FFFFFF,/ "..tostring(pagemax).."]"..
                        "field[1.8,0.32;2.6,1;filter;;"..filter.."]"..xbg
 
-       if stackname then
+       if stackname and minetest.registered_items[stackname] then
                local items_num = #minetest.get_all_craft_recipes(stackname)
                if recipe_num > items_num then
                        recipe_num = 1
@@ -88,10 +87,17 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
                        formspec = formspec.."list[context;craft_output_recipe;5,6.3;1,1;]"
                else
                        if stack_width == 0 then
-                               formspec = formspec.."list[context;craft_output_recipe;5,5.3;3,3;]"
+                               local rows, r = math.ceil(#stack_items / math.min(3, #stack_items))
+                               if rows == 3 then r = 2 else r = rows end
+
+                               formspec = formspec.."list[context;craft_output_recipe;5,"..(7.3-r)..
+                                               ";"..math.min(3, #stack_items)..","..rows..";]"
                        else
-                               formspec = formspec.."list[context;craft_output_recipe;5,5.3;"..stack_width..
-                                               ","..math.ceil(table.maxn(stack_items) / stack_width)..";]"
+                               local rows, r = math.ceil(table.maxn(stack_items) / stack_width)
+                               if rows == 3 then r = 2 else r = rows end
+
+                               formspec = formspec.."list[context;craft_output_recipe;5,"..(7.3-r)..
+                                               ";"..stack_width..","..rows..";]"
                        end
                end
 
@@ -236,6 +242,7 @@ function worktable.fields(pos, _, fields, sender)
                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
                inv:set_list("craft_output_recipe", {})