<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACurrency</id>
	<title>Module:Currency - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3ACurrency"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Currency&amp;action=history"/>
	<updated>2026-05-02T21:47:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=Module:Currency&amp;diff=781&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;-- &lt;pre&gt; -- Implements various currency templates --  local p = {}  local function amount (a, coinType)     -- 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 inventory-image &#039;, true, true, true, true, &#039;&lt;/span&gt;&#039;}     -- add class for CSS to add the correct image with     -- see [[...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Currency&amp;diff=781&amp;oldid=prev"/>
		<updated>2024-10-12T22:57:40Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;-- &amp;lt;pre&amp;gt; -- Implements various currency templates --  local p = {}  local function amount (a, coinType)     -- 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 inventory-image &amp;#039;, true, true, true, true, &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;}     -- add class for CSS to add the correct image with     -- see [[...&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 various currency templates&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local function amount (a, coinType)&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 inventory-image &amp;#039;, true, true, true, true, &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;}&lt;br /&gt;
    -- add class for CSS to add the correct image with&lt;br /&gt;
    -- see [[MediaWiki:Common.less/coins.less]] for more details&lt;br /&gt;
    local coinClasses = {&lt;br /&gt;
        coins = &amp;#039;coins-&amp;#039;,&lt;br /&gt;
        nocoins = &amp;#039;&amp;#039;,&lt;br /&gt;
        nocoinsc = &amp;#039;&amp;#039;&lt;br /&gt;
    }&lt;br /&gt;
    local noCoins = {&lt;br /&gt;
    	nocoins = &amp;#039;&amp;#039;,&lt;br /&gt;
    	nocoinsc = &amp;#039; coins&amp;#039;&lt;br /&gt;
    }&lt;br /&gt;
    local a2, num, amounts, i, j&lt;br /&gt;
&lt;br /&gt;
    ret[1] = &amp;#039;&amp;lt;span class=&amp;quot;coins inventory-image &amp;#039;&lt;br /&gt;
    ret[2] = coinClasses[coinType]&lt;br /&gt;
&lt;br /&gt;
	if noCoins[coinType] then&lt;br /&gt;
		ret[1] = &amp;#039;&amp;lt;span class=&amp;quot;coins &amp;#039;&lt;br /&gt;
	end&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 = string.gsub(a, &amp;#039;,&amp;#039;, &amp;#039;&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
    -- cache tonumber result&lt;br /&gt;
    a2 = tonumber(a)&lt;br /&gt;
&lt;br /&gt;
    -- only do this if required so as not to impact performance too much&lt;br /&gt;
    if a2 == nil then&lt;br /&gt;
        a = expr(a)&lt;br /&gt;
        a2 = tonumber(a) or 0&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- round to 2 d.p.&lt;br /&gt;
    a = math.floor(a2 * 100 + 0.5) / 100&lt;br /&gt;
&lt;br /&gt;
    -- select which image class to use for css to hook off&lt;br /&gt;
    num = math.abs(a)&lt;br /&gt;
    amounts = {10000, 1000, 250, 100, 25, 5, 4, 3, 2, 1}&lt;br /&gt;
&lt;br /&gt;
    for i = 1, #amounts do&lt;br /&gt;
        j = amounts[i]&lt;br /&gt;
&lt;br /&gt;
        if num &amp;gt;= j then&lt;br /&gt;
            break&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    ret[3] = tostring(j)&lt;br /&gt;
    if noCoins[coinType] then&lt;br /&gt;
    	ret[3] = &amp;#039;&amp;#039;&lt;br /&gt;
    end&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[4] = &amp;#039; coins-pos&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
    elseif a &amp;lt; 0 then&lt;br /&gt;
        ret[4] = &amp;#039; coins-neg&amp;quot;&amp;gt;&amp;#039;&lt;br /&gt;
    else&lt;br /&gt;
        ret[4] = &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;
    ret[5] = mw.language.getContentLanguage():formatNum(a)&lt;br /&gt;
    if noCoins[coinType] then&lt;br /&gt;
    	ret[5] = ret[5] .. noCoins[coinType]&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}}&lt;br /&gt;
--&lt;br /&gt;
function p.coins(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, &amp;#039;coins&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.nocoins(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local c = &amp;#039;nocoins&amp;#039;&lt;br /&gt;
    if string.find(args[2] or &amp;#039;&amp;#039;, &amp;#039;%S&amp;#039;) then&lt;br /&gt;
    	c = &amp;#039;nocoinsc&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
    local a = args[1] or &amp;#039;0&amp;#039;&lt;br /&gt;
    return amount(a, c)&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, coinType)&lt;br /&gt;
    a = tostring(a) or &amp;#039;0&amp;#039;&lt;br /&gt;
    return amount(a, coinType)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>