]> git.lizzy.rs Git - xdecor.git/blobdiff - worktable.lua
Craft guide : get rid of item_image_button label on output's stack
[xdecor.git] / worktable.lua
index cd486ee3ccfcb5de9ad0255579648077e00f4285..5aa70742c91a1e736c7c5c47bd608fb2aa02d904 100644 (file)
@@ -10,8 +10,8 @@ function worktable:nodes(def)
                def.after_place_node and not def.on_rightclick and not
                def.on_blast and not def.allow_metadata_inventory_take and not
                (def.groups.not_in_creative_inventory == 1) and not
-               def.groups.wool and not def.drop and def.light_source == 0 and
-               def.description and def.description ~= ""
+               def.groups.wool and not def.description:find("Ore") and
+               def.description and def.description ~= "" and def.light_source == 0
 end
 
 -- Nodeboxes definitions.
@@ -67,14 +67,14 @@ function worktable:craftguide_formspec(meta, pagenum, item, recipe_num, filter)
        local formspec = [[ size[8,6.6;]
                        tablecolumns[color;text;color;text]
                        tableoptions[background=#00000000;highlight=#00000000;border=false]
-                       button[5.5,0;0.7,1;prev;<]
-                       button[7.3,0;0.7,1;next;>]
+                       button[5.5,0;0.7,0.95;prev;<]
+                       button[7.3,0;0.7,0.95;next;>]
                        button[4,0.2;0.7,0.5;search;?]
                        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] ]] ..
-                       "table[6.1,0.2;1.1,0.5;pagenum;#FFFF00,"..tostring(pagenum)..
+                       "table[6.1,0.18;1.1,0.5;pagenum;#FFFF00,"..tostring(pagenum)..
                        ",#FFFFFF,/ "..tostring(pagemax).."]"..
                        "field[1.8,0.32;2.6,1;filter;;"..filter.."]"..xbg
 
@@ -109,7 +109,7 @@ function worktable:craftguide_formspec(meta, pagenum, item, recipe_num, filter)
                local rows = math.ceil(table.maxn(items) / width) -- Lua 5.3 removed `table.maxn`, use `xdecor.maxn` in case of failure.
 
                local function is_group(item)
-                       if item:find("^group:") then return "G" end
+                       if item:find("^group:") then return "\nG" end
                        return ""
                end
 
@@ -118,9 +118,9 @@ function worktable:craftguide_formspec(meta, pagenum, item, recipe_num, filter)
                        (math.floor((i-1) / width + (6 - math.min(2, rows))))..";1,1;"..
                        self:get_recipe(v)..";"..self:get_recipe(v)..";"..is_group(v).."]"
                end
-               
-               local yield = minetest.get_all_craft_recipes(item)[recipe_num].output:match("%s(%d+)") or ""
-               formspec = formspec.."item_image_button[2.5,5;1,1;"..item..";"..item..";"..yield.."]"..
+
+               local output = minetest.get_all_craft_recipes(item)[recipe_num].output
+               formspec = formspec.."item_image_button[2.5,5;1,1;"..output..";"..item..";]"..
                                     "image[3.5,5;1,1;gui_furnace_arrow_bg.png^[transformR90]"
        end
 
@@ -238,7 +238,7 @@ function worktable.fields(pos, _, fields)
                worktable:craftguide_items(meta, nil)
                worktable:craftguide_formspec(meta, 1, nil, 1, "")
        elseif fields.alternate then
-               local item = formspec:match("item_image_button%[.*;([%w_:]+);.*%]") or ""
+               local item = formspec:match("image_button%[.*;([%w_:]+);.*%]") or ""
                local recipe_num = tonumber(formspec:match("Recipe%s(%d+)")) or 1
                recipe_num = recipe_num + 1
                worktable:craftguide_formspec(meta, pagenum, item, recipe_num, filter)
@@ -263,11 +263,11 @@ function worktable.dig(pos)
                inv:is_empty("tool") and inv:is_empty("storage")
 end
 
-function worktable.put(pos, listname, _, stack)
+function worktable.put(_, listname, _, stack)
        local stackname = stack:get_name()
        if (listname == "tool" and stack:get_wear() > 0 and
                        worktable.repairable_tools:find(stackname:match(":(%w+)"))) or
-                       (listname == "input" and worktable:nodes(minetest.registered_nodes[stackname])) or
+                       (listname == "input" and minetest.registered_nodes[stackname.."_cube"]) or
                        (listname == "hammer" and stackname == "xdecor:hammer") or
                        listname == "storage" or listname == "trash" then
                return stack:get_count()
@@ -284,7 +284,6 @@ function worktable.take(_, listname, _, stack, player)
        return stack:get_count()
 end
 
-
 function worktable.move(_, _, _, to_list, _, count)
        if to_list == "storage" or to_list == "trash" then return count end
        return 0
@@ -345,7 +344,7 @@ for _, d in pairs(worktable.defs) do
 for node in pairs(minetest.registered_nodes) do
        local def = minetest.registered_nodes[node]
        if worktable:nodes(def) and d[3] then
-               local groups, tiles = {}, {def.tiles[1]}
+               local groups, tiles = {}, {}
                groups.not_in_creative_inventory = 1
 
                for k, v in pairs(def.groups) do
@@ -354,12 +353,18 @@ for node in pairs(minetest.registered_nodes) do
                        end
                end
 
-               if #def.tiles > 1 and not def.drawtype:find("glass") then
-                       tiles = def.tiles
+               if def.tiles then
+                       if #def.tiles > 1 and not def.drawtype:find("glass") then
+                               tiles = def.tiles
+                       else tiles = {def.tiles[1]} end
+               else
+                       tiles = {def.tile_images[1]}
                end
 
-               stairs.register_stair_and_slab(node:match(":(.*)"), node, groups, tiles,
-                       def.description.." Stair", def.description.." Slab", def.sounds)
+               if not minetest.registered_nodes["stairs:slab_"..node:match(":(.*)")] then
+                       stairs.register_stair_and_slab(node:match(":(.*)"), node, groups, tiles,
+                               def.description.." Stair", def.description.." Slab", def.sounds)
+               end
 
                minetest.register_node(":"..node.."_"..d[1], {
                        description = def.description.." "..d[1]:gsub("^%l", string.upper),