mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-23 03:13:44 +01:00
Update locale template + fix craft command
This commit is contained in:
parent
138ac1ae2c
commit
5d7bb6de53
75
init.lua
75
init.lua
@ -30,6 +30,7 @@ local reg_craftitems = core.registered_craftitems
|
|||||||
local log = core.log
|
local log = core.log
|
||||||
local after = core.after
|
local after = core.after
|
||||||
local clr = core.colorize
|
local clr = core.colorize
|
||||||
|
local chat_send = core.chat_send_player
|
||||||
local show_formspec = core.show_formspec
|
local show_formspec = core.show_formspec
|
||||||
local globalstep = core.register_globalstep
|
local globalstep = core.register_globalstep
|
||||||
local on_shutdown = core.register_on_shutdown
|
local on_shutdown = core.register_on_shutdown
|
||||||
@ -109,6 +110,34 @@ craftguide.group_stereotypes = {
|
|||||||
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function err(str)
|
||||||
|
return log("error", str)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function msg(name, str)
|
||||||
|
return chat_send(name, fmt("[craftguide] %s", clr("#FFFF00", str)))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function clean_str(str)
|
||||||
|
return match(str, "%S*")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_str(x)
|
||||||
|
return type(x) == "string" and clean_str(x)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_table(x)
|
||||||
|
return type(x) == "table"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_func(x)
|
||||||
|
return type(x) == "function"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function is_group(item)
|
||||||
|
return sub(item, 1, 6) == "group:"
|
||||||
|
end
|
||||||
|
|
||||||
local function array_diff(t1, t2)
|
local function array_diff(t1, t2)
|
||||||
local hash = {}
|
local hash = {}
|
||||||
|
|
||||||
@ -140,7 +169,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 type(t1) ~= "table" then
|
if not is_table(t1) then
|
||||||
return t1 == t2
|
return t1 == t2
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -217,30 +246,6 @@ local function table_replace(t, val, new)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function err(str)
|
|
||||||
return log("error", str)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function clean_str(str)
|
|
||||||
return match(str, "%S*")
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_str(x)
|
|
||||||
return type(x) == "string" and clean_str(x)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_table(x)
|
|
||||||
return type(x) == "table"
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_func(x)
|
|
||||||
return type(x) == "function"
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_group(item)
|
|
||||||
return sub(item, 1, 6) == "group:"
|
|
||||||
end
|
|
||||||
|
|
||||||
local craft_types = {}
|
local craft_types = {}
|
||||||
|
|
||||||
function craftguide.register_craft_type(name, def)
|
function craftguide.register_craft_type(name, def)
|
||||||
@ -708,7 +713,7 @@ local function get_itemdef_fs(fs, L)
|
|||||||
local def = reg_items[L.item]
|
local def = reg_items[L.item]
|
||||||
local namestr = fmt("%s (%s)", pretty_wrap(get_desc(L.item), 25), L.item)
|
local namestr = fmt("%s (%s)", pretty_wrap(get_desc(L.item), 25), L.item)
|
||||||
|
|
||||||
local typestr = ""
|
local typestr
|
||||||
if reg_nodes[L.item] then
|
if reg_nodes[L.item] then
|
||||||
typestr = fmt("%s (%s)", ESC(S("Node")), def.drawtype)
|
typestr = fmt("%s (%s)", ESC(S("Node")), def.drawtype)
|
||||||
elseif reg_entities[L.item] then
|
elseif reg_entities[L.item] then
|
||||||
@ -745,8 +750,8 @@ local function get_itemdef_fs(fs, L)
|
|||||||
fs[#fs + 1] = fmt("table[8.1,%f;6.3,1.8;itemdef;" .. tstr .. ";0]",
|
fs[#fs + 1] = fmt("table[8.1,%f;6.3,1.8;itemdef;" .. tstr .. ";0]",
|
||||||
L.y + 0.08,
|
L.y + 0.08,
|
||||||
namestr,
|
namestr,
|
||||||
ESC(typestr),
|
ESC(typestr or S("Unknown")),
|
||||||
ESC(groupstr))
|
ESC(groupstr or S("None")))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_info_fs(data, fs)
|
local function get_info_fs(data, fs)
|
||||||
@ -1747,6 +1752,20 @@ function craftguide.show(name, item, show_usages)
|
|||||||
data.query_item = item
|
data.query_item = item
|
||||||
data.recipes, data.usages = get_recipes(item, data, player)
|
data.recipes, data.usages = get_recipes(item, data, player)
|
||||||
|
|
||||||
|
if not data.recipes and not data.usages then
|
||||||
|
if recipes_cache[item] then
|
||||||
|
return false, msg(name, S("You don't know a recipe for this node"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if usages_cache[item] then
|
||||||
|
return false, msg(name, S("You don't know an usage for this node"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if not recipes_cache[item] and not usages_cache[item] then
|
||||||
|
return false, msg(name, S("No recipe or usage for this node"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if sfinv_only then
|
if sfinv_only then
|
||||||
data.show_usages = show_usages
|
data.show_usages = show_usages
|
||||||
end
|
end
|
||||||
|
@ -20,4 +20,14 @@ Collect items to reveal more recipes=
|
|||||||
Show recipe(s) of the pointed node=
|
Show recipe(s) of the pointed node=
|
||||||
No node pointed=
|
No node pointed=
|
||||||
You don't know a recipe for this node=
|
You don't know a recipe for this node=
|
||||||
No recipe for this node=
|
You don't know an usage for this node=
|
||||||
|
No recipe or usage for this node=
|
||||||
|
Node=
|
||||||
|
Entity=
|
||||||
|
Craftitem=
|
||||||
|
Tool=
|
||||||
|
Name=
|
||||||
|
Type=
|
||||||
|
Groups=
|
||||||
|
Unknown=
|
||||||
|
None=
|
||||||
|
Loading…
Reference in New Issue
Block a user