<?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%3AProfitable_alchemy</id>
	<title>Module:Profitable alchemy - 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%3AProfitable_alchemy"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Profitable_alchemy&amp;action=history"/>
	<updated>2026-04-30T06:36:47Z</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:Profitable_alchemy&amp;diff=34219&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local p = {}  local prices = mw.loadJsonData(&#039;Module:GEPrices/data.json&#039;) local values = mw.loadJsonData(&#039;Module:GEValues/data.json&#039;) local limits = mw.loadJsonData(&#039;Module:GELimits/data.json&#039;) local volumes = mw.loadJsonData(&#039;Module:GEVolumes/data.json&#039;) local members = mw.loadJsonData(&#039;Module:GEMembers/data.json&#039;)  local natureRunePrice = prices[&#039;Nature rune&#039;] local fireRunePrice = prices[&#039;Fire rune&#039;]  local commas = require(&#039;Module:Addcommas&#039;)._add local paramTest = r...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Profitable_alchemy&amp;diff=34219&amp;oldid=prev"/>
		<updated>2024-10-15T23:37:23Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {}  local prices = mw.loadJsonData(&amp;#039;Module:GEPrices/data.json&amp;#039;) local values = mw.loadJsonData(&amp;#039;Module:GEValues/data.json&amp;#039;) local limits = mw.loadJsonData(&amp;#039;Module:GELimits/data.json&amp;#039;) local volumes = mw.loadJsonData(&amp;#039;Module:GEVolumes/data.json&amp;#039;) local members = mw.loadJsonData(&amp;#039;Module:GEMembers/data.json&amp;#039;)  local natureRunePrice = prices[&amp;#039;Nature rune&amp;#039;] local fireRunePrice = prices[&amp;#039;Fire rune&amp;#039;]  local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add local paramTest = r...&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 prices = mw.loadJsonData(&amp;#039;Module:GEPrices/data.json&amp;#039;)&lt;br /&gt;
local values = mw.loadJsonData(&amp;#039;Module:GEValues/data.json&amp;#039;)&lt;br /&gt;
local limits = mw.loadJsonData(&amp;#039;Module:GELimits/data.json&amp;#039;)&lt;br /&gt;
local volumes = mw.loadJsonData(&amp;#039;Module:GEVolumes/data.json&amp;#039;)&lt;br /&gt;
local members = mw.loadJsonData(&amp;#039;Module:GEMembers/data.json&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local natureRunePrice = prices[&amp;#039;Nature rune&amp;#039;]&lt;br /&gt;
local fireRunePrice = prices[&amp;#039;Fire rune&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add&lt;br /&gt;
local paramTest = require(&amp;#039;Module:Paramtest&amp;#039;)&lt;br /&gt;
local yesNo = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local AlchemyTypes = {&lt;br /&gt;
	[&amp;#039;general store&amp;#039;] = { cost = 0, perHour = 50000, mult = 0.1, label = &amp;quot;Sell price&amp;quot;},&lt;br /&gt;
	[&amp;#039;general store single&amp;#039;] = { cost = 0, perHour = 300, mult = 0.6, label = &amp;quot;Sell price&amp;quot;},&lt;br /&gt;
	[&amp;#039;low alch&amp;#039;] = { cost = natureRunePrice, perHour = 2000, mult = 0.4, label = &amp;quot;[[Low Alch]]&amp;quot;},&lt;br /&gt;
	[&amp;#039;fire staff&amp;#039;] = { cost = natureRunePrice, perHour = 1200, mult = 0.6, label = &amp;quot;[[High Alch]]&amp;quot;},&lt;br /&gt;
	[&amp;#039;no staff&amp;#039;] = { cost = natureRunePrice + 5 * fireRunePrice, perHour = 1200, mult = 0.6, label = &amp;quot;[[High Alch]]&amp;quot;},&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function buildRow(item, price, alch, profit, roi, limit, volume, profitMax, profitPerMinute, membersStr, membersVal)&lt;br /&gt;
	local row = mw.html.create(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;td&amp;#039;):wikitext(&amp;#039;[[File:&amp;#039; .. item .. &amp;#039;.png|link=&amp;#039; .. item .. &amp;#039;]]&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(&amp;#039;[[&amp;#039; .. item  .. &amp;#039;]]&amp;#039;):attr(&amp;#039;data-sort-value&amp;#039;, item):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(commas(price)):attr(&amp;#039;data-sort-value&amp;#039;, price):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(commas(alch)):attr(&amp;#039;data-sort-value&amp;#039;, alch):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(commas(profit)):attr(&amp;#039;data-sort-value&amp;#039;, profit):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(roi):attr(&amp;#039;data-sort-value&amp;#039;, roi):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(commas(limit)):attr(&amp;#039;data-sort-value&amp;#039;, limit):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(commas(volume)):attr(&amp;#039;data-sort-value&amp;#039;, volume):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(commas(profitMax)):attr(&amp;#039;data-sort-value&amp;#039;, profitMax):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(commas(profitPerMinute)):attr(&amp;#039;data-sort-value&amp;#039;, profitPerMinute):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(membersStr):attr(&amp;#039;data-sort-value&amp;#039;, tostring(membersVal)):done()&lt;br /&gt;
		:tag(&amp;#039;td&amp;#039;):wikitext(&amp;#039;[[Exchange:&amp;#039; .. item .. &amp;#039;|view]]&amp;#039;):done()&lt;br /&gt;
	return row&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function createHeader(label)&lt;br /&gt;
	local ret = mw.html.create(&amp;#039;table&amp;#039;):addClass(&amp;#039;wikitable sortable sticky-header align-center-1 align-right-3 align-right-4 align-right-5 align-right-6 align-right-7 align-right-8 align-right-9 align-center-10 align-center-11&amp;#039;)&lt;br /&gt;
	ret:tag(&amp;#039;tr&amp;#039;):tag(&amp;#039;th&amp;#039;):attr(&amp;#039;colspan&amp;#039;, &amp;#039;2&amp;#039;):wikitext(&amp;#039;Item&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;GE Price&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(label):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Profit&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;[[wikipedia:Return on investment|ROI%]]&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;[[Grand Exchange#Trade restrictions|Limit]]&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;[[Grand Exchange#Volume|Volume]]&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Max profit&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Profit per Minute&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Members&amp;#039;):done()&lt;br /&gt;
		:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;Details&amp;#039;):done()&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function sortByProfit(profitsOne, profitsTwo)&lt;br /&gt;
	return profitsOne[2] &amp;gt; profitsTwo[2]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function getData(minBuyLimit, costToAlch, mult)&lt;br /&gt;
	local profits = {}&lt;br /&gt;
	for item, price in pairs(prices) do&lt;br /&gt;
		if(tonumber(price)) then&lt;br /&gt;
			-- If limit is above the requested minimum and the item has a value&lt;br /&gt;
			if(((tonumber(limits[item]) or 5000) &amp;gt; minBuyLimit) and values[item]) then&lt;br /&gt;
				local profit = math.floor(values[item] * mult) - (price + costToAlch)&lt;br /&gt;
				if(profit &amp;gt; 0) then&lt;br /&gt;
					table.insert(profits, { item, profit })&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	table.sort(profits, sortByProfit)&lt;br /&gt;
	return profits&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	local minBuyLimit = paramTest.default_to(tonumber(args.minbuylimit), -1)&lt;br /&gt;
	local alchType = paramTest.default_to(string.lower(args.alchtype), &amp;#039;fire staff&amp;#039;)&lt;br /&gt;
	alchType = AlchemyTypes[alchType]&lt;br /&gt;
	&lt;br /&gt;
	data = getData(minBuyLimit, alchType.cost, alchType.mult)&lt;br /&gt;
	&lt;br /&gt;
	if #data == 0 then&lt;br /&gt;
		return &amp;#039;\&amp;#039;\&amp;#039;\&amp;#039;No items are currently profitable.\&amp;#039;\&amp;#039;\&amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local ret = createHeader(alchType.label)&lt;br /&gt;
	for i, itemData in ipairs(data) do&lt;br /&gt;
		local item = itemData[1]&lt;br /&gt;
		local profit = itemData[2]&lt;br /&gt;
		local price = prices[item]&lt;br /&gt;
		local alch = math.floor(values[item] * alchType.mult)&lt;br /&gt;
		local limit = limits[item] or 0&lt;br /&gt;
		local volume = volumes[item]&lt;br /&gt;
		local roi = string.format(&amp;#039;%.2f&amp;#039;, 100 * (profit / (price + natureRunePrice))) .. &amp;#039;%&amp;#039;&lt;br /&gt;
		local profitMax = limit and (math.min(alchType.perHour * 4, math.floor(math.min(limit, volume / 24 * 4))) * profit) or (alchType.perHour * 4 * profit)&lt;br /&gt;
		local profitPerMinute = math.floor(profit * (alchType.perHour / 60))&lt;br /&gt;
		&lt;br /&gt;
		local membersStr = &amp;#039;?&amp;#039;&lt;br /&gt;
		if(members[item]) then&lt;br /&gt;
			membersStr = &amp;#039;[[File:Member icon.png|link=Members]]&amp;#039;&lt;br /&gt;
		elseif(not members[item]) then&lt;br /&gt;
			membersStr = &amp;#039;[[File:Free-to-play icon.png|link=Free-to-play]]&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		ret:node(buildRow(item, price, alch, profit, roi, limit, volume, profitMax, profitPerMinute, membersStr, members[item]))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	return p._main(frame.args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>