mirror of
https://github.com/minetest-mods/craftguide.git
synced 2025-07-06 10:00:32 +02:00
Cache recipes and fuel definitions
And refactor lots of related stuff
This commit is contained in:
273
init.lua
273
init.lua
@ -6,6 +6,8 @@ craftguide = {
|
|||||||
local mt = minetest
|
local mt = minetest
|
||||||
local player_data = {}
|
local player_data = {}
|
||||||
local init_items = {}
|
local init_items = {}
|
||||||
|
local recipes_cache = {}
|
||||||
|
local fuel_cache = {}
|
||||||
local searches = {}
|
local searches = {}
|
||||||
|
|
||||||
local progressive_mode = mt.settings:get_bool("craftguide_progressive_mode")
|
local progressive_mode = mt.settings:get_bool("craftguide_progressive_mode")
|
||||||
@ -78,24 +80,9 @@ craftguide.register_craft({
|
|||||||
items = {"default:stone"},
|
items = {"default:stone"},
|
||||||
})
|
})
|
||||||
|
|
||||||
local function get_recipe(output)
|
local function cache_recipes(output)
|
||||||
local recipe = mt.get_craft_recipe(output)
|
|
||||||
if recipe.items then
|
|
||||||
return recipe
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, #craftguide.custom_crafts do
|
|
||||||
local custom_craft = craftguide.custom_crafts[i]
|
|
||||||
if custom_craft.output:match("%S*") == output then
|
|
||||||
return custom_craft
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return {}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_recipes(output)
|
|
||||||
local recipes = mt.get_all_craft_recipes(output) or {}
|
local recipes = mt.get_all_craft_recipes(output) or {}
|
||||||
|
|
||||||
for i = 1, #craftguide.custom_crafts do
|
for i = 1, #craftguide.custom_crafts do
|
||||||
local custom_craft = craftguide.custom_crafts[i]
|
local custom_craft = craftguide.custom_crafts[i]
|
||||||
if custom_craft.output:match("%S*") == output then
|
if custom_craft.output:match("%S*") == output then
|
||||||
@ -103,7 +90,22 @@ local function get_recipes(output)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return recipes
|
if #recipes > 0 then
|
||||||
|
recipes_cache[output] = recipes
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_burntime(item)
|
||||||
|
return get_result({method = "fuel", width = 1, items = {item}}).time
|
||||||
|
end
|
||||||
|
|
||||||
|
local function cache_fuel(item)
|
||||||
|
local burntime = get_burntime(item)
|
||||||
|
if burntime > 0 then
|
||||||
|
fuel_cache[item] = burntime
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local color_codes = {
|
local color_codes = {
|
||||||
@ -116,10 +118,6 @@ local function colorize(str, color)
|
|||||||
return mt.colorize(color_codes[color], str)
|
return mt.colorize(color_codes[color], str)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_fueltime(item)
|
|
||||||
return get_result({method = "fuel", width = 1, items = {item}}).time
|
|
||||||
end
|
|
||||||
|
|
||||||
local function extract_groups(str)
|
local function extract_groups(str)
|
||||||
return str:sub(7):split(",")
|
return str:sub(7):split(",")
|
||||||
end
|
end
|
||||||
@ -154,85 +152,59 @@ local function groups_to_item(groups)
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_tooltip(item, recipe_type, cooktime, groups)
|
local function get_tooltip(item, groups, cooktime, burntime)
|
||||||
local tooltip, item_desc = "tooltip[" .. item .. ";", ""
|
local tooltip
|
||||||
local fueltime = get_fueltime(item)
|
|
||||||
local has_extras = groups or recipe_type == "cooking" or fueltime > 0
|
|
||||||
|
|
||||||
if reg_items[item] then
|
|
||||||
if not groups then
|
|
||||||
item_desc = reg_items[item].description
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return tooltip .. S("Unknown Item (@1)", item) .. "]"
|
|
||||||
end
|
|
||||||
|
|
||||||
if groups then
|
if groups then
|
||||||
local groupstr = ""
|
local groupstr = {}
|
||||||
for i = 1, #groups do
|
for i = 1, #groups do
|
||||||
groupstr = groupstr ..
|
groupstr[#groupstr + 1] = colorize(groups[i])
|
||||||
colorize(groups[i]) .. (groups[i + 1] and ", " or "")
|
end
|
||||||
|
groupstr = concat(groupstr, ", ")
|
||||||
|
tooltip = S("Any item belonging to the group(s):") .. " " .. groupstr
|
||||||
|
else
|
||||||
|
tooltip = reg_items[item].description
|
||||||
end
|
end
|
||||||
|
|
||||||
tooltip = tooltip ..
|
if cooktime then
|
||||||
S("Any item belonging to the group(s)") .. ": " .. groupstr
|
tooltip = tooltip .. "\n" .. S("Cooking time:") .. " " ..
|
||||||
|
colorize(cooktime)
|
||||||
end
|
end
|
||||||
|
|
||||||
if recipe_type == "cooking" then
|
if burntime then
|
||||||
tooltip = tooltip .. item_desc .. "\n" ..
|
tooltip = tooltip .. "\n" .. S("Burning time:") .. " " ..
|
||||||
S("Cooking time") .. ": " .. colorize(cooktime)
|
colorize(burntime)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fueltime > 0 then
|
return "tooltip[" .. item .. ";" .. tooltip .. "]"
|
||||||
tooltip = tooltip .. item_desc .. "\n" ..
|
|
||||||
S("Burning time") .. ": " .. colorize(fueltime)
|
|
||||||
end
|
|
||||||
|
|
||||||
return has_extras and tooltip .. "]" or ""
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_recipe_fs(iX, iY, xoffset, recipe_num, recipes, show_usage)
|
local function get_recipe_fs(data, iY)
|
||||||
if not recipes[1] then
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
local fs = {}
|
local fs = {}
|
||||||
|
local recipe = data.recipes[data.rnum]
|
||||||
|
local width = recipe.width
|
||||||
|
local xoffset = data.iX / 2.15
|
||||||
|
|
||||||
fs[#fs + 1] = fmt("button[%f,%f;%f,%f;%s;%s %u %s %u]",
|
local cooktime
|
||||||
iX - (sfinv_only and 2.2 or 2.6),
|
if recipe.type == "cooking" then
|
||||||
iY + (sfinv_only and 3.9 or 3.3),
|
cooktime, width = width, 1
|
||||||
2.2,
|
|
||||||
1,
|
|
||||||
"alternate",
|
|
||||||
show_usage and S("Usage") or S("Recipe"),
|
|
||||||
recipe_num,
|
|
||||||
S("of"),
|
|
||||||
#recipes)
|
|
||||||
|
|
||||||
local recipe_type = recipes[recipe_num].type
|
|
||||||
local items = recipes[recipe_num].items
|
|
||||||
local width = recipes[recipe_num].width
|
|
||||||
|
|
||||||
local cooktime = width
|
|
||||||
if recipe_type == "cooking" then
|
|
||||||
width = 1
|
|
||||||
elseif width == 0 then
|
elseif width == 0 then
|
||||||
width = min(3, #items)
|
width = min(3, #recipe.items)
|
||||||
end
|
end
|
||||||
|
|
||||||
local rows = ceil(maxn(items) / width)
|
local rows = ceil(maxn(recipe.items) / width)
|
||||||
local rightest, btn_size, s_btn_size = 0, 1.1
|
local rightest, btn_size, s_btn_size = 0, 1.1
|
||||||
|
|
||||||
if width > GRID_LIMIT or rows > GRID_LIMIT then
|
if width > GRID_LIMIT or rows > GRID_LIMIT then
|
||||||
fs[#fs + 1] = fmt("label[%f,%f;%s]",
|
fs[#fs + 1] = fmt("label[%f,%f;%s]",
|
||||||
(iX / 2) - 2,
|
(data.iX / 2) - 2,
|
||||||
iY + 2.2,
|
iY + 2.2,
|
||||||
S("Recipe is too big to be displayed (@1x@2)", width, rows))
|
S("Recipe is too big to be displayed (@1x@2)", width, rows))
|
||||||
|
|
||||||
return concat(fs)
|
return concat(fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, item in pairs(items) do
|
for i, item in pairs(recipe.items) do
|
||||||
local X = ceil((i - 1) % width + xoffset - width) -
|
local X = ceil((i - 1) % width + xoffset - width) -
|
||||||
(sfinv_only and 0 or 0.2)
|
(sfinv_only and 0 or 0.2)
|
||||||
local Y = ceil(i / width + (iY + 2) - min(2, rows))
|
local Y = ceil(i / width + (iY + 2) - min(2, rows))
|
||||||
@ -255,7 +227,6 @@ local function get_recipe_fs(iX, iY, xoffset, recipe_num, recipes, show_usage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local label = groups and "\nG" or ""
|
local label = groups and "\nG" or ""
|
||||||
local tltp = get_tooltip(item, recipe_type, cooktime, groups)
|
|
||||||
|
|
||||||
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||||
X,
|
X,
|
||||||
@ -266,7 +237,11 @@ local function get_recipe_fs(iX, iY, xoffset, recipe_num, recipes, show_usage)
|
|||||||
item:match("%S*"),
|
item:match("%S*"),
|
||||||
label)
|
label)
|
||||||
|
|
||||||
fs[#fs + 1] = tltp
|
local burntime = fuel_cache[item]
|
||||||
|
|
||||||
|
if groups or cooktime or burntime then
|
||||||
|
fs[#fs + 1] = get_tooltip(item, groups, cooktime, burntime)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local custom_recipe = craftguide.craft_types[recipe_type]
|
local custom_recipe = craftguide.craft_types[recipe_type]
|
||||||
@ -289,12 +264,9 @@ local function get_recipe_fs(iX, iY, xoffset, recipe_num, recipes, show_usage)
|
|||||||
0.5,
|
0.5,
|
||||||
0.5,
|
0.5,
|
||||||
custom_recipe and custom_recipe.description or
|
custom_recipe and custom_recipe.description or
|
||||||
recipe_type:gsub("^%l", string.upper))
|
recipe.type:gsub("^%l", string.upper))
|
||||||
end
|
end
|
||||||
|
|
||||||
local output = recipes[recipe_num].output
|
|
||||||
local output_s = output:match("%S+")
|
|
||||||
|
|
||||||
local arrow_X = rightest + (s_btn_size or 1.1)
|
local arrow_X = rightest + (s_btn_size or 1.1)
|
||||||
local output_X = arrow_X + 0.9
|
local output_X = arrow_X + 0.9
|
||||||
|
|
||||||
@ -305,7 +277,7 @@ local function get_recipe_fs(iX, iY, xoffset, recipe_num, recipes, show_usage)
|
|||||||
0.7,
|
0.7,
|
||||||
"craftguide_arrow.png")
|
"craftguide_arrow.png")
|
||||||
|
|
||||||
if output == "BURN" then
|
if recipe.type == "fuel" then
|
||||||
fs[#fs + 1] = fmt("image[%f,%f;%f,%f;%s]",
|
fs[#fs + 1] = fmt("image[%f,%f;%f,%f;%s]",
|
||||||
output_X,
|
output_X,
|
||||||
iY + (sfinv_only and 2.68 or 2.18),
|
iY + (sfinv_only and 2.68 or 2.18),
|
||||||
@ -313,19 +285,20 @@ local function get_recipe_fs(iX, iY, xoffset, recipe_num, recipes, show_usage)
|
|||||||
1.1,
|
1.1,
|
||||||
"craftguide_fire.png")
|
"craftguide_fire.png")
|
||||||
else
|
else
|
||||||
|
local output_name = recipe.output:match("%S+")
|
||||||
|
local burntime = fuel_cache[output_name]
|
||||||
|
|
||||||
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;]",
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s;]",
|
||||||
output_X,
|
output_X,
|
||||||
iY + (sfinv_only and 2.7 or 2.2),
|
iY + (sfinv_only and 2.7 or 2.2),
|
||||||
1.1,
|
1.1,
|
||||||
1.1,
|
1.1,
|
||||||
output,
|
recipe.output,
|
||||||
output_s)
|
output_name)
|
||||||
end
|
|
||||||
|
|
||||||
fs[#fs + 1] = get_tooltip(output_s)
|
if burntime then
|
||||||
|
fs[#fs + 1] = get_tooltip(output_name, nil, nil, burntime)
|
||||||
|
|
||||||
local output_is_fuel = get_fueltime(output) > 0
|
|
||||||
if output_is_fuel then
|
|
||||||
fs[#fs + 1] = fmt("image[%f,%f;%f,%f;%s]",
|
fs[#fs + 1] = fmt("image[%f,%f;%f,%f;%s]",
|
||||||
output_X + 1,
|
output_X + 1,
|
||||||
iY + (sfinv_only and 2.83 or 2.33),
|
iY + (sfinv_only and 2.83 or 2.33),
|
||||||
@ -340,6 +313,18 @@ local function get_recipe_fs(iX, iY, xoffset, recipe_num, recipes, show_usage)
|
|||||||
0.6,
|
0.6,
|
||||||
"craftguide_fire.png")
|
"craftguide_fire.png")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
fs[#fs + 1] = fmt("button[%f,%f;%f,%f;%s;%s %u %s %u]",
|
||||||
|
data.iX - (sfinv_only and 2.2 or 2.6),
|
||||||
|
iY + (sfinv_only and 3.9 or 3.3),
|
||||||
|
2.2,
|
||||||
|
1,
|
||||||
|
"alternate",
|
||||||
|
data.show_usages and S("Usage") or S("Recipe"),
|
||||||
|
data.rnum,
|
||||||
|
S("of"),
|
||||||
|
#data.recipes)
|
||||||
|
|
||||||
return concat(fs)
|
return concat(fs)
|
||||||
end
|
end
|
||||||
@ -383,8 +368,6 @@ local function make_formspec(player_name)
|
|||||||
",0.12;0.8,0.8;craftguide_next_icon.png;next;]"
|
",0.12;0.8,0.8;craftguide_next_icon.png;next;]"
|
||||||
fs[#fs + 1] = "field[0.3,0.32;2.5,1;filter;;" .. mt.formspec_escape(data.filter) .. "]"
|
fs[#fs + 1] = "field[0.3,0.32;2.5,1;filter;;" .. mt.formspec_escape(data.filter) .. "]"
|
||||||
|
|
||||||
local xoffset = data.iX / 2.15
|
|
||||||
|
|
||||||
if not next(data.items) then
|
if not next(data.items) then
|
||||||
fs[#fs + 1] = fmt("label[%f,%f;%s]",
|
fs[#fs + 1] = fmt("label[%f,%f;%s]",
|
||||||
(data.iX / 2) - 1,
|
(data.iX / 2) - 1,
|
||||||
@ -411,14 +394,8 @@ local function make_formspec(player_name)
|
|||||||
name)
|
name)
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.input then
|
if data.recipes and #data.recipes > 0 then
|
||||||
local usage = data.show_usage
|
fs[#fs + 1] = get_recipe_fs(data, iY)
|
||||||
fs[#fs + 1] = get_recipe_fs(data.iX,
|
|
||||||
iY,
|
|
||||||
xoffset,
|
|
||||||
data.rnum,
|
|
||||||
(usage and data.usages or data.recipes_item),
|
|
||||||
usage)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fs = concat(fs)
|
fs = concat(fs)
|
||||||
@ -494,7 +471,7 @@ local function get_item_usages(item)
|
|||||||
get_recipe(name).items and
|
get_recipe(name).items and
|
||||||
def.description and def.description ~= "" then
|
def.description and def.description ~= "" then
|
||||||
|
|
||||||
local recipes = get_recipes(name)
|
local recipes = recipes_cache[name]
|
||||||
for i = 1, #recipes do
|
for i = 1, #recipes do
|
||||||
local recipe = recipes[i]
|
local recipe = recipes[i]
|
||||||
if item_in_recipe(item, recipe) then
|
if item_in_recipe(item, recipe) then
|
||||||
@ -504,6 +481,10 @@ local function get_item_usages(item)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if fuel_cache[item] then
|
||||||
|
usages[#usages + 1] = {type = "fuel", width = 1, items = {item}}
|
||||||
|
end
|
||||||
|
|
||||||
return usages
|
return usages
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -605,13 +586,15 @@ local function get_progressive_items(player)
|
|||||||
local items = {}
|
local items = {}
|
||||||
for i = 1, #init_items do
|
for i = 1, #init_items do
|
||||||
local item = init_items[i]
|
local item = init_items[i]
|
||||||
local recipes = get_recipes(item)
|
local recipes = recipes_cache[item]
|
||||||
recipes = apply_progressive_filters(recipes, player)
|
|
||||||
|
|
||||||
|
if recipes then
|
||||||
|
recipes = apply_progressive_filters(recipes, player)
|
||||||
if #recipes > 0 then
|
if #recipes > 0 then
|
||||||
items[#items + 1] = item
|
items[#items + 1] = item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return items
|
return items
|
||||||
end
|
end
|
||||||
@ -628,22 +611,22 @@ local function init_data(player, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function reset_data(data)
|
local function reset_data(data)
|
||||||
data.show_usage = nil
|
|
||||||
data.filter = ""
|
data.filter = ""
|
||||||
data.input = nil
|
|
||||||
data.pagenum = 1
|
data.pagenum = 1
|
||||||
data.rnum = 1
|
data.query_item = nil
|
||||||
|
data.show_usages = nil
|
||||||
|
data.recipes = nil
|
||||||
data.items = progressive_mode and data.progressive_items or init_items
|
data.items = progressive_mode and data.progressive_items or init_items
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_init_items()
|
local function get_init_items()
|
||||||
local c = 0
|
local c = 0
|
||||||
for name, def in pairs(reg_items) do
|
for name, def in pairs(reg_items) do
|
||||||
local is_fuel = get_fueltime(name) > 0
|
local is_fuel = cache_fuel(name)
|
||||||
if not (def.groups.not_in_craft_guide == 1 or
|
if not (def.groups.not_in_craft_guide == 1 or
|
||||||
def.groups.not_in_creative_inventory == 1) and
|
def.groups.not_in_creative_inventory == 1) and
|
||||||
(get_recipe(name).items or is_fuel) and
|
def.description and def.description ~= "" and
|
||||||
def.description and def.description ~= "" then
|
(cache_recipes(name) or is_fuel) then
|
||||||
c = c + 1
|
c = c + 1
|
||||||
init_items[c] = name
|
init_items[c] = name
|
||||||
end
|
end
|
||||||
@ -663,18 +646,12 @@ local function on_receive_fields(player, fields)
|
|||||||
show_fs(player, player_name)
|
show_fs(player, player_name)
|
||||||
|
|
||||||
elseif fields.alternate then
|
elseif fields.alternate then
|
||||||
if #(data.show_usage and data.usages or data.recipes_item) == 1 then
|
if #data.recipes == 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local next_i
|
local num_next = data.rnum + 1
|
||||||
if data.show_usage then
|
data.rnum = data.recipes[num_next] and num_next or 1
|
||||||
next_i = data.usages[data.rnum + 1]
|
|
||||||
else
|
|
||||||
next_i = data.recipes_item[data.rnum + 1]
|
|
||||||
end
|
|
||||||
|
|
||||||
data.rnum = next_i and data.rnum + 1 or 1
|
|
||||||
show_fs(player, player_name)
|
show_fs(player, player_name)
|
||||||
|
|
||||||
elseif (fields.key_enter_field == "filter" or fields.search) and
|
elseif (fields.key_enter_field == "filter" or fields.search) and
|
||||||
@ -702,7 +679,7 @@ local function on_receive_fields(player, fields)
|
|||||||
elseif (fields.size_inc and data.iX < MAX_LIMIT) or
|
elseif (fields.size_inc and data.iX < MAX_LIMIT) or
|
||||||
(fields.size_dec and data.iX > MIN_LIMIT) then
|
(fields.size_dec and data.iX > MIN_LIMIT) then
|
||||||
data.pagenum = 1
|
data.pagenum = 1
|
||||||
data.iX = data.iX - (fields.size_dec and 1 or -1)
|
data.iX = data.iX + (fields.size_inc and 1 or -1)
|
||||||
show_fs(player, player_name)
|
show_fs(player, player_name)
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -720,50 +697,42 @@ local function on_receive_fields(player, fields)
|
|||||||
item = item:sub(1,-5)
|
item = item:sub(1,-5)
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_fuel = get_fueltime(item) > 0
|
local is_fuel = fuel_cache[item]
|
||||||
local recipes = get_recipes(item)
|
local recipes = recipes_cache[item]
|
||||||
if progressive_mode then
|
|
||||||
|
if progressive_mode and recipes then
|
||||||
recipes = apply_progressive_filters(recipes, player)
|
recipes = apply_progressive_filters(recipes, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
local no_recipes = not next(recipes)
|
local no_recipes = not recipes or #recipes == 0
|
||||||
if no_recipes and not is_fuel then
|
if no_recipes and not is_fuel then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if item ~= data.input then
|
if item ~= data.query_item then
|
||||||
data.show_usage = nil
|
data.show_usages = nil
|
||||||
else
|
else
|
||||||
data.show_usage = not data.show_usage
|
data.show_usages = not data.show_usages
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_fuel and no_recipes then
|
if is_fuel and no_recipes then
|
||||||
data.show_usage = true
|
data.show_usages = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.show_usage then
|
if data.show_usages then
|
||||||
data.usages = get_item_usages(item)
|
recipes = get_item_usages(item)
|
||||||
|
|
||||||
if is_fuel then
|
|
||||||
data.usages[#data.usages + 1] = {
|
|
||||||
width = 1,
|
|
||||||
type = "normal",
|
|
||||||
items = {item},
|
|
||||||
output = "BURN",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
if progressive_mode then
|
if progressive_mode then
|
||||||
data.usages = apply_progressive_filters(data.usages, player)
|
recipes = apply_progressive_filters(recipes, player)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not next(data.usages) then
|
if not next(recipes) then
|
||||||
data.show_usage = nil
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
data.input = item
|
data.query_item = item
|
||||||
data.recipes_item = recipes
|
data.recipes = recipes
|
||||||
data.rnum = 1
|
data.rnum = 1
|
||||||
|
|
||||||
show_fs(player, player_name)
|
show_fs(player, player_name)
|
||||||
@ -923,9 +892,9 @@ if not progressive_mode then
|
|||||||
local data = player_data[name]
|
local data = player_data[name]
|
||||||
reset_data(data)
|
reset_data(data)
|
||||||
|
|
||||||
local is_fuel = get_fueltime(node_name) > 0
|
local recipes = recipes_cache[node_name]
|
||||||
local recipes = get_recipes(node_name)
|
|
||||||
local no_recipes = not next(recipes)
|
local no_recipes = not next(recipes)
|
||||||
|
local is_fuel = fuel_cache[node_name]
|
||||||
|
|
||||||
if no_recipes and not is_fuel then
|
if no_recipes and not is_fuel then
|
||||||
return false, colorize("[craftguide] ", "red") ..
|
return false, colorize("[craftguide] ", "red") ..
|
||||||
@ -934,23 +903,15 @@ if not progressive_mode then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if is_fuel and no_recipes then
|
if is_fuel and no_recipes then
|
||||||
data.usages = get_item_usages(node_name)
|
recipes = get_item_usages(node_name)
|
||||||
if is_fuel then
|
|
||||||
data.usages[#data.usages + 1] = {
|
|
||||||
width = 1,
|
|
||||||
type = "normal",
|
|
||||||
items = {node_name},
|
|
||||||
output = "BURN",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
if next(data.usages) then
|
if next(recipes) then
|
||||||
data.show_usage = true
|
data.show_usages = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
data.input = node_name
|
data.query_item = node_name
|
||||||
data.recipes_item = recipes
|
data.recipes = recipes
|
||||||
|
|
||||||
return true, show_fs(player, name)
|
return true, show_fs(player, name)
|
||||||
end,
|
end,
|
||||||
|
Reference in New Issue
Block a user