Module:Utility: Difference between revisions

From Kronopolis and the Flat Plane
No edit summary
Tag: Manual revert
No edit summary
Tags: Manual revert Reverted
Line 1: Line 1:
local p = {}
local p = {}


function firstToUpper(str)
function p.firstToUpper(str)
     return (str:gsub("^%l", string.upper))
     return (str:gsub("^%l", string.upper))
end
end


function formatLevel(lv)
function p.formatLevel(lv)
     local str
     local str
     if lv == 0 then str = 'Cantrip'  
     if lv == 0 then str = 'Cantrip'  

Revision as of 12:28, 3 March 2023

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

local p = {}

function p.firstToUpper(str)
    return (str:gsub("^%l", string.upper))
end

function p.formatLevel(lv)
    local str
    if lv == 0 then str = 'Cantrip' 
    elseif lv == 1 then str = '1st' 
    elseif lv == 2 then str = '2nd' 
    elseif lv == 3 then str = '3rd' 
    else str = lv .. 'th'
    end
    return str
end

return p