<?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%3AShop_calc</id>
	<title>Module:Shop calc - 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%3AShop_calc"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Shop_calc&amp;action=history"/>
	<updated>2026-05-05T16:28:07Z</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:Shop_calc&amp;diff=35113&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local p = {}  local commas = require(&#039;Module:Addcommas&#039;)._add  function expr(x) 	x = tostring(x) 	local expr_good, expr_val = pcall(mw.ext.ParserFunctions.expr, x) 	if expr_good then 		return tonumber(expr_val) 	end 	return nil end  function p.main(frame) 	local input = frame:getParent().args 	local shopIncPercent = (input.shop_inc ~= nil and input.shop_inc ~= &#039;&#039;) and tonumber(input.shop_inc) * .01 or 0 	local calcTotal = p.calc(input.base_price, shopIncPercent, input.nu...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Shop_calc&amp;diff=35113&amp;oldid=prev"/>
		<updated>2024-10-16T23:13:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {}  local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add  function expr(x) 	x = tostring(x) 	local expr_good, expr_val = pcall(mw.ext.ParserFunctions.expr, x) 	if expr_good then 		return tonumber(expr_val) 	end 	return nil end  function p.main(frame) 	local input = frame:getParent().args 	local shopIncPercent = (input.shop_inc ~= nil and input.shop_inc ~= &amp;#039;&amp;#039;) and tonumber(input.shop_inc) * .01 or 0 	local calcTotal = p.calc(input.base_price, shopIncPercent, input.nu...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add&lt;br /&gt;
&lt;br /&gt;
function expr(x)&lt;br /&gt;
	x = tostring(x)&lt;br /&gt;
	local expr_good, expr_val = pcall(mw.ext.ParserFunctions.expr, x)&lt;br /&gt;
	if expr_good then&lt;br /&gt;
		return tonumber(expr_val)&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local input = frame:getParent().args&lt;br /&gt;
	local shopIncPercent = (input.shop_inc ~= nil and input.shop_inc ~= &amp;#039;&amp;#039;) and tonumber(input.shop_inc) * .01 or 0&lt;br /&gt;
	local calcTotal = p.calc(input.base_price, shopIncPercent, input.number_bought, tonumber(input.base_stock), tonumber(input.cur_stock))&lt;br /&gt;
	&lt;br /&gt;
	local costPerHop = commas(calcTotal)&lt;br /&gt;
	local averageCost = commas(calcTotal / input.number_bought)&lt;br /&gt;
	&lt;br /&gt;
	if (tonumber(input.total_purchased) &amp;gt; 0)&lt;br /&gt;
	then&lt;br /&gt;
		local totalCost = commas((calcTotal / input.number_bought) * input.total_purchased)&lt;br /&gt;
		return string.format(&amp;#039;\n Total cost per hop: %s \n Average cost per item is: %s per item \n Total cost: %s&amp;#039;, costPerHop, averageCost, totalCost)&lt;br /&gt;
	else&lt;br /&gt;
		return string.format(&amp;#039;\n Total cost per hop: %s \n Average cost per item is: %s per item&amp;#039;, costPerHop, averageCost)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.calc(basePrice, shopIncrease, numberBought, baseStock, currentStock)&lt;br /&gt;
	local total = 0&lt;br /&gt;
	&lt;br /&gt;
	-- These two values are optional&lt;br /&gt;
	if (baseStock &amp;gt; 0 and currentStock &amp;gt; 0)&lt;br /&gt;
	then&lt;br /&gt;
		local first = baseStock - currentStock&lt;br /&gt;
		local last = numberBought + (baseStock - currentStock) - 1&lt;br /&gt;
		&lt;br /&gt;
		for i = first, last do&lt;br /&gt;
			--start at 1 and subtract 1 in function so it actually does 0 - (numberBought)&lt;br /&gt;
			total = total + basePrice + math.floor((shopIncrease * basePrice) * i)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		for i = 1, numberBought do&lt;br /&gt;
			--start at 1 and subtract 1 in function so it actually does 0 - (numberBought - 1)&lt;br /&gt;
			total = total + basePrice + math.floor((shopIncrease*basePrice)*(i - 1))&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return total&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>