<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.2006scape.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AAddcommas</id>
	<title>Module:Addcommas - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.2006scape.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AAddcommas"/>
	<link rel="alternate" type="text/html" href="https://wiki.2006scape.org/index.php?title=Module:Addcommas&amp;action=history"/>
	<updated>2026-04-24T10:24:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>https://wiki.2006scape.org/index.php?title=Module:Addcommas&amp;diff=97&amp;oldid=prev</id>
		<title>Halogod35: adding commas, but in lua</title>
		<link rel="alternate" type="text/html" href="https://wiki.2006scape.org/index.php?title=Module:Addcommas&amp;diff=97&amp;oldid=prev"/>
		<updated>2023-02-02T06:03:31Z</updated>

		<summary type="html">&lt;p&gt;adding commas, but in lua&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
{{Helper module|name=Addcommas&lt;br /&gt;
|fname1=_add(arg)&lt;br /&gt;
|ftype1=Number&lt;br /&gt;
|fuse1=Formats the number arg with commas&lt;br /&gt;
|fname2=_strip(arg)&lt;br /&gt;
|ftype2=Number&lt;br /&gt;
|fuse2=Removes all commas from arg&lt;br /&gt;
}}&lt;br /&gt;
--]]&lt;br /&gt;
-- &amp;lt;nowiki&amp;gt;&lt;br /&gt;
--&lt;br /&gt;
-- Implements {{Addcommas}}&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- main function&lt;br /&gt;
-- keep public so it can be used in other modules&lt;br /&gt;
--&lt;br /&gt;
function p._add( arg )&lt;br /&gt;
    local lang = mw.language.getContentLanguage()&lt;br /&gt;
    local z = tostring( arg )&lt;br /&gt;
    local y = mw.text.split( z, &amp;#039;[%-–]&amp;#039; )&lt;br /&gt;
    local x&lt;br /&gt;
&lt;br /&gt;
    -- strip any existing commas&lt;br /&gt;
    z = z:gsub( &amp;#039;,&amp;#039;, &amp;#039;&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
    -- handle ranges as separate numbers&lt;br /&gt;
    -- required by [[Module:Exchange]] (p._table)&lt;br /&gt;
    if y[1] ~= &amp;#039;&amp;#039; and y[2] then&lt;br /&gt;
        y[1] = tonumber( y[1] )&lt;br /&gt;
        y[2] = tonumber( y[2] )&lt;br /&gt;
        x = lang:formatNum( y[1] ) .. &amp;#039;–&amp;#039; .. lang:formatNum( y[2] )&lt;br /&gt;
    else&lt;br /&gt;
        x = lang:formatNum( tonumber( z ) )&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return x&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- strips any existing commas in the input&lt;br /&gt;
--&lt;br /&gt;
function p._strip( str )&lt;br /&gt;
    str = tostring( str )&lt;br /&gt;
    return str:gsub( &amp;#039;,&amp;#039;, &amp;#039;&amp;#039; )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.commas ( frame )&lt;br /&gt;
    local str = frame:getParent().args[1]&lt;br /&gt;
    return p._add( str )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Halogod35</name></author>
	</entry>
</feed>