Module:Ticks: Difference between revisions

From HighSpell Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
     local amount = tonumber(args[1] or args["amount"]) or 0
     local amount = tonumber(args[1] or args["amount"]) or 0
     local seconds = amount * 0.6
     local seconds = amount * 0.6
    local roundedSeconds = math.floor(seconds + 0.5)


     local timeDisplay = string.format('<abbr title="Time in seconds">%ds</abbr>', roundedSeconds)
    -- Format to one decimal place explicitly
    local secondsFormatted = string.format("%.1f", seconds)
 
     local timeDisplay = string.format('<abbr title="Time in seconds">%ss</abbr>', secondsFormatted)


     return string.format("%d [[Ticks]] (%s)", amount, timeDisplay)
     return string.format("%d [[Ticks]] (%s)", amount, timeDisplay)

Latest revision as of 15:38, 19 May 2025

Documentation for this module may be created at Module:Ticks/doc

local p = {}

function p.display(frame)
    local args = frame:getParent().args
    local amount = tonumber(args[1] or args["amount"]) or 0
    local seconds = amount * 0.6

    -- Format to one decimal place explicitly
    local secondsFormatted = string.format("%.1f", seconds)

    local timeDisplay = string.format('<abbr title="Time in seconds">%ss</abbr>', secondsFormatted)

    return string.format("%d [[Ticks]] (%s)", amount, timeDisplay)
end

return p