Module:AbilityTable/ComplexRenderers: Difference between revisionsGive feedback
Jump to navigation
Jump to search
add RenderBarrier for the barrier list: running totals of barrier value and Spirit scaling per upgrade tier (with help from vergir-bot LLM) |
RenderBarrier: use the compact {{Ss}} form and keep one decimal on scaling totals (with help from vergir-bot LLM) |
||
| Line 81: | Line 81: | ||
end | end | ||
-- Formats one barrier step. Spirit scaling goes through {{Ss}}, expanded via | -- Pads a whole-number scaling out to one decimal, so a running total of 2 | ||
-- reads "2.0" next to its "1.5" neighbours instead of "2". Values that already | |||
-- carry decimals are left alone, which keeps precision on things like 0.75. | |||
local function format_scale(scale) | |||
local text = tostring(scale) | |||
if not text:find(".", 1, true) then text = text .. ".0" end | |||
return text | |||
end | |||
-- Formats one barrier step. Spirit scaling goes through the compact {{Ss}} | |||
-- form, expanded via the frame the surrounding #invoke is already running | |||
-- under: module return values are not re-expanded, so a literal "{{Ss|0.8}}" | |||
-- would reach the page as text. The plain fallback covers a nil frame | |||
-- (module console). | |||
local function format_barrier(value, scale) | local function format_barrier(value, scale) | ||
local out = tostring(value) | local out = tostring(value) | ||
if scale and scale ~= 0 then | if scale and scale ~= 0 then | ||
local scale_text = format_scale(scale) | |||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
if frame then | if frame then | ||
out = out .. " " .. frame:expandTemplate{ title = "Ss", args = { | out = out .. " " .. frame:expandTemplate{ | ||
title = "Ss", | |||
args = { scale_text, compact = "1", show_value = "1" }, | |||
} | |||
else | else | ||
out = out .. " ×" .. | out = out .. " ×" .. scale_text | ||
end | end | ||
end | end | ||