Add tools field in drop section

This commit is contained in:
Jean-Patrick Guerrero 2020-06-29 00:19:11 +02:00
parent 762c166485
commit 6f2c79e7e1
3 changed files with 35 additions and 11 deletions

@ -779,14 +779,32 @@ local function get_tooltip(name, info)
end end
if info.rarity then if info.rarity then
local chance = (1 / info.rarity) * 100 local chance = (1 / max(1, info.rarity)) * 100
tooltip = add(S("@1 of chance to drop", clr("#ff0", chance .. "%"))) tooltip = add(S("@1 of chance to drop", clr("#ff0", chance .. "%")))
end end
if info.tools then
local several = #info.tools > 1
local names = several and "\n" or ""
if several then
for i = 1, #info.tools do
names = fmt("%s\t\t- %s\n",
names, clr("#ff0", get_desc(info.tools[i])))
end
tooltip = add(S("Only drop if using one of these tools: @1",
sub(names, 1, -2)))
else
tooltip = add(S("Only drop if using this tool: @1",
clr("#ff0", get_desc(info.tools[1]))))
end
end
return fmt("tooltip[%s;%s]", name, ESC(tooltip)) return fmt("tooltip[%s;%s]", name, ESC(tooltip))
end end
local function get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_size, spacing, rarity) local function get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_size, spacing)
local custom_recipe = craft_types[rcp.type] local custom_recipe = craft_types[rcp.type]
if custom_recipe or shapeless or rcp.type == "cooking" then if custom_recipe or shapeless or rcp.type == "cooking" then
@ -840,7 +858,8 @@ local function get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_siz
unknown = not def or nil, unknown = not def or nil,
burntime = fuel_cache[name], burntime = fuel_cache[name],
repair = repairable(name), repair = repairable(name),
rarity = rarity, rarity = rcp.rarity,
tools = rcp.tools,
newline = check_newline(def), newline = check_newline(def),
} }
@ -862,8 +881,6 @@ end
local function get_grid_fs(data, fs, rcp, spacing) local function get_grid_fs(data, fs, rcp, spacing)
local width = rcp.width or 1 local width = rcp.width or 1
local replacements = rcp.replacements
local rarity = rcp.rarity
local right, btn_size, _btn_size = 0, 1.1 local right, btn_size, _btn_size = 0, 1.1
local cooktime, shapeless local cooktime, shapeless
@ -929,9 +946,9 @@ local function get_grid_fs(data, fs, rcp, spacing)
local label = groups and "\nG" or "" local label = groups and "\nG" or ""
local replace local replace
if replacements then if rcp.replacements then
for j = 1, #replacements do for j = 1, #rcp.replacements do
local replacement = replacements[j] local replacement = rcp.replacements[j]
if replacement[1] == name then if replacement[1] == name then
label = (label ~= "" and "\n" or "") .. label .. "\nR" label = (label ~= "" and "\n" or "") .. label .. "\nR"
replace = replacement[2] replace = replacement[2]
@ -968,7 +985,7 @@ local function get_grid_fs(data, fs, rcp, spacing)
fs[#fs + 1] = "style_type[item_image_button;border=false]" fs[#fs + 1] = "style_type[item_image_button;border=false]"
end end
get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_size, spacing, rarity) get_output_fs(data, fs, rcp, shapeless, right, btn_size, _btn_size, spacing)
end end
local function get_rcp_lbl(data, fs, panel, spacing, rn, is_recipe) local function get_rcp_lbl(data, fs, panel, spacing, rn, is_recipe)
@ -1450,6 +1467,7 @@ local function handle_drops_table(name, drop)
drop_maybe[dname] = { drop_maybe[dname] = {
output = drop_maybe[dname].output + dcount, output = drop_maybe[dname].output + dcount,
rarity = di.rarity, rarity = di.rarity,
tools = di.tools,
} }
end end
end end
@ -1461,15 +1479,17 @@ local function handle_drops_table(name, drop)
type = "digging", type = "digging",
items = {name}, items = {name},
output = fmt("%s %u", item, count), output = fmt("%s %u", item, count),
tools = drop.tools,
} }
end end
for item, data in pairs(drop_maybe) do for item, data in pairs(drop_maybe) do
craftguide.register_craft{ craftguide.register_craft{
type = "digging_chance", type = "digging_chance",
items = {name}, items = {name},
output = fmt("%s %u", item, data.output), output = fmt("%s %u", item, data.output),
rarity = data.rarity, rarity = data.rarity,
tools = data.tools,
} }
end end
end end

@ -61,3 +61,5 @@ Digging Chance=Destruction chanceuse
Mark this item=Mettre en favori. Mark this item=Mettre en favori.
Unmark this item=Enlever des favoris. Unmark this item=Enlever des favoris.
Cannot mark this item. Limit of bookmarks reached.=Impossible de mettre cet item en favori. Limite des favoris atteinte. Cannot mark this item. Limit of bookmarks reached.=Impossible de mettre cet item en favori. Limite des favoris atteinte.
Only drop if using one of these tools: @1=Tombe seulement si détruit avec un de ces outils: @1
Only drop if using this tool: @1=Tombe seulement si détruit avec cet outil: @1

@ -61,3 +61,5 @@ Digging Chance=
Mark this item= Mark this item=
Unmark this item= Unmark this item=
Cannot mark this item. Limit of bookmarks reached.= Cannot mark this item. Limit of bookmarks reached.=
Only drop if using one of these tools: @1=
Only drop if using this tool: @1=