As I wanted to learn Lua one day I used my basic knowledge to create something. I'm pretty sure there are more edge cases to be considered.
Do with it whatever you want :)
Testing:
Code changes overview inside production_table.lua -> function builders.products
https://i.imgur.com/sDKZ05C.png
Code
local break_down_tooltip = ""
local parent = line.parent
local cancel = false
if (line.active == nil or line.active) then
for _, parent_line in ipairs(Line.get_in_order(parent, "Line")) do
if line == parent_line and not metadata.matrix_solver_active then
cancel = true -- traditional solver only uses products from below so we MUST cancel further breakdown here
end
if not cancel and line ~= parent_line and (parent_line.active == nil or parent_line.active) then
for _, ingredient in ipairs(Line.get_in_order(parent_line, "Ingredient")) do
if product.proto.name == ingredient.proto.name then
local machine_count_break_down = (not parent_line.subfloor) and parent_line.machine.count or nil
local amount_breakdown = ingredient.amount
if ingredient.amount > product.amount then
local percentage = product.amount / ingredient.amount
if machine_count_break_down ~= nil then
machine_count_break_down = machine_count_break_down * percentage
end
amount_breakdown = amount_breakdown * percentage
end
local amount_break_down, number_tooltip_break_down = view_state.process_item(metadata.view_state_metadata, ingredient, amount_breakdown, machine_count_break_down)
if amount_break_down ~= "0" then
if break_down_tooltip == "" then
break_down_tooltip = {"", "\n", {"fp.tt_title", "Breakdown"}}
end
local recipe = parent_line.recipe
local subfloor_text = ""
if recipe == nil then
recipe = parent_line.subfloor.defining_line.recipe
subfloor_text = "(subfloor) "
end
local tooltip_icon = "[recipe=" .. recipe.proto.name .. "] "
if recipe.proto.name == "impostor-silo-rocket-silo-item-satellite" then
tooltip_icon = "[item=space-science-pack] "
end
table.insert(break_down_tooltip, "\n")
table.insert(break_down_tooltip, {"", tooltip_icon .. subfloor_text, number_tooltip_break_down})
end
end
end
end
end
end
local name_line = (note == nil) and {"fp.tt_title", product.proto.localised_name}
or {"fp.tt_title_with_note", product.proto.localised_name, note}
local number_line = (number_tooltip) and {"", "\n", number_tooltip} or ""
local tooltip = {"", name_line, number_line, break_down_tooltip, metadata.product_tutorial_tt}