mirror of
https://github.com/minetest-mods/craftguide.git
synced 2025-06-30 15:10:38 +02:00
Compare commits
6 Commits
6e6ff93d29
...
1.14.2
Author | SHA1 | Date | |
---|---|---|---|
efe7434dd4 | |||
df26d31a2d | |||
50d19faa48 | |||
d93f5b0cf2 | |||
f83bc9cccf | |||
f88e0412fc |
38
init.lua
38
init.lua
@ -709,9 +709,21 @@ local function cache_recipes(item)
|
||||
_recipes[#recipes + 1 - k] = v
|
||||
end
|
||||
|
||||
local shift = 0
|
||||
local size_rpl = maxn(replacements[item])
|
||||
local size_rcp = #_recipes
|
||||
|
||||
if size_rpl > size_rcp then
|
||||
shift = size_rcp - size_rpl
|
||||
end
|
||||
|
||||
for k, v in pairs(replacements[item]) do
|
||||
k = k + shift
|
||||
|
||||
if _recipes[k] then
|
||||
_recipes[k].replacements = v
|
||||
end
|
||||
end
|
||||
|
||||
recipes = _recipes
|
||||
end
|
||||
@ -872,13 +884,13 @@ local function get_tooltip(item, info, lang_code)
|
||||
end
|
||||
|
||||
if info.replace then
|
||||
for i = 1, #info.replace do
|
||||
local rpl = match(info.replace[i], "%S+")
|
||||
for i = 1, #info.replace.items do
|
||||
local rpl = match(info.replace.items[i], "%S+")
|
||||
local desc = clr("#ff0", get_desc(rpl, lang_code))
|
||||
|
||||
if info.cooktime then
|
||||
if info.replace.type == "cooking" then
|
||||
tooltip = add(S("Replaced by @1 on smelting", desc))
|
||||
elseif info.burntime then
|
||||
elseif info.replace.type == "fuel" then
|
||||
tooltip = add(S("Replaced by @1 on burning", desc))
|
||||
else
|
||||
tooltip = add(S("Replaced by @1 on crafting", desc))
|
||||
@ -1061,11 +1073,11 @@ local function get_grid_fs(lang_code, fs, rcp, spacing)
|
||||
for j = 1, #(rcp.replacements or {}) do
|
||||
local replacement = rcp.replacements[j]
|
||||
if replacement[1] == name then
|
||||
replace = replace or {}
|
||||
replace = replace or {type = rcp.type, items = {}}
|
||||
|
||||
local added
|
||||
|
||||
for _, v in ipairs(replace) do
|
||||
for _, v in ipairs(replace.items) do
|
||||
if replacement[2] == v then
|
||||
added = true
|
||||
break
|
||||
@ -1074,7 +1086,7 @@ local function get_grid_fs(lang_code, fs, rcp, spacing)
|
||||
|
||||
if not added then
|
||||
label = fmt("%s%s\nR", label ~= "" and "\n" or "", label)
|
||||
replace[#replace + 1] = replacement[2]
|
||||
replace.items[#replace.items + 1] = replacement[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1498,15 +1510,15 @@ core.register_craft = function(def)
|
||||
end
|
||||
|
||||
for i = 1, #output do
|
||||
local name = output[i]
|
||||
rcp_num[name] = (rcp_num[name] or 0) + 1
|
||||
local item = output[i]
|
||||
rcp_num[item] = (rcp_num[item] or 0) + 1
|
||||
|
||||
if def.replacements then
|
||||
if def.type == "fuel" then
|
||||
replacements.fuel[name] = def.replacements
|
||||
replacements.fuel[item] = def.replacements
|
||||
else
|
||||
replacements[name] = replacements[name] or {}
|
||||
replacements[name][rcp_num[name]] = def.replacements
|
||||
replacements[item] = replacements[item] or {}
|
||||
replacements[item][rcp_num[item]] = def.replacements
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -2125,7 +2137,7 @@ on_leaveplayer(function(player)
|
||||
end)
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user