]> git.lizzy.rs Git - xdecor.git/commitdiff
Small simplifications
authorkilbith <jeanpatrick.guerrero@gmail.com>
Sat, 9 Jan 2016 14:58:39 +0000 (15:58 +0100)
committerkilbith <jeanpatrick.guerrero@gmail.com>
Sat, 9 Jan 2016 17:56:05 +0000 (18:56 +0100)
cooking.lua
enchanting.lua
worktable.lua

index 3cad827f35c7f444d45d5e469a7b7c1e5f2d025a..5cf19f0a908dc8df002343ef89bcbb6ba129f37e 100644 (file)
@@ -116,7 +116,7 @@ minetest.register_abm({
 
                for _, obj in pairs(objs) do
                        if obj and obj:get_luaentity() then
-                               local itemstring = obj:get_luaentity().itemstring:match("[%w_]+:([%w_]+)")
+                               local itemstring = obj:get_luaentity().itemstring:match(":([%w_]+)")
                                if not next(ingredients) then
                                        for _, rep in pairs(ingredients) do
                                                if itemstring == rep then return end
index 75ae0ff6a20c201bcf3125db2fff90612c4e4674..fdce2d4e9f44b2539429d3ce1cf46b4f0670217c 100644 (file)
@@ -84,7 +84,7 @@ end
 
 function enchanting.put(_, listname, _, stack)
        local toolstack = stack:get_name()
-       local toolname = toolstack:match("[%w_]+:([%w_]+)")
+       local toolname = toolstack:match(":([%w_]+)")
 
        if listname == "mese" and toolstack == "default:mese_crystal" then
                return stack:get_count()
index d2e649a93f3f38fc6e3b470374f53a8f7d9dd42c..b3289c5807bf5b5a14808c267fcc3ebd1a59aa5d 100644 (file)
@@ -85,35 +85,25 @@ function worktable.craftguide_formspec(meta, start_i, pagenum, stackname, recipe
                        recipe_num = 1
                end
 
-               --print(dump(minetest.get_all_craft_recipes(stackname)))
-               local items = minetest.get_all_craft_recipes(stackname)[recipe_num].items
-               local width = minetest.get_all_craft_recipes(stackname)[recipe_num].width
-               local type = minetest.get_all_craft_recipes(stackname)[recipe_num].type
-
                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 type == "cooking" or table.maxn(items) == 1 then
-                       if type == "cooking" then
-                               formspec = formspec.."image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png]"
-                       end
-                       formspec = formspec.."list[context;craft_output_recipe;5,6.3;1,1;]"
-               else
-                       if width == 0 then
-                               local rows, r = math.ceil(#items / math.min(3, #items))
-                               if rows == 3 then r = 2 else r = rows end
+               --print(dump(minetest.get_all_craft_recipes(stackname)))
+               local items = minetest.get_all_craft_recipes(stackname)[recipe_num].items
+               local type = minetest.get_all_craft_recipes(stackname)[recipe_num].type
 
-                               formspec = formspec.."list[context;craft_output_recipe;5,"..
-                                               (7.3-r)..";"..math.min(3, #items)..","..rows..";]"
-                       else
-                               local rows, r = math.ceil(table.maxn(items) / width)
-                               if rows == 3 then r = 2 else r = rows end
+               if type == "cooking" then
+                       formspec = formspec..[[ list[context;craft_output_recipe;5,6.3;1,1;]
+                                       image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png] ]]
+               else
+                       local width = minetest.get_all_craft_recipes(stackname)[recipe_num].width
+                       if width == 0 then width = math.min(3, #items) end
+                       local rows = math.ceil(table.maxn(items) / width)                       
 
-                               formspec = formspec.."list[context;craft_output_recipe;5,"..
-                                               (7.3-r)..";"..width..","..rows..";]"
-                       end
+                       formspec = formspec.."list[context;craft_output_recipe;5,"..
+                                       (7.3 - math.min(2, rows))..";"..width..","..rows..";]"
                end
 
                formspec = formspec..[[ image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]