Various clean-ups and update inv size on clicking on [Guide] button instead
after constructing
This commit is contained in:
parent
f16aac2f21
commit
04b1dccb5e
@ -403,7 +403,7 @@ minetest.register_craft({
|
|||||||
output = "xdecor:wood_tile 2",
|
output = "xdecor:wood_tile 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "group:wood", ""},
|
{"", "group:wood", ""},
|
||||||
{"group:wood", "group:wood", "group:wood"},
|
{"group:wood", "", "group:wood"},
|
||||||
{"", "group:wood", ""}
|
{"", "group:wood", ""}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -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_items = minetest.get_all_craft_recipes(stackname)[recipe_num].items
|
||||||
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+)") or 1
|
||||||
|
|
||||||
|
inv:set_stack("item_craft_input", 1, stackname.." "..stack_count)
|
||||||
|
|
||||||
if items_num > 1 then
|
if items_num > 1 then
|
||||||
formspec = formspec.."button[0,5.7;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.."]"
|
"label[0,5.2;Recipe "..recipe_num.." of "..items_num.."]"
|
||||||
end
|
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" or table.maxn(stack_items) == 1 then
|
||||||
if stack_type == "cooking" then
|
if stack_type == "cooking" then
|
||||||
formspec = formspec.."image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png]"
|
formspec = formspec.."image[4.25,5.9;0.5,0.5;default_furnace_fire_fg.png]"
|
||||||
@ -107,20 +103,18 @@ function worktable.craft_output_recipe(pos, start_i, pagenum, stackname, recipe_
|
|||||||
if def and def:find("^group:") then
|
if def and def:find("^group:") then
|
||||||
if def:find("wool$") or def:find("dye$") then
|
if def:find("wool$") or def:find("dye$") then
|
||||||
def = def:match(":([%w_]+)")..":white"
|
def = def:match(":([%w_]+)")..":white"
|
||||||
|
elseif minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
|
||||||
|
def = def:gsub("group", "default")
|
||||||
else
|
else
|
||||||
if minetest.registered_items["default:"..def:match("^group:([%w_,]+)$")] then
|
for node, definition in pairs(minetest.registered_items) do
|
||||||
def = def:gsub("group", "default")
|
for group in pairs(definition.groups) do
|
||||||
else
|
if def:match("^group:"..group.."$") or
|
||||||
for node, definition in pairs(minetest.registered_items) do
|
((def:find("dye") or def:find("flower")) and
|
||||||
for group in pairs(definition.groups) do
|
group == def:match("^group:.*,("..group..")")) then
|
||||||
if def:match("^group:"..group.."$") or
|
def = node
|
||||||
((def:find("dye") or def:find("flower")) and
|
|
||||||
group == def:match("^group:.*,("..group..")")) then
|
|
||||||
def = node
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -220,7 +214,6 @@ function worktable.construct(pos)
|
|||||||
meta:set_string("infotext", "Work Table")
|
meta:set_string("infotext", "Work Table")
|
||||||
|
|
||||||
worktable.main(pos)
|
worktable.main(pos)
|
||||||
worktable.craftguide_update(pos, nil)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function worktable.fields(pos, _, fields, sender)
|
function worktable.fields(pos, _, fields, sender)
|
||||||
@ -241,7 +234,6 @@ function worktable.fields(pos, _, fields, sender)
|
|||||||
end
|
end
|
||||||
worktable.crafting(pos)
|
worktable.crafting(pos)
|
||||||
elseif fields.craftguide then
|
elseif fields.craftguide then
|
||||||
if not meta:to_table().inventory.inv_items_list then return end -- legacy code
|
|
||||||
worktable.craftguide_update(pos, nil)
|
worktable.craftguide_update(pos, nil)
|
||||||
worktable.craft_output_recipe(pos, 0, 1, nil, 1, "")
|
worktable.craft_output_recipe(pos, 0, 1, nil, 1, "")
|
||||||
elseif fields.alternate then
|
elseif fields.alternate then
|
||||||
|
Loading…
Reference in New Issue
Block a user