<?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%3AGETotal</id>
	<title>Module:GETotal - 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%3AGETotal"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:GETotal&amp;action=history"/>
	<updated>2026-05-03T05:44:42Z</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:GETotal&amp;diff=34961&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;--&lt;nowiki&gt;   -- Implements helper templates for {{GECoinsTotal}} and {{GECoinsTotalqty}} Adds all prices together and creates an easy to parse number --   local p = {}   local geprice = require(&#039;Module:Exchange&#039;)._price   --c}} will add the prices of a, b, and c Does not allow quantities of items Technically unlimited -- function p.simple(frame) 	local args = frame:getParent().args 	local prices = {} 	for _, v in i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:GETotal&amp;diff=34961&amp;oldid=prev"/>
		<updated>2024-10-16T23:12:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--&amp;lt;nowiki&amp;gt;   --[[ Implements helper templates for {{GECoinsTotal}} and {{GECoinsTotalqty}} Adds all prices together and creates an easy to parse number --]]   local p = {}   local geprice = require(&amp;#039;Module:Exchange&amp;#039;)._price   --[[ For simple sets, 1 item at a time {{GETotal|a|b|c}} will add the prices of a, b, and c Does not allow quantities of items Technically unlimited --]] function p.simple(frame) 	local args = frame:getParent().args 	local prices = {} 	for _, v in i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
--[[&lt;br /&gt;
Implements helper templates for {{GECoinsTotal}} and {{GECoinsTotalqty}}&lt;br /&gt;
Adds all prices together and creates an easy to parse number&lt;br /&gt;
--]]&lt;br /&gt;
 &lt;br /&gt;
local p = {}&lt;br /&gt;
 &lt;br /&gt;
local geprice = require(&amp;#039;Module:Exchange&amp;#039;)._price&lt;br /&gt;
 &lt;br /&gt;
--[[&lt;br /&gt;
For simple sets, 1 item at a time&lt;br /&gt;
{{GETotal|a|b|c}} will add the prices of a, b, and c&lt;br /&gt;
Does not allow quantities of items&lt;br /&gt;
Technically unlimited&lt;br /&gt;
--]]&lt;br /&gt;
function p.simple(frame)&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	local prices = {}&lt;br /&gt;
	for _, v in ipairs(args) do&lt;br /&gt;
		table.insert(prices,geprice(v))&lt;br /&gt;
	end&lt;br /&gt;
	return p._main(prices)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
--[[&lt;br /&gt;
For stuff that&amp;#039;s a but more complex&lt;br /&gt;
{{GETotalqty|name1=a|qty1=4|name2=b|qty2=1/4}}&lt;br /&gt;
Will add together the price of a * 4 and b / 4&lt;br /&gt;
Can recognize and parse vulgar fractions&lt;br /&gt;
All fractions and decimals will be truncated off the final price&lt;br /&gt;
Technically limited to 20, can be expanded as needed&lt;br /&gt;
--]]&lt;br /&gt;
function p.quantities(frame)&lt;br /&gt;
	local args = frame:getParent().args&lt;br /&gt;
	local prices = {}&lt;br /&gt;
	for i=1,20,1 do&lt;br /&gt;
		local itemx = args[&amp;#039;name&amp;#039;..i]&lt;br /&gt;
		if itemx then&lt;br /&gt;
			local priceret = geprice(itemx)&lt;br /&gt;
			local qtyx = args[&amp;#039;qty&amp;#039;..i] or 1&lt;br /&gt;
			local qtyret = tonumber(qtyx) or frac(qtyx) or 1&lt;br /&gt;
			table.insert(prices,math.floor(priceret * qtyret))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return p._main(prices)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
--[[&lt;br /&gt;
Helper function to parse vulgar fractions&lt;br /&gt;
If not readable as a vulgar fraction (i.e. no &amp;#039;/&amp;#039; character)&lt;br /&gt;
Returns nil, even if it can be read as a number&lt;br /&gt;
--]]&lt;br /&gt;
function frac(num)&lt;br /&gt;
	if not num then&lt;br /&gt;
		return nil&lt;br /&gt;
	elseif not num:find(&amp;#039;/&amp;#039;) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local parts = mw.text.split(num,&amp;#039;/&amp;#039;)&lt;br /&gt;
	local numer,denom = tonumber(parts[1]),tonumber(parts[2])&lt;br /&gt;
	if numer and denom then&lt;br /&gt;
		return numer / denom&lt;br /&gt;
	else&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
--[[&lt;br /&gt;
Function to add prices together&lt;br /&gt;
]]--&lt;br /&gt;
function p._main(list)&lt;br /&gt;
	local price = 0&lt;br /&gt;
	for _, v in ipairs(list) do&lt;br /&gt;
		price = price + v&lt;br /&gt;
	end&lt;br /&gt;
	return price&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
--[[&lt;br /&gt;
---- Module Access Point ----&lt;br /&gt;
Modified version of quantity.&lt;br /&gt;
Will add together the price of a * 4 and b / 4&lt;br /&gt;
Can recognize and parse vulgar fractions&lt;br /&gt;
All fractions and decimals will be truncated off the final price&lt;br /&gt;
Technically unlimited&lt;br /&gt;
 &lt;br /&gt;
To use:&lt;br /&gt;
variable &amp;#039;a&amp;#039; = array of {quantity,&amp;quot;item name&amp;quot;, etc...}&lt;br /&gt;
variable &amp;#039;b&amp;#039; = number of unique items to be included&lt;br /&gt;
--]]&lt;br /&gt;
function p._quantity(a,b)&lt;br /&gt;
	local values = a or {}&lt;br /&gt;
	local count  = b or 0&lt;br /&gt;
	local prices = {}&lt;br /&gt;
 &lt;br /&gt;
	for i=1 , (count*2) , 2 do&lt;br /&gt;
		local itemx = a[i+1]&lt;br /&gt;
		if itemx then&lt;br /&gt;
			local priceret = geprice(itemx)&lt;br /&gt;
			local qtyx = a[i] or 1&lt;br /&gt;
			local qtyret = tonumber(qtyx) or frac(qtyx) or 1&lt;br /&gt;
			table.insert(prices,math.floor(priceret * qtyret))&lt;br /&gt;
		end&lt;br /&gt;
    end&lt;br /&gt;
 &lt;br /&gt;
	return p._main(prices)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>