<?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%3ACoins</id>
	<title>Module:Coins - 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%3ACoins"/>
	<link rel="alternate" type="text/html" href="https://wiki.2006scape.org/index.php?title=Module:Coins&amp;action=history"/>
	<updated>2026-04-22T23:16:57Z</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:Coins&amp;diff=541&amp;oldid=prev</id>
		<title>Halogod35: Created page with &quot;-- &lt;pre&gt; -- Implements {{Coins}} -- Original source: http://runescape.wiki/w/Module:Coins?action=history  local p = {}  local function amount(a) 	-- convert used globals to locals where possible to improve performance 	local math = math 	local string = string 	local table = table 	local mw = mw         local expr = mw.ext.ParserFunctions.expr  	local ret = {&#039;&lt;span class=&quot;coins coins-&#039;, true, true, true, &#039;&lt;/span&gt;&#039;}  	-- strip commas from input 	-- @example &#039;123,456,789&#039;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.2006scape.org/index.php?title=Module:Coins&amp;diff=541&amp;oldid=prev"/>
		<updated>2023-02-04T00:29:25Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;-- &amp;lt;pre&amp;gt; -- Implements {{Coins}} -- Original source: http://runescape.wiki/w/Module:Coins?action=history  local p = {}  local function amount(a) 	-- convert used globals to locals where possible to improve performance 	local math = math 	local string = string 	local table = table 	local mw = mw         local expr = mw.ext.ParserFunctions.expr  	local ret = {&amp;#039;&amp;lt;span class=&amp;quot;coins coins-&amp;#039;, true, true, true, &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;}  	-- strip commas from input 	-- @example &amp;#039;123,456,789&amp;#039;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- &amp;lt;pre&amp;gt;&lt;br /&gt;
-- Implements {{Coins}}&lt;br /&gt;
-- Original source: http://runescape.wiki/w/Module:Coins?action=history&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function amount(a)&lt;br /&gt;
	-- convert used globals to locals where possible to improve performance&lt;br /&gt;
	local math = math&lt;br /&gt;
	local string = string&lt;br /&gt;
	local table = table&lt;br /&gt;
	local mw = mw&lt;br /&gt;
        local expr = mw.ext.ParserFunctions.expr&lt;br /&gt;
&lt;br /&gt;
	local ret = {&amp;#039;&amp;lt;span class=&amp;quot;coins coins-&amp;#039;, true, true, true, &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
	-- strip commas from input&lt;br /&gt;
	-- @example &amp;#039;123,456,789&amp;#039;&lt;br /&gt;
	a = string.gsub(a, &amp;#039;,&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	-- check for decimals/division to determine if output should have forced 2 decimal places&lt;br /&gt;
	local has_decimal_or_division = false&lt;br /&gt;
	if string.match(a, &amp;quot;[./]&amp;quot;) then&lt;br /&gt;
		has_decimal_or_division = true&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- for performance reasons, only calculate expr if required&lt;br /&gt;
	if tonumber(a) == nil then&lt;br /&gt;
		a = tonumber(expr(a)) or 0&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- round to two decimal places&lt;br /&gt;
	a = math.floor(a * 100 + 0.5) / 100&lt;br /&gt;
&lt;br /&gt;
	local num = math.abs(a)&lt;br /&gt;
	local amounts = {1000, 250, 100, 25, 5, 4, 3, 2, 1}&lt;br /&gt;
	local result = 1000&lt;br /&gt;
	&lt;br /&gt;
	for _, amount in ipairs(amounts) do&lt;br /&gt;
		result = amount&lt;br /&gt;
		if num &amp;gt;= amount then&lt;br /&gt;
			break&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	ret[2] = tostring(result)&lt;br /&gt;
&lt;br /&gt;
	-- set a class to denote positive or negative (css sets the colour)&lt;br /&gt;
	if a &amp;gt; 0 then&lt;br /&gt;
		ret[3] = &amp;#039; coins-pos&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
	elseif a &amp;lt; 0 then&lt;br /&gt;
		ret[3] = &amp;#039; coins-neg&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		ret[3] = &amp;#039;&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- format number with commas&lt;br /&gt;
	if has_decimal_or_division then&lt;br /&gt;
		local b = 0&lt;br /&gt;
		a, b = math.modf(a)&lt;br /&gt;
		b = math.abs(b)&lt;br /&gt;
		-- hack fix for formatNum stripping the sign from -0&lt;br /&gt;
		if (a &amp;gt; 999 or a &amp;lt; -999) then&lt;br /&gt;
			a = mw.language.getContentLanguage():formatNum(a)&lt;br /&gt;
		end&lt;br /&gt;
		b = string.sub(string.format(&amp;quot;%.2f&amp;quot;, b),2)&lt;br /&gt;
		ret[4] = a..b&lt;br /&gt;
	else&lt;br /&gt;
		ret[4] = mw.language.getContentLanguage():formatNum(a)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return table.concat( ret )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- {{Coins}} access point&lt;br /&gt;
--&lt;br /&gt;
function p.amount(frame)&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	-- for {{coins|111}}&lt;br /&gt;
	local a = args[1] or &amp;#039;0&amp;#039;&lt;br /&gt;
	return amount(a)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- Module access point&lt;br /&gt;
--&lt;br /&gt;
function p._amount(a)&lt;br /&gt;
	a = tostring(a) or &amp;#039;0&amp;#039;&lt;br /&gt;
	return amount(a)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Halogod35</name></author>
	</entry>
</feed>