Home
Random
Log in
Settings
About the Deadlock Wiki
Search
Editing
Module
:
Addcommas
Give feedback
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
-- -- @Attribution https://runescape.wiki/w/Module:Addcommas -- local libraryUtil = require('libraryUtil') local p = {} -- -- main function -- keep public so it can be used in other modules -- function p._add(arg, sep) libraryUtil.checkTypeMulti('Module:Addcommas._add', 1, arg, {'number', 'string'}) libraryUtil.checkType('"Module:Addcommas"._add', 2, sep, "string", true); local lang = mw.language.getContentLanguage() local x; if type(arg) == 'number' then x = lang:formatNum(arg) else local z = tostring(arg) -- strip any existing commas z = z:gsub(',', '') local y = mw.text.split(z, '[%-β]') -- handle ranges as separate numbers -- required by [[Module:Exchange]] (p._table) if y[1] ~= '' and y[2] then y[1] = tonumber(y[1]) y[2] = tonumber(y[2]) x = lang:formatNum(y[1]) .. 'β' .. lang:formatNum(y[2]) else x = lang:formatNum(tonumber(z)) end end if (sep) then x = mw.ustring.gsub(x, ",", sep); end return x; end -- -- strips any existing commas in the input -- function p._strip(str) libraryUtil.checkType('Module:Addcommas._strip', 1, str, 'string') return str:gsub(',', '') end function p.commas(frame) --local args = require("Module:Arguments").getArgs(frame); -- Module:Arguments does not yet exist local str = frame.args[1] local delimiter = frame.args.sep return p._add(str, delimiter); end return p
Summary:
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Page included on this page:
Module:Addcommas/doc
(
view source
)