<?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%3AGiants%27_Foundry_Calculator</id>
	<title>Module:Giants&#039; Foundry Calculator - 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%3AGiants%27_Foundry_Calculator"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Giants%27_Foundry_Calculator&amp;action=history"/>
	<updated>2026-05-05T15:19:30Z</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:Giants%27_Foundry_Calculator&amp;diff=34967&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local experience = require( &#039;Module:Experience&#039; ) local paramtest = require ( &#039;Module:Paramtest&#039; ) local allMoulds = require( &quot;Module:Giants&#039; Foundry Calculator/Moulds&quot; ) local gePrices = mw.loadJsonData(&#039;Module:GEPrices/data.json&#039;) local commas = require(&#039;Module:Addcommas&#039;)._add local coins = require(&#039;Module:Coins&#039;)._amount local scp = require(&#039;Module:SCP&#039;)._main  local p = {}  function p.lazyplink(str) 	return &#039;link=&#039; .. str .. &#039; [[&#039; .. str ....&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Giants%27_Foundry_Calculator&amp;diff=34967&amp;oldid=prev"/>
		<updated>2024-10-16T23:12:13Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local experience = require( &amp;#039;Module:Experience&amp;#039; ) local paramtest = require ( &amp;#039;Module:Paramtest&amp;#039; ) local allMoulds = require( &amp;quot;Module:Giants&amp;#039; Foundry Calculator/Moulds&amp;quot; ) local gePrices = mw.loadJsonData(&amp;#039;Module:GEPrices/data.json&amp;#039;) local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add local coins = require(&amp;#039;Module:Coins&amp;#039;)._amount local scp = require(&amp;#039;Module:SCP&amp;#039;)._main  local p = {}  function p.lazyplink(str) 	return &amp;#039;&lt;a href=&quot;/index.php?title=File:%27_.._str_.._%27.png&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;File:&amp;#039; .. str .. &amp;#039;.png (page does not exist)&quot;&gt;link=&amp;#039; .. str .. &amp;#039;&lt;/a&gt; [[&amp;#039; .. str ....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local experience = require( &amp;#039;Module:Experience&amp;#039; )&lt;br /&gt;
local paramtest = require ( &amp;#039;Module:Paramtest&amp;#039; )&lt;br /&gt;
local allMoulds = require( &amp;quot;Module:Giants&amp;#039; Foundry Calculator/Moulds&amp;quot; )&lt;br /&gt;
local gePrices = mw.loadJsonData(&amp;#039;Module:GEPrices/data.json&amp;#039;)&lt;br /&gt;
local commas = require(&amp;#039;Module:Addcommas&amp;#039;)._add&lt;br /&gt;
local coins = require(&amp;#039;Module:Coins&amp;#039;)._amount&lt;br /&gt;
local scp = require(&amp;#039;Module:SCP&amp;#039;)._main&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.lazyplink(str)&lt;br /&gt;
	return &amp;#039;[[File:&amp;#039; .. str .. &amp;#039;.png|link=&amp;#039; .. str .. &amp;#039;]] [[&amp;#039; .. str .. &amp;#039;]]&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.strtobool(str)&lt;br /&gt;
	local result = false&lt;br /&gt;
	if str == &amp;#039;true&amp;#039; then&lt;br /&gt;
		result = true&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.experience(quality)&lt;br /&gt;
	local result = (math.floor(quality*quality/73)+math.floor(1.5*quality)+1)*30&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.metalScore(tier1, tier2, amount1, amount2)&lt;br /&gt;
	local value1&lt;br /&gt;
	local value2&lt;br /&gt;
	if tier2 == tier1 or tier2 == 0 then&lt;br /&gt;
		value1 = 10*tier1&lt;br /&gt;
		value2 = 0&lt;br /&gt;
	else&lt;br /&gt;
		value1 = 10*tier1*amount1/28&lt;br /&gt;
		value2 = 10*tier2*amount2/28&lt;br /&gt;
	end&lt;br /&gt;
	local result = math.floor((math.floor(10*value1)+math.floor(10*value2)+math.floor(value1*value2))/10)&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local barTier = {&lt;br /&gt;
	[&amp;#039;None&amp;#039;] = 0,&lt;br /&gt;
	[&amp;#039;Bronze&amp;#039;] = 1,&lt;br /&gt;
	[&amp;#039;Iron&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;Steel&amp;#039;] = 3,&lt;br /&gt;
	[&amp;#039;Mithril&amp;#039;] = 4,&lt;br /&gt;
	[&amp;#039;Adamantite&amp;#039;] = 5,&lt;br /&gt;
	[&amp;#039;Runite&amp;#039;] = 6&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
local itemBarWorth = {&lt;br /&gt;
	[&amp;#039;platebody&amp;#039;] = 4,&lt;br /&gt;
	[&amp;#039;warhammer&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;battleaxe&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;chainbody&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;kiteshield&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;2h sword&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;platelegs&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;plateskirt&amp;#039;] = 2,&lt;br /&gt;
	[&amp;#039;scimitar&amp;#039;] = 1,&lt;br /&gt;
	[&amp;#039;longsword&amp;#039;] = 1,&lt;br /&gt;
	[&amp;#039;full helm&amp;#039;] = 1,&lt;br /&gt;
	[&amp;#039;sq shield&amp;#039;] = 1,&lt;br /&gt;
	[&amp;#039;claws&amp;#039;] = 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
--requests and their frequency, sums up to 24&lt;br /&gt;
local requestCombinations = {&lt;br /&gt;
	[{&amp;#039;broad&amp;#039;,&amp;#039;heavy&amp;#039;}] = 3,&lt;br /&gt;
	[{&amp;#039;broad&amp;#039;,&amp;#039;light&amp;#039;}]=3,&lt;br /&gt;
	[{&amp;#039;broad&amp;#039;,&amp;#039;spiked&amp;#039;}]=1,&lt;br /&gt;
	[{&amp;#039;broad&amp;#039;,&amp;#039;flat&amp;#039;}]=1,&lt;br /&gt;
	[{&amp;#039;narrow&amp;#039;,&amp;#039;heavy&amp;#039;}]=3,&lt;br /&gt;
	[{&amp;#039;narrow&amp;#039;,&amp;#039;light&amp;#039;}]=3,&lt;br /&gt;
	[{&amp;#039;narrow&amp;#039;,&amp;#039;spiked&amp;#039;}]=1,&lt;br /&gt;
	[{&amp;#039;narrow&amp;#039;,&amp;#039;flat&amp;#039;}]=1,&lt;br /&gt;
	[{&amp;#039;heavy&amp;#039;,&amp;#039;spiked&amp;#039;}]=2,&lt;br /&gt;
	[{&amp;#039;heavy&amp;#039;,&amp;#039;flat&amp;#039;}]=2,&lt;br /&gt;
	[{&amp;#039;light&amp;#039;,&amp;#039;spiked&amp;#039;}]=2,&lt;br /&gt;
	[{&amp;#039;light&amp;#039;,&amp;#039;flat&amp;#039;}]=2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.difficulty(score)&lt;br /&gt;
	local result = 0&lt;br /&gt;
	if score &amp;lt; 20 then&lt;br /&gt;
		result = 3&lt;br /&gt;
	elseif score &amp;lt; 60 then&lt;br /&gt;
		result = 4&lt;br /&gt;
	elseif score &amp;lt; 90 then&lt;br /&gt;
		result = 5&lt;br /&gt;
	elseif score &amp;lt; 120 then&lt;br /&gt;
		result = 6&lt;br /&gt;
	else&lt;br /&gt;
		result = 7&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--maps the name of each mould to whether they are unlocked&lt;br /&gt;
function p.mouldsUnlocked(mould1,mould2,mould3,mould4,mould5,mould6,mould7,mould8,mould9,mould10,mould11,mould12,mould13,mould14,mould15)&lt;br /&gt;
	local results = {&lt;br /&gt;
		[&amp;#039;Stiletto Forte&amp;#039;] = p.strtobool(mould1),&lt;br /&gt;
		[&amp;#039;Defender Base&amp;#039;] = p.strtobool(mould2),&lt;br /&gt;
		[&amp;#039;Juggernaut Forte&amp;#039;] = p.strtobool(mould3),&lt;br /&gt;
		[&amp;#039;Chopper Forte +1&amp;#039;] = p.strtobool(mould4),&lt;br /&gt;
		[&amp;#039;Spiker!&amp;#039;] = p.strtobool(mould5),&lt;br /&gt;
		[&amp;#039;Flamberge Blade&amp;#039;] = p.strtobool(mould6),&lt;br /&gt;
		[&amp;#039;Serpent Blade&amp;#039;] = p.strtobool(mould7),&lt;br /&gt;
		[&amp;#039;Claymore Blade&amp;#039;] = p.strtobool(mould8),&lt;br /&gt;
		[&amp;#039;Fleur de Blade&amp;#039;] = p.strtobool(mould9),&lt;br /&gt;
		[&amp;#039;Choppa!&amp;#039;] = p.strtobool(mould10),&lt;br /&gt;
		[&amp;#039;Corrupted Point&amp;#039;] = p.strtobool(mould11),&lt;br /&gt;
		[&amp;#039;Defenders Tip&amp;#039;] = p.strtobool(mould12),&lt;br /&gt;
		[&amp;#039;Serrated Tip&amp;#039;] = p.strtobool(mould13),&lt;br /&gt;
		[&amp;#039;Needle Point&amp;#039;] = p.strtobool(mould14),&lt;br /&gt;
		[&amp;#039;The Point!&amp;#039;] = p.strtobool(mould15)&lt;br /&gt;
	}&lt;br /&gt;
	return results&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--gives the average quality and average xp over all the possible requests. Done by going over all possible mould combinations and seeing which one is the best&lt;br /&gt;
function p.averageQualityExp(level,unlockedMoulds,metalscore)&lt;br /&gt;
	local scores = {[&amp;#039;Forte&amp;#039;] = {}, [&amp;#039;Blade&amp;#039;] = {}, [&amp;#039;Tip&amp;#039;] = {}}&lt;br /&gt;
	for combo,_ in pairs(requestCombinations) do&lt;br /&gt;
		for mouldtype,__ in pairs(scores) do&lt;br /&gt;
			scores[mouldtype][combo]=0&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local temp&lt;br /&gt;
	for _,mould in ipairs(allMoulds) do&lt;br /&gt;
		if mould.level &amp;lt;= level and (mould.default or unlockedMoulds[mould.name]) then&lt;br /&gt;
			for combo,__ in pairs(requestCombinations) do&lt;br /&gt;
				temp = mould[combo[1]]+mould[combo[2]]&lt;br /&gt;
				if scores[mould.type][combo] &amp;lt; temp then&lt;br /&gt;
					scores[mould.type][combo] = temp&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local scoresMerged = {}&lt;br /&gt;
	local experienceMerged = {}&lt;br /&gt;
	for combo,_ in pairs(requestCombinations) do&lt;br /&gt;
		scoresMerged[combo] = metalscore + scores[&amp;#039;Forte&amp;#039;][combo]+scores[&amp;#039;Blade&amp;#039;][combo]+scores[&amp;#039;Tip&amp;#039;][combo]&lt;br /&gt;
		experienceMerged[combo] = p.experience(scoresMerged[combo])&lt;br /&gt;
	end&lt;br /&gt;
	local scoresAverage = 0&lt;br /&gt;
	local experienceAverage = 0&lt;br /&gt;
	for combo,value in pairs(requestCombinations) do&lt;br /&gt;
		scoresAverage = scoresAverage + value*scoresMerged[combo]/24&lt;br /&gt;
		experienceAverage = experienceAverage + value*experienceMerged[combo]/24&lt;br /&gt;
	end&lt;br /&gt;
	return {scoresAverage,experienceAverage}&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
	local bar1 = paramtest.default_to(args.metal1,&amp;#039;Bronze&amp;#039;)&lt;br /&gt;
	local bar2 = paramtest.default_to(args.metal2,&amp;#039;Iron&amp;#039;)&lt;br /&gt;
	local tier1 = barTier[bar1]&lt;br /&gt;
	local tier2 = barTier[bar2]&lt;br /&gt;
	local amount1 = paramtest.default_to(tonumber(args.metal1Amount), 14)&lt;br /&gt;
	local amount2 = 28 - amount1&lt;br /&gt;
	local metalwarning = &amp;#039;&amp;#039;&lt;br /&gt;
	--since the second type can be none, we make sure that the bars per sword is always 28&lt;br /&gt;
	if tier2==0 and amount2&amp;gt;0 then&lt;br /&gt;
		amount1 = 28&lt;br /&gt;
		amount2 = 0&lt;br /&gt;
		metalwarning = &amp;#039;&amp;lt;b&amp;gt;Warning:&amp;lt;/b&amp;gt; you used at least 1 bar with no type! Defaulted to 28 bars of the first type.&amp;lt;br&amp;gt;&amp;#039; &lt;br /&gt;
	end&lt;br /&gt;
	local metalscore = p.metalScore(tier1,tier2,amount1,amount2)&lt;br /&gt;
	-- get all the unlocked moulds as strings&lt;br /&gt;
	local mould1,mould2,mould3,mould4,mould5,mould6,mould7,mould8,mould9,mould10,mould11,mould12,mould13,mould14,mould15 = paramtest.defaults{&lt;br /&gt;
		{args.stiletto_F, false},&lt;br /&gt;
		{args.defender_F, false},&lt;br /&gt;
		{args.juggernaut_F, false},&lt;br /&gt;
		{args.chopper_F, false},&lt;br /&gt;
		{args.spiker_F, false},&lt;br /&gt;
		{args.flamberge_B, false},&lt;br /&gt;
		{args.serpent_B, false},&lt;br /&gt;
		{args.claymore_B, false},&lt;br /&gt;
		{args.fleur_B, false},&lt;br /&gt;
		{args.choppa_B, false},&lt;br /&gt;
		{args.corrupted_T, false},&lt;br /&gt;
		{args.defenders_T, false},&lt;br /&gt;
		{args.serrated_T, false},&lt;br /&gt;
		{args.needle_T, false},&lt;br /&gt;
		{args.point_T, false}&lt;br /&gt;
	}&lt;br /&gt;
	local unlockedMoulds = p.mouldsUnlocked(mould1,mould2,mould3,mould4,mould5,mould6,mould7,mould8,mould9,mould10,mould11,mould12,mould13,mould14,mould15)&lt;br /&gt;
	local currentLevel&lt;br /&gt;
	local currentxp&lt;br /&gt;
	--since we get level or xp, we calculate the other for various purposes&lt;br /&gt;
	local levelToggle = paramtest.default_to(args.currentToggle,&amp;#039;Level&amp;#039;)&lt;br /&gt;
	local current = paramtest.default_to(tonumber(args.current),1)&lt;br /&gt;
	if levelToggle == &amp;#039;Level&amp;#039; then&lt;br /&gt;
		currentLevel = current&lt;br /&gt;
		currentxp = experience.xp_at_level_unr({args = {current}})&lt;br /&gt;
	else&lt;br /&gt;
		currentxp = current&lt;br /&gt;
		currentLevel = experience.level_at_xp_unr({args = {current}})&lt;br /&gt;
	end&lt;br /&gt;
	--note that average xp is not a function of average quality, since xp is not linear over quality&lt;br /&gt;
	local averages = p.averageQualityExp(currentLevel,unlockedMoulds,metalscore)&lt;br /&gt;
	local quality = averages[1]&lt;br /&gt;
	local xp = averages[2]&lt;br /&gt;
	&lt;br /&gt;
	local goal = paramtest.default_to(tonumber(args.goal),99)&lt;br /&gt;
	local goalToggle = paramtest.default_to(args.goalToggle,&amp;#039;Level&amp;#039;)&lt;br /&gt;
	local swordsToMake&lt;br /&gt;
	local goalText = &amp;#039;&amp;#039;&lt;br /&gt;
	local goalWarning = &amp;#039;&amp;#039;&lt;br /&gt;
	local toGo&lt;br /&gt;
	--different cases for the various goals&lt;br /&gt;
	if goalToggle == &amp;#039;Level&amp;#039; then&lt;br /&gt;
		if goal == 0 or goal&amp;gt;126 then&lt;br /&gt;
			goalWarning = &amp;#039;&amp;lt;b&amp;gt;Warning:&amp;lt;/b&amp;gt; your current goal is not a level. Please enter a nonnegative level reachable within 200m xp or switch to xp.&amp;lt;br&amp;gt;&amp;#039;&lt;br /&gt;
			swordsToMake = 0&lt;br /&gt;
		elseif goal &amp;lt;= currentLevel then&lt;br /&gt;
			swordsToMake = 0&lt;br /&gt;
		else&lt;br /&gt;
			toGo = experience.xp_at_level_unr({args = {goal}}) - currentxp&lt;br /&gt;
			swordsToMake = math.ceil(toGo/xp)&lt;br /&gt;
		end&lt;br /&gt;
		goalText = &amp;#039;To get to level &amp;#039; .. tostring(goal) .. &amp;#039; [[Smithing]] from level &amp;#039; .. tonumber(currentLevel) .. &amp;#039; [[Smithing]] (&amp;#039; .. commas(currentxp) .. &amp;#039; experience) &amp;lt;b&amp;gt;&amp;#039; .. commas(swordsToMake) .. &amp;#039;&amp;lt;/b&amp;gt; swords will have to be made on average.\n&amp;#039;&lt;br /&gt;
	elseif goalToggle == &amp;#039;Experience&amp;#039; then&lt;br /&gt;
		if goal &amp;lt; currentxp then&lt;br /&gt;
			toGo = 0&lt;br /&gt;
		else&lt;br /&gt;
			toGo = goal - currentxp&lt;br /&gt;
		end&lt;br /&gt;
		swordsToMake = math.ceil(toGo/xp)&lt;br /&gt;
		goalText = &amp;#039;To get to &amp;#039; .. commas(goal) .. &amp;#039; experience (level &amp;#039; .. tostring(experience.level_at_xp({args = {goal}})) .. &amp;#039; [[Smithing]]) from &amp;#039; .. commas(currentxp) .. &amp;#039; (level &amp;#039; .. tostring(currentLevel) .. &amp;#039; [[Smithing]]) &amp;lt;b&amp;gt;&amp;#039; .. commas(swordsToMake) .. &amp;#039;&amp;lt;/b&amp;gt; swords will have to be made on average.\n&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		swordsToMake = math.ceil(goal/quality)&lt;br /&gt;
		toGo = math.floor(swordsToMake*xp)&lt;br /&gt;
		-- xp can&amp;#039;t go above 200m&lt;br /&gt;
		if toGo+currentxp &amp;gt; 200000000 then&lt;br /&gt;
			toGo = 200000000-currentxp&lt;br /&gt;
		end&lt;br /&gt;
		local newxp = toGo+currentxp&lt;br /&gt;
		goalText = &amp;#039;To get &amp;#039; .. commas(goal) .. &amp;#039; reputation &amp;lt;b&amp;gt;&amp;#039; .. commas(swordsToMake) .. &amp;#039;&amp;lt;/b&amp;gt; swords will have to be made on average. This grants &amp;#039; .. commas(toGo) .. &amp;#039; experience putting you at &amp;#039; .. commas(newxp) .. &amp;#039; experience (level &amp;#039; .. tostring(experience.level_at_xp({args = {newxp}})) .. &amp;#039; [[Smithing]]).\n&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	goalText = goalText .. &amp;#039;* Each sword is of average quality &amp;#039; .. tonumber(quality) .. &amp;#039;, grants on average &amp;#039; .. commas(math.floor(xp)) .. &amp;#039; [[Smithing]] experience, awards on average &amp;#039;.. coins(math.floor(xp)*2) ..&amp;#039; and consists of &amp;#039; .. tostring(p.difficulty(metalscore)) .. &amp;#039; sections.\n&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	local bar1bar = bar1 .. &amp;#039; bar&amp;#039;&lt;br /&gt;
	local bar2bar = bar2 .. &amp;#039; bar&amp;#039;&lt;br /&gt;
	local bar1price = gePrices[bar1bar]&lt;br /&gt;
	local bar1toggle = p.strtobool(paramtest.default_to(args.metal1PriceToggle,&amp;#039;false&amp;#039;))&lt;br /&gt;
	if bar1toggle then&lt;br /&gt;
		bar1price = paramtest.default_to(args.metal1Price,gePrices[bar1bar])&lt;br /&gt;
	end&lt;br /&gt;
	local bar2price = 0&lt;br /&gt;
	local bar2toggle = p.strtobool(paramtest.default_to(args.metal2PriceToggle,&amp;#039;false&amp;#039;))&lt;br /&gt;
	local barText = &amp;#039;&amp;#039;&lt;br /&gt;
	local costText = &amp;#039;* &amp;#039; .. commas(swordsToMake) .. &amp;#039; swords will require &amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	local itemPrice = 0&lt;br /&gt;
	local itemName = &amp;#039;&amp;#039;&lt;br /&gt;
	local totalItemPrice = 0&lt;br /&gt;
	local bestItem1price = 0&lt;br /&gt;
	local bestItem2price = 0&lt;br /&gt;
	&lt;br /&gt;
	if amount1 &amp;gt; 0 then&lt;br /&gt;
		bestItem1price = math.huge&lt;br /&gt;
		barText = barText .. &amp;#039;* &amp;#039; .. tostring(amount1) .. &amp;#039; &amp;#039; .. p.lazyplink(bar1bar) .. &amp;#039; at &amp;#039; .. coins(bar1price) .. &amp;#039; each will cost &amp;#039; .. coins(amount1*bar1price) .. &amp;#039;.\n&amp;#039;&lt;br /&gt;
		for itemType,itemWorth in pairs(itemBarWorth) do&lt;br /&gt;
			itemName = bar1 .. &amp;#039; &amp;#039; .. itemType&lt;br /&gt;
			if (bar1 == &amp;#039;Runite&amp;#039;) then&lt;br /&gt;
				itemName = &amp;#039;Rune &amp;#039; .. itemType&lt;br /&gt;
			end&lt;br /&gt;
			if (bar1 == &amp;#039;Adamantite&amp;#039;) then&lt;br /&gt;
				itemName = &amp;#039;Adamant &amp;#039; .. itemType&lt;br /&gt;
			end&lt;br /&gt;
			itemPrice = gePrices[itemName] &lt;br /&gt;
			if (itemPrice) then&lt;br /&gt;
				totalItemPrice = itemPrice*(amount1 / itemWorth)&lt;br /&gt;
				barText = barText .. &amp;#039;\n:* or &amp;#039; .. tostring(amount1 / itemWorth) .. &amp;#039; &amp;#039; .. p.lazyplink(itemName) .. &amp;#039; at &amp;#039; .. coins(itemPrice) .. &amp;#039; each for &amp;#039; .. coins(totalItemPrice) .. &amp;#039;\n&amp;#039;&lt;br /&gt;
				if (totalItemPrice &amp;lt; bestItem1price) then&lt;br /&gt;
					bestItem1price = totalItemPrice&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		costText = costText .. commas(amount1*swordsToMake) .. &amp;#039; &amp;#039; .. p.lazyplink(bar1bar) .. &amp;#039;s&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if amount1 &amp;gt; 0 and amount2 &amp;gt; 0 then&lt;br /&gt;
		costText = costText .. &amp;#039; and &amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if amount2 &amp;gt; 0 then&lt;br /&gt;
		bestItem2price = math.huge&lt;br /&gt;
		bar2price = gePrices[bar2bar]&lt;br /&gt;
		if bar2toggle then&lt;br /&gt;
			bar2price = paramtest.default_to(args.metal2Price,gePrices[bar2bar])&lt;br /&gt;
		end&lt;br /&gt;
		barText = barText .. &amp;#039;* &amp;#039; .. tostring(amount2) .. &amp;#039; &amp;#039; .. p.lazyplink(bar2bar) .. &amp;#039; at &amp;#039; .. coins(bar2price) .. &amp;#039; each will cost &amp;#039; .. coins(amount2*bar2price) .. &amp;#039;.\n&amp;#039;&lt;br /&gt;
		for itemType,itemWorth in pairs(itemBarWorth) do&lt;br /&gt;
			itemName = bar2 .. &amp;#039; &amp;#039; .. itemType&lt;br /&gt;
			if (bar2 == &amp;#039;Runite&amp;#039;) then&lt;br /&gt;
				itemName = &amp;#039;Rune &amp;#039; .. itemType&lt;br /&gt;
			end&lt;br /&gt;
			if (bar2 == &amp;#039;Adamantite&amp;#039;) then&lt;br /&gt;
				itemName = &amp;#039;Adamant &amp;#039; .. itemType&lt;br /&gt;
			end&lt;br /&gt;
			itemPrice = gePrices[itemName] &lt;br /&gt;
			if (itemPrice) then&lt;br /&gt;
				totalItemPrice = itemPrice*(amount2 / itemWorth)&lt;br /&gt;
				barText = barText .. &amp;#039;\n:* or &amp;#039; .. tostring(amount2 / itemWorth) .. &amp;#039; &amp;#039; .. p.lazyplink(itemName) .. &amp;#039; at &amp;#039; .. coins(itemPrice) .. &amp;#039; each for &amp;#039; .. coins(totalItemPrice) .. &amp;#039;\n&amp;#039;&lt;br /&gt;
				if (totalItemPrice &amp;lt; bestItem2price) then&lt;br /&gt;
					bestItem2price = totalItemPrice&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		costText = costText .. commas(amount2*swordsToMake) .. &amp;#039; &amp;#039; .. p.lazyplink(bar2bar) .. &amp;#039;s&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local swordCost = amount1*bar1price+amount2*bar2price&lt;br /&gt;
	local finalCost = swordCost*swordsToMake&lt;br /&gt;
&lt;br /&gt;
	local swordCostWithItems = bestItem1price+bestItem2price&lt;br /&gt;
	local finalCostWithItems = swordCostWithItems*swordsToMake&lt;br /&gt;
&lt;br /&gt;
	barText = barText .. &amp;#039;\n* Each sword will cost a total of &amp;#039; .. coins(swordCost) .. &amp;#039; using bars or &amp;#039; .. coins(swordCostWithItems) .. &amp;#039; using items.\n&amp;#039;&lt;br /&gt;
	costText = costText .. &amp;#039;, at a total cost of &amp;#039; .. coins(finalCost) .. &amp;#039; using bars, or at a total cost of &amp;#039; .. coins(finalCostWithItems) .. &amp;#039; using items.\n&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	local income = swordsToMake*xp*2&lt;br /&gt;
	local profit = income-finalCost&lt;br /&gt;
	local profitWithItems = income-finalCostWithItems&lt;br /&gt;
	&lt;br /&gt;
	local incomeText = &amp;#039;* &amp;#039; .. coins(income) .. &amp;#039; will be earned using bars for a total profit of &amp;#039; .. coins(profit) .. &amp;#039;, or for a total profit of &amp;#039; .. coins(profitWithItems) .. &amp;#039; using items.\n&amp;#039;&lt;br /&gt;
&lt;br /&gt;
	local repTotal = math.floor(quality*swordsToMake)&lt;br /&gt;
	local grogNumber = math.floor(repTotal/300)&lt;br /&gt;
	local grogValue = gePrices[&amp;quot;Kovac&amp;#039;s grog&amp;quot;]*grogNumber&lt;br /&gt;
	&lt;br /&gt;
	local repText = &amp;#039;* A total of &amp;#039; .. commas(repTotal) .. &amp;quot; Reputation will be earned. If used to buy [[Kovac&amp;#039;s grog]] an additional &amp;quot; .. coins(grogValue) .. &amp;#039; will be earned at current GE prices.&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	local levelwarning = &amp;#039;&amp;#039;&lt;br /&gt;
	if currentLevel &amp;lt; 15 then&lt;br /&gt;
		levelwarning = &amp;#039;&amp;lt;b&amp;gt;Warning:&amp;lt;/b&amp;gt; you need at least level 15 smithing to participate in the minigame. This might have unintended consequences for the calculations.&amp;lt;br&amp;gt;&amp;#039;&lt;br /&gt;
	elseif currentLevel &amp;lt; (tier1-1)*15+(tier1&amp;gt;=4 and 5 or 0)+(tier1&amp;gt;=5 and 5 or 0) or currentLevel &amp;lt; (tier2-1)*15+(tier2 &amp;gt;= 4 and 5 or 0)+(tier2 &amp;gt;= 5 and 5 or 0) then&lt;br /&gt;
		levelwarning = &amp;#039;&amp;lt;b&amp;gt;Warning:&amp;lt;/b&amp;gt; one of the metals selected is above your current smithing level.&amp;lt;br&amp;gt;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return metalwarning .. goalWarning .. levelwarning .. goalText .. barText ..costText .. incomeText .. repText&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	return p._main(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>