Compare commits
34 Commits
Author | SHA1 | Date | |
---|---|---|---|
103624bc28 | |||
bf28a48c40 | |||
bd5c5fcd16 | |||
095e45197e | |||
13252049c2 | |||
87177d0d7f | |||
109965175d | |||
4ff200dfd9 | |||
3baab53b84 | |||
8a4fbd0933 | |||
5560374801 | |||
5e23600001 | |||
f39ca50f3b | |||
450797e148 | |||
6d994fc8d5 | |||
1910b4b345 | |||
4823a9dd62 | |||
689840d6f5 | |||
3f34d275c1 | |||
8c7408f66f | |||
4483f60cbc | |||
79693f5c88 | |||
b8c491a489 | |||
34231e01df | |||
2d6951cd0c | |||
df21df2bce | |||
5669bcdcb7 | |||
3ad05328bf | |||
7793019357 | |||
a97c0b96b3 | |||
63769603c4 | |||
189a3ff971 | |||
ca723202d6 | |||
a3e7031c04 |
@ -19,4 +19,4 @@ For developers, `craftguide` also has a [modding API](https://github.com/minetes
|
|||||||
Love this mod? Donations are appreciated: https://www.paypal.me/jpg84240
|
Love this mod? Donations are appreciated: https://www.paypal.me/jpg84240
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
347
init.lua
@ -10,10 +10,12 @@ local fuel_cache = {}
|
|||||||
|
|
||||||
local toolrepair
|
local toolrepair
|
||||||
|
|
||||||
local progressive_mode = core.settings:get_bool("craftguide_progressive_mode")
|
local progressive_mode = core.settings:get_bool "craftguide_progressive_mode"
|
||||||
local sfinv_only = core.settings:get_bool("craftguide_sfinv_only") and rawget(_G, "sfinv")
|
local sfinv_only = core.settings:get_bool "craftguide_sfinv_only" and rawget(_G, "sfinv")
|
||||||
|
local autocache = core.settings:get_bool "craftguide_autocache"
|
||||||
|
|
||||||
local http = core.request_http_api()
|
local http = core.request_http_api()
|
||||||
|
local storage = core.get_mod_storage()
|
||||||
|
|
||||||
local reg_items = core.registered_items
|
local reg_items = core.registered_items
|
||||||
local reg_tools = core.registered_tools
|
local reg_tools = core.registered_tools
|
||||||
@ -41,7 +43,7 @@ local get_player_info = core.get_player_information
|
|||||||
local on_receive_fields = core.register_on_player_receive_fields
|
local on_receive_fields = core.register_on_player_receive_fields
|
||||||
|
|
||||||
local ESC = core.formspec_escape
|
local ESC = core.formspec_escape
|
||||||
local S = core.get_translator("craftguide")
|
local S = core.get_translator "craftguide"
|
||||||
|
|
||||||
local ES = function(...)
|
local ES = function(...)
|
||||||
return ESC(S(...))
|
return ESC(S(...))
|
||||||
@ -56,9 +58,11 @@ local fmt, find, gmatch, match, sub, split, upper, lower =
|
|||||||
string.sub, string.split, string.upper, string.lower
|
string.sub, string.split, string.upper, string.lower
|
||||||
|
|
||||||
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
|
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
|
||||||
local pairs, next, type, tostring, io = pairs, next, type, tostring, io
|
local pairs, next, type, tostring, unpack = pairs, next, type, tostring, unpack
|
||||||
local vec_add, vec_mul = vector.add, vector.multiply
|
local vec_add, vec_mul = vector.add, vector.multiply
|
||||||
|
|
||||||
|
local FORMSPEC_MINIMAL_VERSION = 3
|
||||||
|
|
||||||
local ROWS = 9
|
local ROWS = 9
|
||||||
local LINES = sfinv_only and 5 or 9
|
local LINES = sfinv_only and 5 or 9
|
||||||
local IPP = ROWS * LINES
|
local IPP = ROWS * LINES
|
||||||
@ -76,9 +80,12 @@ local PNG = {
|
|||||||
next = "craftguide_next_icon.png",
|
next = "craftguide_next_icon.png",
|
||||||
arrow = "craftguide_arrow.png",
|
arrow = "craftguide_arrow.png",
|
||||||
fire = "craftguide_fire.png",
|
fire = "craftguide_fire.png",
|
||||||
|
fire_anim = "craftguide_fire_anim.png",
|
||||||
book = "craftguide_book.png",
|
book = "craftguide_book.png",
|
||||||
sign = "craftguide_sign.png",
|
sign = "craftguide_sign.png",
|
||||||
|
nothing = "craftguide_no.png",
|
||||||
selected = "craftguide_selected.png",
|
selected = "craftguide_selected.png",
|
||||||
|
furnace_anim = "craftguide_furnace_anim.png",
|
||||||
|
|
||||||
search_hover = "craftguide_search_icon_hover.png",
|
search_hover = "craftguide_search_icon_hover.png",
|
||||||
clear_hover = "craftguide_clear_icon_hover.png",
|
clear_hover = "craftguide_clear_icon_hover.png",
|
||||||
@ -94,10 +101,16 @@ local FMT = {
|
|||||||
tooltip = "tooltip[%f,%f;%f,%f;%s]",
|
tooltip = "tooltip[%f,%f;%f,%f;%s]",
|
||||||
item_image = "item_image[%f,%f;%f,%f;%s]",
|
item_image = "item_image[%f,%f;%f,%f;%s]",
|
||||||
image_button = "image_button[%f,%f;%f,%f;%s;%s;%s]",
|
image_button = "image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||||
|
animated_image = "animated_image[%f,%f;%f,%f;;%s;%u;%u]",
|
||||||
item_image_button = "item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
item_image_button = "item_image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||||
arrow = "image_button[%f,%f;0.8,0.8;%s;%s;;;false;%s]",
|
arrow = "image_button[%f,%f;0.8,0.8;%s;%s;;;false;%s]",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function get_fs_version(name)
|
||||||
|
local info = get_player_info(name)
|
||||||
|
return info and info.formspec_version or 1
|
||||||
|
end
|
||||||
|
|
||||||
local function mul_elem(elem, n)
|
local function mul_elem(elem, n)
|
||||||
local fstr, elems = "", {}
|
local fstr, elems = "", {}
|
||||||
|
|
||||||
@ -112,6 +125,8 @@ end
|
|||||||
craftguide.group_stereotypes = {
|
craftguide.group_stereotypes = {
|
||||||
dye = "dye:white",
|
dye = "dye:white",
|
||||||
wool = "wool:white",
|
wool = "wool:white",
|
||||||
|
wood = "default:wood",
|
||||||
|
tree = "default:tree",
|
||||||
coal = "default:coal_lump",
|
coal = "default:coal_lump",
|
||||||
vessel = "vessels:glass_bottle",
|
vessel = "vessels:glass_bottle",
|
||||||
flower = "flowers:dandelion_yellow",
|
flower = "flowers:dandelion_yellow",
|
||||||
@ -119,12 +134,48 @@ craftguide.group_stereotypes = {
|
|||||||
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local group_names = {
|
||||||
|
coal = S"Any coal",
|
||||||
|
wool = S"Any wool",
|
||||||
|
wood = S"Any wood planks",
|
||||||
|
sand = S"Any sand",
|
||||||
|
stick = S"Any stick",
|
||||||
|
stone = S"Any kind of stone block",
|
||||||
|
tree = S"Any tree",
|
||||||
|
vessel = S"Any vessel",
|
||||||
|
|
||||||
|
["color_red,flower"] = S"Any red flower",
|
||||||
|
["color_blue,flower"] = S"Any blue flower",
|
||||||
|
["color_black,flower"] = S"Any black flower",
|
||||||
|
["color_white,flower"] = S"Any white flower",
|
||||||
|
["color_green,flower"] = S"Any green flower",
|
||||||
|
["color_orange,flower"] = S"Any orange flower",
|
||||||
|
["color_yellow,flower"] = S"Any yellow flower",
|
||||||
|
["color_violet,flower"] = S"Any violet flower",
|
||||||
|
|
||||||
|
["color_red,dye"] = S"Any red dye",
|
||||||
|
["color_blue,dye"] = S"Any blue dye",
|
||||||
|
["color_grey,dye"] = S"Any grey dye",
|
||||||
|
["color_pink,dye"] = S"Any pink dye",
|
||||||
|
["color_cyan,dye"] = S"Any cyan dye",
|
||||||
|
["color_black,dye"] = S"Any black dye",
|
||||||
|
["color_white,dye"] = S"Any white dye",
|
||||||
|
["color_brown,dye"] = S"Any brown dye",
|
||||||
|
["color_green,dye"] = S"Any green dye",
|
||||||
|
["color_orange,dye"] = S"Any orange dye",
|
||||||
|
["color_yellow,dye"] = S"Any yellow dye",
|
||||||
|
["color_violet,dye"] = S"Any violet dye",
|
||||||
|
["color_magenta,dye"] = S"Any magenta dye",
|
||||||
|
["color_dark_grey,dye"] = S"Any dark grey dye",
|
||||||
|
["color_dark_green,dye"] = S"Any dark green dye",
|
||||||
|
}
|
||||||
|
|
||||||
local function err(str)
|
local function err(str)
|
||||||
return log("error", str)
|
return log("error", str)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function msg(name, str)
|
local function msg(name, str)
|
||||||
return chat_send(name, fmt("[craftguide] %s", clr("#f00", str)))
|
return chat_send(name, fmt("[craftguide] %s", str))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_str(x)
|
local function is_str(x)
|
||||||
@ -186,6 +237,7 @@ local function table_eq(T1, T2)
|
|||||||
|
|
||||||
local function recurse(t1, t2)
|
local function recurse(t1, t2)
|
||||||
if type(t1) ~= type(t2) then return end
|
if type(t1) ~= type(t2) then return end
|
||||||
|
|
||||||
if not is_table(t1) then
|
if not is_table(t1) then
|
||||||
return t1 == t2
|
return t1 == t2
|
||||||
end
|
end
|
||||||
@ -266,7 +318,7 @@ local craft_types = {}
|
|||||||
|
|
||||||
function craftguide.register_craft_type(name, def)
|
function craftguide.register_craft_type(name, def)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err"craftguide.register_craft_type(): name missing"
|
return err "craftguide.register_craft_type(): name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
if not is_str(def.description) then
|
if not is_str(def.description) then
|
||||||
@ -285,8 +337,9 @@ function craftguide.register_craft(def)
|
|||||||
|
|
||||||
if true_str(def.url) then
|
if true_str(def.url) then
|
||||||
if not http then
|
if not http then
|
||||||
return err"No HTTP support for this mod. " ..
|
return err(fmt([[craftguide.register_craft(): Unable to reach %s.
|
||||||
"Add it to the `secure.http_mods` or `secure.trusted_mods` setting."
|
No HTTP support for this mod: add it to the `secure.http_mods` or
|
||||||
|
`secure.trusted_mods` setting.]], def.url))
|
||||||
end
|
end
|
||||||
|
|
||||||
http.fetch({url = def.url}, function(result)
|
http.fetch({url = def.url}, function(result)
|
||||||
@ -302,7 +355,7 @@ function craftguide.register_craft(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not is_table(def) or not next(def) then
|
if not is_table(def) or not next(def) then
|
||||||
return err"craftguide.register_craft(): craft definition missing"
|
return err "craftguide.register_craft(): craft definition missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
if #def > 1 then
|
if #def > 1 then
|
||||||
@ -318,7 +371,7 @@ function craftguide.register_craft(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not true_str(def.output) then
|
if not true_str(def.output) then
|
||||||
return err"craftguide.register_craft(): output missing"
|
return err "craftguide.register_craft(): output missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
if not is_table(def.items) then
|
if not is_table(def.items) then
|
||||||
@ -388,9 +441,9 @@ local recipe_filters = {}
|
|||||||
|
|
||||||
function craftguide.add_recipe_filter(name, f)
|
function craftguide.add_recipe_filter(name, f)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err"craftguide.add_recipe_filter(): name missing"
|
return err "craftguide.add_recipe_filter(): name missing"
|
||||||
elseif not is_func(f) then
|
elseif not is_func(f) then
|
||||||
return err"craftguide.add_recipe_filter(): function missing"
|
return err "craftguide.add_recipe_filter(): function missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
recipe_filters[name] = f
|
recipe_filters[name] = f
|
||||||
@ -398,9 +451,9 @@ end
|
|||||||
|
|
||||||
function craftguide.set_recipe_filter(name, f)
|
function craftguide.set_recipe_filter(name, f)
|
||||||
if not is_str(name) then
|
if not is_str(name) then
|
||||||
return err"craftguide.set_recipe_filter(): name missing"
|
return err "craftguide.set_recipe_filter(): name missing"
|
||||||
elseif not is_func(f) then
|
elseif not is_func(f) then
|
||||||
return err"craftguide.set_recipe_filter(): function missing"
|
return err "craftguide.set_recipe_filter(): function missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
recipe_filters = {[name] = f}
|
recipe_filters = {[name] = f}
|
||||||
@ -426,9 +479,9 @@ local search_filters = {}
|
|||||||
|
|
||||||
function craftguide.add_search_filter(name, f)
|
function craftguide.add_search_filter(name, f)
|
||||||
if not true_str(name) then
|
if not true_str(name) then
|
||||||
return err"craftguide.add_search_filter(): name missing"
|
return err "craftguide.add_search_filter(): name missing"
|
||||||
elseif not is_func(f) then
|
elseif not is_func(f) then
|
||||||
return err"craftguide.add_search_filter(): function missing"
|
return err "craftguide.add_search_filter(): function missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
search_filters[name] = f
|
search_filters[name] = f
|
||||||
@ -457,6 +510,7 @@ end
|
|||||||
|
|
||||||
local function item_in_recipe(item, recipe)
|
local function item_in_recipe(item, recipe)
|
||||||
local clean_item = reg_aliases[item] or item
|
local clean_item = reg_aliases[item] or item
|
||||||
|
|
||||||
for _, recipe_item in pairs(recipe.items) do
|
for _, recipe_item in pairs(recipe.items) do
|
||||||
local clean_recipe_item = reg_aliases[recipe_item] or recipe_item
|
local clean_recipe_item = reg_aliases[recipe_item] or recipe_item
|
||||||
if clean_recipe_item == clean_item then
|
if clean_recipe_item == clean_item then
|
||||||
@ -659,6 +713,10 @@ local function get_tooltip(name, info)
|
|||||||
local tooltip
|
local tooltip
|
||||||
|
|
||||||
if info.groups then
|
if info.groups then
|
||||||
|
sort(info.groups)
|
||||||
|
tooltip = group_names[concat(info.groups, ",")]
|
||||||
|
|
||||||
|
if not tooltip then
|
||||||
local groupstr, c = {}, 0
|
local groupstr, c = {}, 0
|
||||||
|
|
||||||
for i = 1, #info.groups do
|
for i = 1, #info.groups do
|
||||||
@ -668,6 +726,7 @@ local function get_tooltip(name, info)
|
|||||||
|
|
||||||
groupstr = concat(groupstr, ", ")
|
groupstr = concat(groupstr, ", ")
|
||||||
tooltip = S("Any item belonging to the group(s): @1", groupstr)
|
tooltip = S("Any item belonging to the group(s): @1", groupstr)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
tooltip = get_desc(name)
|
tooltip = get_desc(name)
|
||||||
end
|
end
|
||||||
@ -720,43 +779,40 @@ local function get_output_fs(data, fs, L)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local pos_x = L.rightest + L.btn_size + 0.1
|
local pos_x = L.rightest + L.btn_size + 0.1
|
||||||
local pos_y = YOFFSET + (sfinv_only and 0.25 or -0.45)
|
local pos_y = YOFFSET + (sfinv_only and 0.25 or -0.45) + L.spacing
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.image, pos_x, pos_y + L.spacing, 0.5, 0.5, icon)
|
if sub(icon, 1, 18) == "craftguide_furnace" then
|
||||||
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
||||||
|
pos_x, pos_y, 0.5, 0.5, PNG.furnace_anim, 8, 180)
|
||||||
|
else
|
||||||
|
fs[#fs + 1] = fmt(FMT.image, pos_x, pos_y, 0.5, 0.5, icon)
|
||||||
|
end
|
||||||
|
|
||||||
local tooltip = custom_recipe and custom_recipe.description or
|
local tooltip = custom_recipe and custom_recipe.description or
|
||||||
L.shapeless and S"Shapeless" or S"Cooking"
|
L.shapeless and S"Shapeless" or S"Cooking"
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y + L.spacing, 0.5, 0.5, ESC(tooltip))
|
fs[#fs + 1] = fmt(FMT.tooltip, pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
|
||||||
end
|
end
|
||||||
|
|
||||||
local arrow_X = L.rightest + (L._btn_size or 1.1)
|
local arrow_X = L.rightest + (L._btn_size or 1.1)
|
||||||
local output_X = arrow_X + 0.9
|
local output_X = arrow_X + 0.9
|
||||||
|
local Y = YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
fs[#fs + 1] = fmt(FMT.image, arrow_X, Y + 0.2, 0.9, 0.7, PNG.arrow)
|
||||||
arrow_X, YOFFSET + (sfinv_only and 0.9 or 0.2) + L.spacing,
|
|
||||||
0.9, 0.7, PNG.arrow)
|
|
||||||
|
|
||||||
if L.recipe.type == "fuel" then
|
if L.recipe.type == "fuel" then
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
fs[#fs + 1] = fmt(FMT.animated_image, output_X, Y, 1.1, 1.1, PNG.fire_anim, 8, 180)
|
||||||
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
|
|
||||||
1.1, 1.1, PNG.fire)
|
|
||||||
else
|
else
|
||||||
local item = L.recipe.output
|
local item = L.recipe.output
|
||||||
item = clean_name(item)
|
item = clean_name(item)
|
||||||
local name = match(item, "%S*")
|
local name = match(item, "%S*")
|
||||||
|
|
||||||
if data.fs_version >= 3 then
|
fs[#fs + 1] = fmt(FMT.image, output_X, Y, 1.1, 1.1, PNG.selected)
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
|
||||||
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
|
|
||||||
1.1, 1.1, PNG.selected)
|
|
||||||
end
|
|
||||||
|
|
||||||
local _name = sfinv_only and name or fmt("_%s", name)
|
local _name = sfinv_only and name or fmt("_%s", name)
|
||||||
|
|
||||||
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]",
|
||||||
output_X, YOFFSET + (sfinv_only and 0.7 or 0) + L.spacing,
|
output_X, Y, 1.1, 1.1, item, _name, "")
|
||||||
1.1, 1.1, item, _name, "")
|
|
||||||
|
|
||||||
local infos = {
|
local infos = {
|
||||||
unknown = not reg_items[name] or nil,
|
unknown = not reg_items[name] or nil,
|
||||||
@ -774,9 +830,9 @@ local function get_output_fs(data, fs, L)
|
|||||||
output_X + 1, YOFFSET + (sfinv_only and 0.7 or 0.1) + L.spacing,
|
output_X + 1, YOFFSET + (sfinv_only and 0.7 or 0.1) + L.spacing,
|
||||||
0.6, 0.4, PNG.arrow)
|
0.6, 0.4, PNG.arrow)
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
fs[#fs + 1] = fmt(FMT.animated_image,
|
||||||
output_X + 1.6, YOFFSET + (sfinv_only and 0.55 or 0) + L.spacing,
|
output_X + 1.6, YOFFSET + (sfinv_only and 0.55 or 0) + L.spacing,
|
||||||
0.6, 0.6, PNG.fire)
|
0.6, 0.6, PNG.fire_anim, 8, 180)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -831,9 +887,9 @@ local function get_grid_fs(data, fs, rcp, spacing)
|
|||||||
_btn_size = btn_size
|
_btn_size = btn_size
|
||||||
|
|
||||||
X = (btn_size * ((i - 1) % width) + XOFFSET -
|
X = (btn_size * ((i - 1) % width) + XOFFSET -
|
||||||
(sfinv_only and 2.83 or 0.5)) * (0.83 - (x_y / 5))
|
(sfinv_only and 2.83 or 0)) * (0.83 - (x_y / 5))
|
||||||
Y = (btn_size * floor((i - 1) / width) +
|
Y = (btn_size * floor((i - 1) / width) +
|
||||||
(sfinv_only and 5.81 or 5.5) + x_y) * (0.86 - (x_y / 5))
|
(sfinv_only and 5.81 or 3.92) + x_y) * (0.86 - (x_y / 5))
|
||||||
end
|
end
|
||||||
|
|
||||||
if X > rightest then
|
if X > rightest then
|
||||||
@ -860,14 +916,14 @@ local function get_grid_fs(data, fs, rcp, spacing)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.fs_version >= 3 and not large_recipe then
|
Y = Y + (sfinv_only and 0.7 or 0)
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
|
||||||
X, Y + (sfinv_only and 0.7 or 0), btn_size, btn_size, PNG.selected)
|
if not large_recipe then
|
||||||
|
fs[#fs + 1] = fmt(FMT.image, X, Y, btn_size, btn_size, PNG.selected)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.item_image_button,
|
fs[#fs + 1] = fmt(FMT.item_image_button,
|
||||||
X, Y + (sfinv_only and 0.7 or 0),
|
X, Y, btn_size, btn_size, item, item, label)
|
||||||
btn_size, btn_size, item, item, ESC(label))
|
|
||||||
|
|
||||||
local infos = {
|
local infos = {
|
||||||
unknown = not reg_items[name] or nil,
|
unknown = not reg_items[name] or nil,
|
||||||
@ -898,19 +954,17 @@ local function get_grid_fs(data, fs, rcp, spacing)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_panels(data, fs)
|
local function get_panels(data, fs)
|
||||||
local start_y = data.fs_version >= 3 and (sfinv_only and 0.33 or 0) or 0.33
|
local start_y = sfinv_only and 0.33 or 0
|
||||||
|
|
||||||
local panels = {
|
local panels = {
|
||||||
{dat = data.usages or {}, height = 3.5},
|
{dat = data.usages or {}, height = 3.5},
|
||||||
{dat = data.recipes or {}, height = 3.5},
|
{dat = data.recipes or {}, height = 3.5},
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.fs_version >= 3 and not sfinv_only then
|
if not sfinv_only then
|
||||||
panels.favs = {dat = {}, height = 2.19}
|
panels.favs = {height = 2.19}
|
||||||
|
else
|
||||||
elseif sfinv_only then
|
panels = data.show_usages and {{dat = data.usages}} or {{dat = data.recipes}}
|
||||||
panels = data.show_usages and
|
|
||||||
{{dat = data.usages}} or {{dat = data.recipes}}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(panels) do
|
for k, v in pairs(panels) do
|
||||||
@ -921,7 +975,7 @@ local function get_panels(data, fs)
|
|||||||
fs[#fs + 1] = fmt("background9[8.1,%f;6.6,%f;%s;false;%d]",
|
fs[#fs + 1] = fmt("background9[8.1,%f;6.6,%f;%s;false;%d]",
|
||||||
-0.2 + spacing, v.height, PNG.bg_full, 10)
|
-0.2 + spacing, v.height, PNG.bg_full, 10)
|
||||||
|
|
||||||
if data.fs_version >= 3 and k == 2 then
|
if k == 2 then
|
||||||
local fav = is_fav(data)
|
local fav = is_fav(data)
|
||||||
local nfavs = #data.favs
|
local nfavs = #data.favs
|
||||||
|
|
||||||
@ -941,7 +995,7 @@ local function get_panels(data, fs)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local rn = #v.dat
|
local rn = v.dat and #v.dat or -1
|
||||||
local _rn = tostring(rn)
|
local _rn = tostring(rn)
|
||||||
local xu = tostring(data.unum) .. _rn
|
local xu = tostring(data.unum) .. _rn
|
||||||
local xr = tostring(data.rnum) .. _rn
|
local xr = tostring(data.rnum) .. _rn
|
||||||
@ -949,10 +1003,16 @@ local function get_panels(data, fs)
|
|||||||
xr = max(-0.3, -((#xr - 3) * 0.05))
|
xr = max(-0.3, -((#xr - 3) * 0.05))
|
||||||
|
|
||||||
local is_recipe = sfinv_only and not data.show_usages or k == 2
|
local is_recipe = sfinv_only and not data.show_usages or k == 2
|
||||||
local lbl
|
local lbl = ""
|
||||||
|
|
||||||
if not sfinv_only and rn == 0 then
|
if not sfinv_only and rn == 0 then
|
||||||
lbl = clr("#f00", is_recipe and ES"No recipes" or ES"No usages")
|
local X = XOFFSET - 0.7
|
||||||
|
local Y = YOFFSET - 0.4 + spacing
|
||||||
|
|
||||||
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 2, 2, PNG.nothing)
|
||||||
|
|
||||||
|
fs[#fs + 1] = fmt(FMT.tooltip,
|
||||||
|
X, Y, 2, 2, is_recipe and ES"No recipes" or ES"No usages")
|
||||||
|
|
||||||
elseif (not sfinv_only and is_recipe) or
|
elseif (not sfinv_only and is_recipe) or
|
||||||
(sfinv_only and not data.show_usages) then
|
(sfinv_only and not data.show_usages) then
|
||||||
@ -978,39 +1038,31 @@ local function get_panels(data, fs)
|
|||||||
local x_arrow = XOFFSET + (sfinv_only and 1.7 or 1)
|
local x_arrow = XOFFSET + (sfinv_only and 1.7 or 1)
|
||||||
local y_arrow = YOFFSET + (sfinv_only and 3.3 or 1.4 + spacing)
|
local y_arrow = YOFFSET + (sfinv_only and 3.3 or 1.4 + spacing)
|
||||||
|
|
||||||
if data.fs_version >= 3 then
|
|
||||||
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
||||||
x_arrow + (is_recipe and xr or xu), y_arrow,
|
x_arrow + (is_recipe and xr or xu), y_arrow,
|
||||||
PNG.prev, prev_name, "",
|
PNG.prev, prev_name, "",
|
||||||
x_arrow + 1.8, y_arrow, PNG.next, next_name, "")
|
x_arrow + 1.8, y_arrow, PNG.next, next_name, "")
|
||||||
else
|
|
||||||
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
|
||||||
x_arrow + (is_recipe and xr or xu),
|
|
||||||
y_arrow, PNG.prev, prev_name, PNG.prev_hover,
|
|
||||||
x_arrow + 1.8, y_arrow, PNG.next, next_name, PNG.next_hover)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local rcp = is_recipe and v.dat[data.rnum] or v.dat[data.unum]
|
local rcp = v.dat and (is_recipe and v.dat[data.rnum] or v.dat[data.unum])
|
||||||
if rcp then
|
if rcp then
|
||||||
get_grid_fs(data, fs, rcp, spacing)
|
get_grid_fs(data, fs, rcp, spacing)
|
||||||
end
|
end
|
||||||
|
|
||||||
if k == "favs" and data.fs_version >= 3 and not sfinv_only then
|
if k == "favs" and not sfinv_only then
|
||||||
fs[#fs + 1] = fmt(FMT.label, 8.3, spacing - 0.1, ES"Bookmarks")
|
fs[#fs + 1] = fmt(FMT.label, 8.3, spacing - 0.1, ES"Bookmarks")
|
||||||
|
|
||||||
for i = 1, #data.favs do
|
for i = 1, #data.favs do
|
||||||
local item = data.favs[i]
|
local item = data.favs[i]
|
||||||
|
local X = 7.85 + (i - 0.5)
|
||||||
|
local Y = spacing + 0.45
|
||||||
|
|
||||||
if data.query_item == item then
|
if data.query_item == item then
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 1.1, 1.1, PNG.selected)
|
||||||
7.85 + (i - 0.5), spacing + 0.45,
|
|
||||||
1.1, 1.1, PNG.selected)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.item_image_button,
|
fs[#fs + 1] = fmt(FMT.item_image_button,
|
||||||
7.85 + (i - 0.5), spacing + 0.45,
|
X, Y, 1.1, 1.1, item, item, "")
|
||||||
1.1, 1.1, item, item, "")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1024,20 +1076,21 @@ local function make_fs(data)
|
|||||||
no_prepend[]
|
no_prepend[]
|
||||||
bgcolor[#0000]
|
bgcolor[#0000]
|
||||||
]],
|
]],
|
||||||
ROWS + (data.query_item and 6.7 or 0) - 1.2, LINES - 0.3)
|
9 + (data.query_item and 6.7 or 0) - 1.2, LINES - 0.3)
|
||||||
|
|
||||||
if not sfinv_only then
|
if not sfinv_only then
|
||||||
fs[#fs + 1] = fmt("background9[-0.15,-0.2;%f,%f;%s;false;%d]",
|
fs[#fs + 1] = fmt("background9[-0.15,-0.2;%f,%f;%s;false;%d]",
|
||||||
ROWS - 0.9, LINES + 0.4, PNG.bg_full, 10)
|
9 - 0.9, LINES + 0.4, PNG.bg_full, 10)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt([[
|
fs[#fs + 1] = fmt([[
|
||||||
field[0.25,0.2;%f,1;filter;;%s]
|
style[filter;border=false]
|
||||||
|
field[0.4,0.2;2.5,1;filter;;%s]
|
||||||
field_close_on_enter[filter;false]
|
field_close_on_enter[filter;false]
|
||||||
|
box[0,0;2.4,0.6;#bababa25]
|
||||||
]],
|
]],
|
||||||
sfinv_only and 2.76 or 2.72, ESC(data.filter))
|
ESC(data.filter))
|
||||||
|
|
||||||
if data.fs_version >= 3 then
|
|
||||||
fs[#fs + 1] = fmt([[
|
fs[#fs + 1] = fmt([[
|
||||||
style_type[image_button;border=false]
|
style_type[image_button;border=false]
|
||||||
style_type[item_image_button;border=false;bgimg_hovered=%s;bgimg_pressed=%s]
|
style_type[item_image_button;border=false;bgimg_hovered=%s;bgimg_pressed=%s]
|
||||||
@ -1055,39 +1108,25 @@ local function make_fs(data)
|
|||||||
fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 4),
|
fs[#fs + 1] = fmt(mul_elem(FMT.image_button, 4),
|
||||||
sfinv_only and 2.6 or 2.54, -0.06, 0.85, 0.85, "", "search", "",
|
sfinv_only and 2.6 or 2.54, -0.06, 0.85, 0.85, "", "search", "",
|
||||||
sfinv_only and 3.3 or 3.25, -0.06, 0.85, 0.85, "", "clear", "",
|
sfinv_only and 3.3 or 3.25, -0.06, 0.85, 0.85, "", "clear", "",
|
||||||
sfinv_only and 5.45 or (ROWS * 6.83) / 11, -0.06, 0.85, 0.85, "", "prev_page", "",
|
sfinv_only and 5.45 or (9 * 6.83) / 11, -0.06, 0.85, 0.85, "", "prev_page", "",
|
||||||
sfinv_only and 7.2 or (ROWS * 8.75) / 11, -0.06, 0.85, 0.85, "", "next_page", "")
|
sfinv_only and 7.2 or (9 * 8.75) / 11, -0.06, 0.85, 0.85, "", "next_page", "")
|
||||||
else
|
|
||||||
fs[#fs + 1] = fmt([[
|
|
||||||
image_button[%f,-0.06;0.85,0.85;%s;search;;;false;%s]
|
|
||||||
image_button[%f,-0.06;0.85,0.85;%s;clear;;;false;%s]
|
|
||||||
]],
|
|
||||||
sfinv_only and 2.6 or 2.54, PNG.search, PNG.search_hover,
|
|
||||||
sfinv_only and 3.3 or 3.25, PNG.clear, PNG.clear_hover)
|
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(mul_elem(FMT.arrow, 2),
|
|
||||||
sfinv_only and 5.45 or (ROWS * 6.83) / 11, -0.05,
|
|
||||||
PNG.prev, "prev_page", PNG.prev_hover,
|
|
||||||
sfinv_only and 7.2 or (ROWS * 8.75) / 11, -0.05,
|
|
||||||
PNG.next, "next_page", PNG.next_hover)
|
|
||||||
end
|
|
||||||
|
|
||||||
data.pagemax = max(1, ceil(#data.items / IPP))
|
data.pagemax = max(1, ceil(#data.items / IPP))
|
||||||
|
|
||||||
fs[#fs + 1] = fmt("label[%f,%f;%s / %u]",
|
fs[#fs + 1] = fmt("label[%f,%f;%s / %u]",
|
||||||
sfinv_only and 6.35 or (ROWS * 7.85) / 11,
|
sfinv_only and 6.35 or (9 * 7.85) / 11,
|
||||||
0.06, clr("#ff0", data.pagenum), data.pagemax)
|
0.06, clr("#ff0", data.pagenum), data.pagemax)
|
||||||
|
|
||||||
if #data.items == 0 then
|
if #data.items == 0 then
|
||||||
local no_item = S"No item to show"
|
local no_item = ES"No item to show"
|
||||||
local pos = ROWS / 3
|
local pos = 3
|
||||||
|
|
||||||
if next(recipe_filters) and #init_items > 0 and data.filter == "" then
|
if next(recipe_filters) and #init_items > 0 and data.filter == "" then
|
||||||
no_item = S"Collect items to reveal more recipes"
|
no_item = ES"Collect items to reveal more recipes"
|
||||||
pos = pos - 1
|
pos = pos - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt(FMT.label, pos, 2, ESC(no_item))
|
fs[#fs + 1] = fmt(FMT.label, pos, 2, no_item)
|
||||||
end
|
end
|
||||||
|
|
||||||
local first_item = (data.pagenum - 1) * IPP
|
local first_item = (data.pagenum - 1) * IPP
|
||||||
@ -1098,18 +1137,15 @@ local function make_fs(data)
|
|||||||
|
|
||||||
local X = i % ROWS
|
local X = i % ROWS
|
||||||
local Y = (i % IPP - X) / ROWS + 1
|
local Y = (i % IPP - X) / ROWS + 1
|
||||||
|
X = X - (X * (sfinv_only and 0.12 or 0.14)) - 0.05
|
||||||
|
Y = Y - (Y * 0.1) - 0.1
|
||||||
|
|
||||||
if data.fs_version >= 3 and data.query_item == item then
|
if data.query_item == item then
|
||||||
fs[#fs + 1] = fmt(FMT.image,
|
fs[#fs + 1] = fmt(FMT.image, X, Y, 1, 1, PNG.selected)
|
||||||
X - (X * (sfinv_only and 0.12 or 0.14)) - 0.05,
|
|
||||||
Y - (Y * 0.1) - 0.1,
|
|
||||||
1, 1, PNG.selected)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s_inv;]",
|
fs[#fs + 1] = fmt("item_image_button[%f,%f;%f,%f;%s;%s_inv;]",
|
||||||
X - (X * (sfinv_only and 0.12 or 0.14)) - 0.05,
|
X, Y, 1, 1, item, item)
|
||||||
Y - (Y * 0.1) - 0.1,
|
|
||||||
1, 1, item, item)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (data.recipes and #data.recipes > 0) or (data.usages and #data.usages > 0) then
|
if (data.recipes and #data.recipes > 0) or (data.usages and #data.usages > 0) then
|
||||||
@ -1138,16 +1174,6 @@ craftguide.register_craft_type("digging_chance", {
|
|||||||
icon = "default_tool_mesepick.png",
|
icon = "default_tool_mesepick.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
local function sfind(str, filter)
|
|
||||||
if filter == "" then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
if find(str, filter, 1, true) then
|
|
||||||
return #str - #filter
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function search(data)
|
local function search(data)
|
||||||
local filter = data.filter
|
local filter = data.filter
|
||||||
|
|
||||||
@ -1169,28 +1195,30 @@ local function search(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local filtered_list, order, c = {}, {}, 0
|
local filtered_list, c = {}, 0
|
||||||
|
|
||||||
for i = 1, #data.items_raw do
|
for i = 1, #data.items_raw do
|
||||||
local item = data.items_raw[i]
|
local item = data.items_raw[i]
|
||||||
local def = reg_items[item]
|
local def = reg_items[item]
|
||||||
local desc = (def and def.description) and lower(def.description) or ""
|
local desc = (def and def.description) and lower(def.description) or ""
|
||||||
|
local search_in = fmt("%s %s", item, desc)
|
||||||
local to_add
|
local to_add
|
||||||
|
|
||||||
if search_filter then
|
if search_filter then
|
||||||
for filter_name, values in pairs(filters) do
|
for filter_name, values in pairs(filters) do
|
||||||
|
if values then
|
||||||
local func = search_filters[filter_name]
|
local func = search_filters[filter_name]
|
||||||
to_add = func(item, values) and (search_filter == "" or
|
to_add = func(item, values) and (search_filter == "" or
|
||||||
(sfind(item, search_filter) or sfind(desc, search_filter)))
|
find(search_in, search_filter, 1, true))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
to_add = sfind(item, filter) or sfind(desc, filter)
|
to_add = find(search_in, filter, 1, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if to_add then
|
if to_add then
|
||||||
c = c + 1
|
c = c + 1
|
||||||
filtered_list[c] = item
|
filtered_list[c] = item
|
||||||
order[item] = to_add
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1203,10 +1231,6 @@ local function search(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sort(filtered_list, function(a, b)
|
|
||||||
return order[a] < order[b]
|
|
||||||
end)
|
|
||||||
|
|
||||||
data.items = filtered_list
|
data.items = filtered_list
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1384,8 +1408,7 @@ local function handle_drops_table(name, drop)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function register_drops(name, def)
|
local function register_drops(name, drop)
|
||||||
local drop = def.drop
|
|
||||||
local dstack = ItemStack(drop)
|
local dstack = ItemStack(drop)
|
||||||
|
|
||||||
if not dstack:is_empty() and dstack:get_name() ~= name then
|
if not dstack:is_empty() and dstack:get_name() ~= name then
|
||||||
@ -1443,38 +1466,19 @@ local function show_item(def)
|
|||||||
def.description and def.description ~= ""
|
def.description and def.description ~= ""
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tablelen(t)
|
|
||||||
local c = 0
|
|
||||||
for _ in pairs(t) do
|
|
||||||
c = c + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
return c
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_init_items()
|
local function get_init_items()
|
||||||
local ic, it, last_str = 0, tablelen(reg_items), ""
|
local init_items_bak = storage:get "init_items"
|
||||||
|
|
||||||
|
if autocache == false and init_items_bak then
|
||||||
|
init_items = dslz(init_items_bak)
|
||||||
|
fuel_cache = dslz(storage:get "fuel_cache")
|
||||||
|
usages_cache = dslz(storage:get "usages_cache")
|
||||||
|
recipes_cache = dslz(storage:get "recipes_cache")
|
||||||
|
else
|
||||||
|
print "[craftguide] Caching data (this may take a while)"
|
||||||
local hash = {}
|
local hash = {}
|
||||||
|
|
||||||
local function iop(str)
|
|
||||||
io.write(("\b \b"):rep(#last_str))
|
|
||||||
io.write(str)
|
|
||||||
io.flush()
|
|
||||||
last_str = str
|
|
||||||
end
|
|
||||||
|
|
||||||
local full_char, empty_char = "▰", "▱"
|
|
||||||
|
|
||||||
for name, def in pairs(reg_items) do
|
for name, def in pairs(reg_items) do
|
||||||
ic = ic + 1
|
|
||||||
local percent, bar, len = (ic * 100) / it, "", 20
|
|
||||||
|
|
||||||
for i = 1, len do
|
|
||||||
bar = bar .. (i <= percent / (100 / len) and full_char or empty_char)
|
|
||||||
end
|
|
||||||
|
|
||||||
iop(fmt("[craftguide] Caching data %s %u%%\r", bar, percent))
|
|
||||||
|
|
||||||
if show_item(def) then
|
if show_item(def) then
|
||||||
if not fuel_cache[name] then
|
if not fuel_cache[name] then
|
||||||
cache_fuel(name)
|
cache_fuel(name)
|
||||||
@ -1485,7 +1489,7 @@ local function get_init_items()
|
|||||||
end
|
end
|
||||||
|
|
||||||
cache_usages(name)
|
cache_usages(name)
|
||||||
register_drops(name, def)
|
register_drops(name, def.drop)
|
||||||
|
|
||||||
if name ~= "" and recipes_cache[name] or usages_cache[name] then
|
if name ~= "" and recipes_cache[name] or usages_cache[name] then
|
||||||
init_items[#init_items + 1] = name
|
init_items[#init_items + 1] = name
|
||||||
@ -1497,6 +1501,12 @@ local function get_init_items()
|
|||||||
handle_aliases(hash)
|
handle_aliases(hash)
|
||||||
sort(init_items)
|
sort(init_items)
|
||||||
|
|
||||||
|
storage:set_string("init_items", slz(init_items))
|
||||||
|
storage:set_string("fuel_cache", slz(fuel_cache))
|
||||||
|
storage:set_string("usages_cache", slz(usages_cache))
|
||||||
|
storage:set_string("recipes_cache", slz(recipes_cache))
|
||||||
|
end
|
||||||
|
|
||||||
if http and true_str(craftguide.export_url) then
|
if http and true_str(craftguide.export_url) then
|
||||||
local post_data = {
|
local post_data = {
|
||||||
recipes = recipes_cache,
|
recipes = recipes_cache,
|
||||||
@ -1509,8 +1519,6 @@ local function get_init_items()
|
|||||||
post_data = write_json(post_data),
|
post_data = write_json(post_data),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
print()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function init_data(name)
|
local function init_data(name)
|
||||||
@ -1520,7 +1528,7 @@ local function init_data(name)
|
|||||||
items = init_items,
|
items = init_items,
|
||||||
items_raw = init_items,
|
items_raw = init_items,
|
||||||
favs = {},
|
favs = {},
|
||||||
fs_version = get_player_info(name).formspec_version,
|
fs_version = get_fs_version(name),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1546,7 +1554,6 @@ end)
|
|||||||
local function fields(player, _f)
|
local function fields(player, _f)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
--print(dump(_f))
|
|
||||||
|
|
||||||
if _f.clear then
|
if _f.clear then
|
||||||
reset_data(data)
|
reset_data(data)
|
||||||
@ -1640,7 +1647,7 @@ if sfinv_only then
|
|||||||
|
|
||||||
is_in_nav = function(self, player, context)
|
is_in_nav = function(self, player, context)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
return get_player_info(name).formspec_version >= 2
|
return get_fs_version(name) >= FORMSPEC_MINIMAL_VERSION
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get = function(self, player, context)
|
get = function(self, player, context)
|
||||||
@ -1676,9 +1683,18 @@ else
|
|||||||
local name = user:get_player_name()
|
local name = user:get_player_name()
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
|
||||||
if data.fs_version == 1 then
|
if data.fs_version < FORMSPEC_MINIMAL_VERSION then
|
||||||
return msg(name, "Your Minetest client is outdated. " ..
|
local fs = fmt([[
|
||||||
|
size[6.6,1.3]
|
||||||
|
image[0,0;1,1;%s]
|
||||||
|
label[1,0;%s]
|
||||||
|
button_exit[2.8,0.8;1,1;;OK]
|
||||||
|
]],
|
||||||
|
PNG.nothing,
|
||||||
|
"Your Minetest client is outdated.\n" ..
|
||||||
"Get the latest version on minetest.net to use the Crafting Guide.")
|
"Get the latest version on minetest.net to use the Crafting Guide.")
|
||||||
|
|
||||||
|
return show_formspec(name, "craftguide", fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
if next(recipe_filters) then
|
if next(recipe_filters) then
|
||||||
@ -1709,7 +1725,7 @@ else
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
groups = {oddly_breakable_by_hand = 1, flammable = 3},
|
groups = {choppy = 1, attached_node = 1, oddly_breakable_by_hand = 1, flammable = 3},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "wallmounted",
|
type = "wallmounted",
|
||||||
wall_top = {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
|
wall_top = {-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
|
||||||
@ -1824,11 +1840,7 @@ if progressive_mode then
|
|||||||
return filtered
|
return filtered
|
||||||
end
|
end
|
||||||
|
|
||||||
local item_lists = {
|
local item_lists = {"main", "craft", "craftpreview"}
|
||||||
"main",
|
|
||||||
"craft",
|
|
||||||
"craftpreview",
|
|
||||||
}
|
|
||||||
|
|
||||||
local function get_inv_items(player)
|
local function get_inv_items(player)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
@ -1956,8 +1968,8 @@ if progressive_mode then
|
|||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
data.inv_items = dslz(meta:get_string("inv_items")) or {}
|
data.inv_items = dslz(meta:get_string "inv_items") or {}
|
||||||
data.known_recipes = dslz(meta:get_string("known_recipes")) or 0
|
data.known_recipes = dslz(meta:get_string "known_recipes") or 0
|
||||||
|
|
||||||
data.hud = {
|
data.hud = {
|
||||||
bg = player:hud_add{
|
bg = player:hud_add{
|
||||||
@ -1986,10 +1998,7 @@ if progressive_mode then
|
|||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local to_save = {
|
local to_save = {"inv_items", "known_recipes"}
|
||||||
"inv_items",
|
|
||||||
"known_recipes",
|
|
||||||
}
|
|
||||||
|
|
||||||
local function save_meta(player)
|
local function save_meta(player)
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
@ -2022,7 +2031,7 @@ end)
|
|||||||
|
|
||||||
function craftguide.show(name, item, show_usages)
|
function craftguide.show(name, item, show_usages)
|
||||||
if not true_str(name)then
|
if not true_str(name)then
|
||||||
return err"craftguide.show(): player name missing"
|
return err "craftguide.show(): player name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
@ -3,17 +3,58 @@
|
|||||||
Craft Guide=Rezeptbuch
|
Craft Guide=Rezeptbuch
|
||||||
Crafting Guide=Rezeptbuch
|
Crafting Guide=Rezeptbuch
|
||||||
Crafting Guide Sign=Rezepttafel
|
Crafting Guide Sign=Rezepttafel
|
||||||
|
Bookmarks=Lesezeichen
|
||||||
Usage @1 of @2=Verwendung @1 von @2
|
Usage @1 of @2=Verwendung @1 von @2
|
||||||
Recipe @1 of @2=Rezept @1 von @2
|
Recipe @1 of @2=Rezept @1 von @2
|
||||||
|
No recipes=Keine Rezepte
|
||||||
|
No usages=Keine Verwendungen
|
||||||
Burning time: @1=Brennzeit: @1
|
Burning time: @1=Brennzeit: @1
|
||||||
Cooking time: @1=Kochzeit: @1
|
Cooking time: @1=Kochzeit: @1
|
||||||
|
Replaced by @1 on smelting=Ersetzt durch @1 beim Schmelzen
|
||||||
|
Replaced by @1 on burning=Ersetzt durch @1 beim Brennen
|
||||||
|
Replaced by @1 on crafting=Ersetzt durch @1 beim Fertigen
|
||||||
|
Repairable by step of @1=Reparierbar um @1
|
||||||
Any item belonging to the group(s): @1=Beliebiger Gegenstand aus Gruppe(n): @1
|
Any item belonging to the group(s): @1=Beliebiger Gegenstand aus Gruppe(n): @1
|
||||||
|
Any black dye=Beliebiger schwarzer Farbstoff
|
||||||
|
Any black flower=Beliebige schwarze Blume
|
||||||
|
Any blue dye=Beliebiger blauer Farbstoff
|
||||||
|
Any blue flower=Beliebige blaue Blume
|
||||||
|
Any brown dye=Beliebiger brauner Farbstoff
|
||||||
|
Any coal=Beliebige Kohle
|
||||||
|
Any cyan dye=Beliebiger türkiser Farbstoff
|
||||||
|
Any dark green dye=Beliebiger dunkelgrüner Farbstoff
|
||||||
|
Any dark grey dye=Beliebiger dunkelgrauer Farbstoff
|
||||||
|
Any green dye=Beliebiger grüner Farbstoff
|
||||||
|
Any green flower=Beliebige grüne Blume
|
||||||
|
Any grey dye=Beliebiger grauer Farbstoff
|
||||||
|
Any kind of stone block=Beliebiger Steinblock
|
||||||
|
Any magenta dye=Beliebiger magenta Farbstoff
|
||||||
|
Any orange dye=Beliebiger orange Farbstoff
|
||||||
|
Any orange flower=Beliebige orange Blume
|
||||||
|
Any pink dye=Beliebiger rosa Farbstoff
|
||||||
|
Any red dye=Beliebiger roter Farbstoff
|
||||||
|
Any red flower=Beliebige rote Blume
|
||||||
|
Any sand=Beliebiger Sand
|
||||||
|
Any stick=Beliebiger Stock
|
||||||
|
Any tree=Beliebiger Baum
|
||||||
|
Any vessel=Beliebiger Behälter
|
||||||
|
Any violet dye=Beliebiger violetter Farbstoff
|
||||||
|
Any violet flower=Beliebige violette Blume
|
||||||
|
Any white dye=Beliebiger weißer Farbstoff
|
||||||
|
Any white flower=Beliebige weiße Blume
|
||||||
|
Any wood planks=Beliebige Holzplanken
|
||||||
|
Any wool=Beliebige Wolle
|
||||||
|
Any yellow dye=Beliebiger gelber Farbstoff
|
||||||
|
Any yellow flower=Beliebige gelbe Blume
|
||||||
Recipe's too big to be displayed (@1x@2)=Rezept ist zu groß für die Anzeige (@1×@2)
|
Recipe's too big to be displayed (@1x@2)=Rezept ist zu groß für die Anzeige (@1×@2)
|
||||||
Shapeless=Formlos
|
Shapeless=Formlos
|
||||||
Cooking=Kochen
|
Cooking=Kochen
|
||||||
No item to show=Nichts anzuzeigen
|
No item to show=Nichts anzuzeigen
|
||||||
Collect items to reveal more recipes=Gegenstände aufsammeln, um mehr Rezepte aufzudecken
|
Collect items to reveal more recipes=Gegenstände aufsammeln, um mehr Rezepte aufzudecken
|
||||||
Show recipe(s) of the pointed node=Rezept(e) des gezeigten Blocks anzeigen
|
Show recipe(s) of the pointed node=Rezept(e) des gezeigten Blocks anzeigen
|
||||||
No node pointed=Auf keinen Block gezeigt
|
No node pointed=Auf keinem Block gezeigt
|
||||||
You don't know a recipe for this node=Sie kennen kein Rezept für diesen Block
|
You don't know a recipe or usage for this item=Sie kennen kein Rezept und keine Verwendung für diesen Gegenstand
|
||||||
No recipe for this node=Kein Rezept für diesen Block
|
No recipe or usage for this item=Kein Rezept und keine Verwendung für diesen Gegenstand
|
||||||
|
Digging=Graben
|
||||||
|
Digging Chance=Grabechance
|
||||||
|
@1 of chance to drop=@1 Abwurfwahrscheinlichkeit
|
||||||
|
@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
Craft Guide=Guide de recettes
|
Craft Guide=Guide de recettes
|
||||||
Crafting Guide=Guide de recettes
|
Crafting Guide=Guide de recettes
|
||||||
|
Crafting Guide Sign=Guide de recettes
|
||||||
|
Bookmarks=Favoris
|
||||||
Usage @1 of @2=Usage @1 de @2
|
Usage @1 of @2=Usage @1 de @2
|
||||||
Recipe @1 of @2=Recette @1 de @2
|
Recipe @1 of @2=Recette @1 de @2
|
||||||
|
No recipes=Pas de recettes
|
||||||
|
No usages=Pas d'usages
|
||||||
Burning time: @1=Temps de combustion : @1
|
Burning time: @1=Temps de combustion : @1
|
||||||
Cooking time: @1=Temps de cuisson : @1
|
Cooking time: @1=Temps de cuisson : @1
|
||||||
Replaced by @1 on smelting=Remplacé par @1 lors de la cuisson
|
Replaced by @1 on smelting=Remplacé par @1 lors de la cuisson
|
||||||
@ -11,6 +15,37 @@ Replaced by @1 on burning=Remplacé par @1 lors de la combustion
|
|||||||
Replaced by @1 on crafting=Remplacé par @1 lors de la fabrication
|
Replaced by @1 on crafting=Remplacé par @1 lors de la fabrication
|
||||||
Repairable by step of @1=Réparable par étape de @1
|
Repairable by step of @1=Réparable par étape de @1
|
||||||
Any item belonging to the group(s): @1=Tout item appartenant au(x) groupe(s) : @1
|
Any item belonging to the group(s): @1=Tout item appartenant au(x) groupe(s) : @1
|
||||||
|
Any black dye=Quelconque colorant noir
|
||||||
|
Any black flower=Quelconque fleur noire
|
||||||
|
Any blue dye=Quelconque colorant bleu
|
||||||
|
Any blue flower=Quelconque fleur bleue
|
||||||
|
Any brown dye=Quelconque colorant marron
|
||||||
|
Any coal=Quelconque charbon
|
||||||
|
Any cyan dye=Quelconque colorant bleu ciel
|
||||||
|
Any dark green dye=Quelconque colorant vert foncé
|
||||||
|
Any dark grey dye=Quelconque colorant gris foncé
|
||||||
|
Any green dye=Quelconque colorant vert
|
||||||
|
Any green flower=Quelconque fleur verte
|
||||||
|
Any grey dye=Quelconque colorant gris
|
||||||
|
Any kind of stone block=Quelconque roche
|
||||||
|
Any magenta dye=Quelconque colorant magenta
|
||||||
|
Any orange dye=Quelconque colorant orange
|
||||||
|
Any orange flower=Quelconque fleur orange
|
||||||
|
Any pink dye=Quelconque colorant rose
|
||||||
|
Any red dye=Quelconque colorant rouge
|
||||||
|
Any red flower=Quelconque fleur rouge
|
||||||
|
Any sand=Quelconque sable
|
||||||
|
Any stick=Quelconque bâton
|
||||||
|
Any tree=Quelconque tronc d'arbre
|
||||||
|
Any vessel=Quelconque couvert
|
||||||
|
Any violet dye=Quelconque colorant violet
|
||||||
|
Any violet flower=Quelconque fleur violette
|
||||||
|
Any white dye=Quelconque colorant blanc
|
||||||
|
Any white flower=Quelconque fleur blanche
|
||||||
|
Any wood planks=Quelconques planches de bois
|
||||||
|
Any wool=Quelconque laine
|
||||||
|
Any yellow dye=Quelconque colorant jaune
|
||||||
|
Any yellow flower=Quelconque fleur jaune
|
||||||
Recipe's too big to be displayed (@1x@2)=La recette est trop grande pour être affichée (@1x@2)
|
Recipe's too big to be displayed (@1x@2)=La recette est trop grande pour être affichée (@1x@2)
|
||||||
Shapeless=Sans forme
|
Shapeless=Sans forme
|
||||||
Cooking=Cuisson
|
Cooking=Cuisson
|
||||||
@ -18,5 +53,8 @@ No item to show=Aucun item à afficher
|
|||||||
Collect items to reveal more recipes=Collecte des items pour révéler plus de recettes
|
Collect items to reveal more recipes=Collecte des items pour révéler plus de recettes
|
||||||
Show recipe(s) of the pointed node=Affiche les recettes du bloc visé
|
Show recipe(s) of the pointed node=Affiche les recettes du bloc visé
|
||||||
No node pointed=Aucun bloc visé
|
No node pointed=Aucun bloc visé
|
||||||
You don't know a recipe for this node=Tu ne connais aucune recette pour ce bloc
|
You don't know a recipe or usage for this item=Tu ne connais aucune recette pour ce bloc
|
||||||
No recipe for this node=Aucune recette pour ce bloc
|
No recipe or usage for this item=Aucune recette pour ce bloc
|
||||||
|
Digging=Destruction
|
||||||
|
Digging Chance=Destruction chanceuse
|
||||||
|
@1 of chance to drop=@1 de chance de tomber
|
||||||
|
@ -2,25 +2,59 @@
|
|||||||
|
|
||||||
Craft Guide=Guida di assemblaggio
|
Craft Guide=Guida di assemblaggio
|
||||||
Crafting Guide=Guida d'assemblaggio
|
Crafting Guide=Guida d'assemblaggio
|
||||||
Crafting Guide Sign=Cartello della guida d'assemblaggio
|
Crafting Guide Sign=Cartello della guida di assemblaggio
|
||||||
|
Bookmarks=Segnalibri
|
||||||
Usage @1 of @2=Utilizzo @1 di @2
|
Usage @1 of @2=Utilizzo @1 di @2
|
||||||
Recipe @1 of @2=Ricetta @1 di @2
|
Recipe @1 of @2=Ricetta @1 di @2
|
||||||
Burning time: @1=Tempo di bruciatura: @1
|
No recipes=Nessuna ricetta
|
||||||
|
No usages=Nessun utilizzo
|
||||||
|
Burning time: @1=Tempo di combustione: @1
|
||||||
Cooking time: @1=Tempo di cottura: @1
|
Cooking time: @1=Tempo di cottura: @1
|
||||||
Replaced by @1 on smelting=Sostituito da @1 alla fusione
|
Replaced by @1 on smelting=Sostituito da @1 alla fusione
|
||||||
Replaced by @1 on burning=Sostituito da @1 alla bruciatura
|
Replaced by @1 on burning=Sostituito da @1 alla combustione
|
||||||
Replaced by @1 on crafting=Sostituito da @1 all'assemblaggio
|
Replaced by @1 on crafting=Sostituito da @1 all'assemblaggio
|
||||||
Repairable by step of @1=Riparabile per passo di @1
|
Repairable by step of @1=Riparabile per passo di @1
|
||||||
Any item belonging to the group(s): @1=Qualunque oggetto appartenente al gruppo: @1
|
Any item belonging to the group(s): @1=Qualunque oggetto appartenente al/ai gruppo/i: @1
|
||||||
|
Any black dye=Qualunque tintura nera
|
||||||
|
Any black flower=Qualunque fiore nero
|
||||||
|
Any blue dye=Qualunque tintura blu
|
||||||
|
Any blue flower=Qualunque fiore blu
|
||||||
|
Any brown dye=Qualunque tintura marrone
|
||||||
|
Any coal=Qualunque carbone
|
||||||
|
Any cyan dye=Qualunque tintura ciano
|
||||||
|
Any dark green dye=Qualunque tintura verde scura
|
||||||
|
Any dark grey dye=Qualunque tintura grigio scura
|
||||||
|
Any green dye=Qualunque tintura verde
|
||||||
|
Any green flower=Qualunque fiore verde
|
||||||
|
Any grey dye=Qualunque tintura grigia
|
||||||
|
Any kind of stone block=Qualunque tipo di blocco di pietra
|
||||||
|
Any magenta dye=Qualunque tintura magenta
|
||||||
|
Any orange dye=Qualunque tintura arancione
|
||||||
|
Any orange flower=Qualunque fiore arancione
|
||||||
|
Any pink dye=Qualunque tintura rosa
|
||||||
|
Any red dye=Qualunque tintura rossa
|
||||||
|
Any red flower=Qualunque fiore rosso
|
||||||
|
Any sand=Qualunque sabbia
|
||||||
|
Any stick=Qualunque bastone
|
||||||
|
Any tree=Qualunque albero
|
||||||
|
Any vessel=Qualunque contenitore
|
||||||
|
Any violet dye=Qualunque tintura viola
|
||||||
|
Any violet flower=Qualunque fiore viola
|
||||||
|
Any white dye=Qualunque tintura bianca
|
||||||
|
Any white flower=Qualunque fiore bianco
|
||||||
|
Any wood planks=Qualunque asse di legno
|
||||||
|
Any wool=Qualunque lana
|
||||||
|
Any yellow dye=Qualunque tintura gialla
|
||||||
|
Any yellow flower=Qualunque fiore giallo
|
||||||
Recipe's too big to be displayed (@1x@2)=La ricetta è troppo grande per essere mostrata (@1x@2)
|
Recipe's too big to be displayed (@1x@2)=La ricetta è troppo grande per essere mostrata (@1x@2)
|
||||||
Shapeless=Senza forma
|
Shapeless=Senza forma
|
||||||
Cooking=Cottura
|
Cooking=Cottura
|
||||||
No item to show=Nessun oggetto da mostrare
|
No item to show=Nessun oggetto da mostrare
|
||||||
Collect items to reveal more recipes=Raccogli oggetti per svelare più ricette
|
Collect items to reveal more recipes=Raccogli oggetti per svelare più ricette
|
||||||
Show recipe(s) of the pointed node=Mostra la ricetta del nodo puntato
|
Show recipe(s) of the pointed node=Mostra la/le ricetta/e del nodo puntato
|
||||||
No node pointed=Nessun nodo puntato
|
No node pointed=Nessun nodo puntato
|
||||||
You don't know a recipe for this node=Non conosci una ricetta per questo nodo
|
You don't know a recipe or usage for this item=Non conosci una ricetta o un utilizzo per questo oggetto
|
||||||
No recipe for this node=Nessuna ricetta per questo nodo
|
No recipe or usage for this item=Nessuna ricetta o utilizzo per questo oggetto
|
||||||
Digging=Scavando
|
Digging=Scavando
|
||||||
Digging Chance=Probabilità di scavare
|
Digging Chance=Probabilità di scavare
|
||||||
@1 of chance to drop=@1 di probabilità di rilascio
|
@1 of chance to drop=@1 di probabilità di rilascio
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Craft Guide=
|
Craft Guide=
|
||||||
Crafting Guide=
|
Crafting Guide=
|
||||||
Crafting Guide Sign=
|
Crafting Guide Sign=
|
||||||
|
Bookmarks=
|
||||||
Usage @1 of @2=
|
Usage @1 of @2=
|
||||||
Recipe @1 of @2=
|
Recipe @1 of @2=
|
||||||
No recipes=
|
No recipes=
|
||||||
@ -14,6 +15,37 @@ Replaced by @1 on burning=
|
|||||||
Replaced by @1 on crafting=
|
Replaced by @1 on crafting=
|
||||||
Repairable by step of @1=
|
Repairable by step of @1=
|
||||||
Any item belonging to the group(s): @1=
|
Any item belonging to the group(s): @1=
|
||||||
|
Any black dye=
|
||||||
|
Any black flower=
|
||||||
|
Any blue dye=
|
||||||
|
Any blue flower=
|
||||||
|
Any brown dye=
|
||||||
|
Any coal=
|
||||||
|
Any cyan dye=
|
||||||
|
Any dark green dye=
|
||||||
|
Any dark grey dye=
|
||||||
|
Any green dye=
|
||||||
|
Any green flower=
|
||||||
|
Any grey dye=
|
||||||
|
Any kind of stone block=
|
||||||
|
Any magenta dye=
|
||||||
|
Any orange dye=
|
||||||
|
Any orange flower=
|
||||||
|
Any pink dye=
|
||||||
|
Any red dye=
|
||||||
|
Any red flower=
|
||||||
|
Any sand=
|
||||||
|
Any stick=
|
||||||
|
Any tree=
|
||||||
|
Any vessel=
|
||||||
|
Any violet dye=
|
||||||
|
Any violet flower=
|
||||||
|
Any white dye=
|
||||||
|
Any white flower=
|
||||||
|
Any wood planks=
|
||||||
|
Any wool=
|
||||||
|
Any yellow dye=
|
||||||
|
Any yellow flower=
|
||||||
Recipe's too big to be displayed (@1x@2)=
|
Recipe's too big to be displayed (@1x@2)=
|
||||||
Shapeless=
|
Shapeless=
|
||||||
Cooking=
|
Cooking=
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
||||||
craftguide_progressive_mode (Progressive Mode) bool false
|
craftguide_progressive_mode (Learn crafting recipes progressively) bool false
|
||||||
|
|
||||||
# Integration in the default Minetest Game inventory.
|
# Integration in the default Minetest Game inventory.
|
||||||
craftguide_sfinv_only (Sfinv only) bool false
|
craftguide_sfinv_only (Crafting Guide in inventory only) bool false
|
||||||
|
|
||||||
|
# Enable pre-caching of item recipes.
|
||||||
|
# Do NOT disable the first time the mod loads.
|
||||||
|
# Disabling the auto-caching will result in faster mod loading.
|
||||||
|
# If you enable or disable mods, or edit the current mod recipes in your setup, you SHOULD re-enable this setting until the next caching at least.
|
||||||
|
# Usage at your own risk.
|
||||||
|
craftguide_autocache (Auto-caching of recipes) bool true
|
||||||
|
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 4.5 KiB |
BIN
textures/craftguide_no.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 3.5 KiB |