Various clean-ups and update inv size on clicking on [Guide] button instead

after constructing
This commit is contained in:
kilbith 2016-01-04 11:41:15 +01:00
parent f16aac2f21
commit 04b1dccb5e
2 changed files with 13 additions and 21 deletions

View 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", ""}
}
})

View 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,8 +103,7 @@ 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"
else
if minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
elseif minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
def = def:gsub("group", "default")
else
for node, definition in pairs(minetest.registered_items) do
@ -122,7 +117,6 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
end
end
end
end
inv:set_stack("craft_output_recipe", k, def)
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