<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FMdowdell%2FCoins</id>
	<title>Module:Sandbox/Mdowdell/Coins - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FMdowdell%2FCoins"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Mdowdell/Coins&amp;action=history"/>
	<updated>2026-05-27T05:49:41Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Mdowdell/Coins&amp;diff=145824&amp;oldid=prev</id>
		<title>imported&gt;Mdowdell: ←Created page with &#039;-- &lt;pre&gt; -- -- Implements {{Coins}} and {{Rusty coins}} --  local p = {}  -- -- {{Coins}} access point -- function p.amount( frame )     local args = frame:getPa...&#039;</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Mdowdell/Coins&amp;diff=145824&amp;oldid=prev"/>
		<updated>2015-01-06T10:59:59Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/index.php?title=WP:AES&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;WP:AES (page does not exist)&quot;&gt;←&lt;/a&gt;Created page with &amp;#039;-- &amp;lt;pre&amp;gt; -- -- Implements {{Coins}} and {{Rusty coins}} --  local p = {}  -- -- {{Coins}} access point -- function p.amount( frame )     local args = frame:getPa...&amp;#039;&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;
--&lt;br /&gt;
-- Implements {{Coins}} and {{Rusty coins}}&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local p = {}&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}} or {{coins|amount=111}}&lt;br /&gt;
    local a = args[1] or args.Amount or args.amount&lt;br /&gt;
    return p._amount( a )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- {{Rusty coins}} access point&lt;br /&gt;
--&lt;br /&gt;
function p.rusty( frame )&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local a = args[1] or args.Amount or args.amount&lt;br /&gt;
    return p._amount( a, true )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--&lt;br /&gt;
-- @param a {number} Number to output with coins image&lt;br /&gt;
-- @param rusty {boolean} If true, outputs rusty coins image. Defauts to false&lt;br /&gt;
-- @return {string}&lt;br /&gt;
--&lt;br /&gt;
function p._amount ( a, rusty )&lt;br /&gt;
    -- convert used globals to locals where possible to improve performance&lt;br /&gt;
    local tostring = tostring&lt;br /&gt;
    local tonumber = tonumber&lt;br /&gt;
    local mw = mw&lt;br /&gt;
&lt;br /&gt;
    local a = tostring( a ) or &amp;#039;0&amp;#039;&lt;br /&gt;
    local color = &amp;#039;green&amp;#039;&lt;br /&gt;
    local img = &amp;#039;1&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    -- strip commas from input&lt;br /&gt;
    -- @example {{GEPrice|Foo}} -&amp;gt; &amp;#039;1,000&amp;#039;&lt;br /&gt;
    a = a:gsub( &amp;#039;,&amp;#039;, &amp;#039;&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
    -- cache tonumber( a ) to improve performance a bit&lt;br /&gt;
    num_a = tonumber( a )&lt;br /&gt;
&lt;br /&gt;
    -- dirty way of replicating #expr&lt;br /&gt;
    -- should be able to be replaced by backporting&lt;br /&gt;
    -- &amp;lt;https://git.wikimedia.org/commit/mediawiki%2Fextensions%2FParserFunctions/ea7bc2880a5e6e71d5b6c904e5299cdde30817bd&amp;gt;&lt;br /&gt;
    --&lt;br /&gt;
    -- only do this if required so as not to impact performance too much&lt;br /&gt;
    if num_a == nil then&lt;br /&gt;
        a = mw.getCurrentFrame():preprocess( &amp;#039;{{#expr:&amp;#039; .. a .. &amp;#039;}}&amp;#039; )&lt;br /&gt;
        num_a = tonumber( a )&lt;br /&gt;
&lt;br /&gt;
        if num_a == nil then&lt;br /&gt;
            num_a = 0&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- round to 2 d.p.&lt;br /&gt;
    a = math.floor( num_a * 100 + 0.5 ) / 100&lt;br /&gt;
&lt;br /&gt;
    -- set the color&lt;br /&gt;
    -- blue for positive, red for negative, green for zero&lt;br /&gt;
    -- default &amp;#039;green&amp;#039; set above&lt;br /&gt;
    if a &amp;gt; 0 then&lt;br /&gt;
        -- blue&lt;br /&gt;
        color = &amp;#039;#014cc0&amp;#039;&lt;br /&gt;
    elseif a &amp;lt; 0 then&lt;br /&gt;
        -- red&lt;br /&gt;
        color = &amp;#039;#c02614&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- set the coins image&lt;br /&gt;
    -- default &amp;#039;1&amp;#039; set above&lt;br /&gt;
    local num = math.abs( a )&lt;br /&gt;
    local amounts = { 1000, 250, 100, 25, 5, 4, 3, 2 }&lt;br /&gt;
    local i, j&lt;br /&gt;
&lt;br /&gt;
    for i = 1, 8 do&lt;br /&gt;
        j = amounts[i]&lt;br /&gt;
&lt;br /&gt;
        if num &amp;gt;= j then&lt;br /&gt;
            img = tostring( j )&lt;br /&gt;
            break&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if not rusty then&lt;br /&gt;
        img = &amp;#039;[[File:Coins &amp;#039; .. img .. &amp;#039;.png|link=Coins]]&amp;#039;&lt;br /&gt;
    else&lt;br /&gt;
        img = &amp;#039;[[File:Rusty coins &amp;#039; .. img .. &amp;#039;.png|link=Rusty coins]]&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- format number with commas&lt;br /&gt;
    a = mw.language.getContentLanguage():formatNum( a )&lt;br /&gt;
&lt;br /&gt;
    -- return &amp;#039;&amp;lt;span class=&amp;quot;coins/rusty-coins &amp;#039; .. &amp;#039;coins-XXXX &amp;#039; .. &amp;#039;coins-pos/neg&amp;quot;&amp;gt;&amp;#039; .. a .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    return &amp;#039;&amp;lt;span class=&amp;quot;coins-templ&amp;quot; style=&amp;quot;white-space:nowrap; color:&amp;#039; ..&lt;br /&gt;
        color .. &amp;#039;&amp;quot;&amp;gt;&amp;#039; .. img .. &amp;#039;&amp;amp;nbsp;&amp;#039; .. a .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Mdowdell</name></author>
	</entry>
</feed>