Craft guide : improved formspec
This commit is contained in:
parent
02e86e7ca9
commit
1e9f2f8086
@ -65,9 +65,11 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname)
|
|||||||
local stack_type = minetest.get_all_craft_recipes(stackname)[recipe_num]["type"]
|
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_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+)")
|
||||||
|
local items_num = #minetest.get_all_craft_recipes(stackname)
|
||||||
|
|
||||||
if #minetest.get_all_craft_recipes(stackname) > 1 then
|
if items_num > 1 then
|
||||||
formspec = formspec.."button[1.2,5.5;1.6,1;alternate;Alternate]"
|
formspec = formspec.."button[0,5.7;1.6,1;alternate;Alternate]"..
|
||||||
|
"label[0,5.2;Recipe "..recipe_num.." of "..items_num.."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if stack_count then
|
if stack_count then
|
||||||
@ -159,8 +161,8 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname)
|
|||||||
end
|
end
|
||||||
|
|
||||||
formspec = formspec.."image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]"..
|
formspec = formspec.."image[4,6.3;1,1;gui_furnace_arrow_bg.png^[transformR90]"..
|
||||||
"button[1.2,6.35;1.6,1;trash;Clear]"..
|
"button[0,6.5;1.6,1;trash;Clear]"..
|
||||||
"label["..(12/string.len(stackname))..",7.5;"..stackname:sub(1,30).."]"
|
"label[0,7.5;"..stackname:sub(1,30).."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
meta:set_int("start_i", tostring(start_i))
|
meta:set_int("start_i", tostring(start_i))
|
||||||
@ -178,7 +180,7 @@ function worktable.craftguide_update(pos, filter)
|
|||||||
def.description and def.description ~= "" then
|
def.description and def.description ~= "" then
|
||||||
if filter and def.name:find(filter) then
|
if filter and def.name:find(filter) then
|
||||||
inv_items_list[#inv_items_list+1] = name
|
inv_items_list[#inv_items_list+1] = name
|
||||||
elseif filter == "all" then
|
elseif not filter then
|
||||||
inv_items_list[#inv_items_list+1] = name
|
inv_items_list[#inv_items_list+1] = name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -258,7 +260,7 @@ function worktable.construct(pos)
|
|||||||
meta:set_int("start_i", 0)
|
meta:set_int("start_i", 0)
|
||||||
meta:set_string("infotext", "Work Table")
|
meta:set_string("infotext", "Work Table")
|
||||||
worktable.main(pos)
|
worktable.main(pos)
|
||||||
worktable.craftguide_update(pos, "all")
|
worktable.craftguide_update(pos, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
function worktable.fields(pos, _, fields, sender)
|
function worktable.fields(pos, _, fields, sender)
|
||||||
@ -298,7 +300,7 @@ function worktable.fields(pos, _, fields, sender)
|
|||||||
worktable.craftguide_update(pos, fields.filter:lower())
|
worktable.craftguide_update(pos, fields.filter:lower())
|
||||||
worktable.craft_output_recipe(pos, 0, 1, nil)
|
worktable.craft_output_recipe(pos, 0, 1, nil)
|
||||||
elseif fields.clearfilter then
|
elseif fields.clearfilter then
|
||||||
worktable.craftguide_update(pos, "all")
|
worktable.craftguide_update(pos, nil)
|
||||||
worktable.craft_output_recipe(pos, 0, 1, nil)
|
worktable.craft_output_recipe(pos, 0, 1, nil)
|
||||||
elseif fields.prev or fields.next then
|
elseif fields.prev or fields.next then
|
||||||
if fields.prev or start_i >= inventory_size then
|
if fields.prev or start_i >= inventory_size then
|
||||||
|
Loading…
Reference in New Issue
Block a user