Module:ItemData: Difference between revisions

m cleanup
add comma formatting
Line 11: Line 11:
return nil
return nil
end
end
-- Adds commas delimiter to the thousands place
-- NOTE: Thousands delimiters are language specific. Some languages use commas, periods, or spaces.
-- TODO: Implement language check either through extension or lua
function Format(amount)
    local formatted = amount
    while true do
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
        if (k == 0) then
            break
        end
    end
    return formatted
end


--{{#invoke:ItemData|get_cost|ITEM_NAME}}--
--{{#invoke:ItemData|get_cost|ITEM_NAME}}--
Line 28: Line 43:
until cur_item == nil
until cur_item == nil


return cost
return Format(cost)
end
end