FANDOM


-- <nowiki>
local p = {}
local coins = require('Module:Coins')
 
local runes = {
	"Air", "Water", "Earth", "Fire", "Dust", "Lava", "Mist", "Mud", "Smoke", "Steam", "Mind", "Body", "Cosmic", "Chaos", "Nature", "Law", "Death", "Astral", "Blood", "Soul"
}
-- Sets up the base quantities needed for the machine 
local rune_quantities = {
	1000, 1000, 1000, 1000, 500, 500, 500, 300, 500, 500, 2000, 2000, 400, 500, 350, 300, 400, 300, 350, 300
}
--creates a table of prices based on the runes arrary
function get_prices(frame)
	local prices = {}
 
	for _, r in pairs(runes) do
		table.insert(prices, tonumber(frame:expandTemplate{ title = 'GEP', args = { r .. " rune" } }))
	end
 
	return prices
end
--returns the base quantity for the runes if a rune is selected 
function p.quantity(frame)
        local attempts = tonumber(frame.args[1])
	local index = tonumber(frame.args[2])
        local runesneeded = 0
	if index == 0 or index > #rune_quantities then
		return "No rune selected"
	else
                runesneeded = rune_quantities[index] + math.floor(rune_quantities[index] * attempts * .005)
		return runesneeded
	end
end
-- this creates the table following the calculator. 
function p.table(frame)
	local prices = get_prices(frame)
 
	local t = mw.html.create('table')
	          :addClass('wikitable sortable')
	          :tag('tr')
	              :tag('th'):wikitext('Rune'):done()
	              :tag('th'):wikitext('Base quantity'):done()
	              :tag('th'):wikitext('Amount added Per Try'):done()
	              :tag('th'):wikitext('Price per Rune'):done()
                      :tag('th'):wikitext('Price per Try'):done()
                      :tag('th'):wikitext('Total Base Price'):done()
	          :done()
 
	for i, r in pairs(runes) do
		t:tag('tr')
			:tag('td'):wikitext('[[File:' .. r .. ' rune.png]] [[' .. r .. ' rune]]'):done()
			:tag('td'):wikitext(rune_quantities[i]):done()
                        :tag('td'):wikitext(rune_quantities[i]*.005):done()
			:tag('td'):wikitext(coins._amount(prices[i])):done()
			:tag('td'):wikitext(coins._amount(rune_quantities[i] * prices[i] * .005)):done()
                        :tag('td'):wikitext(coins._amount(rune_quantities[i] * prices[i])):done()
	end
 
	return t
end
 
function p.main(frame)
	local prices = get_prices(frame)
 
	local r1 = tonumber(frame.args[1]) or 0
	local r2 = tonumber(frame.args[2]) or 0
	local r3 = tonumber(frame.args[3]) or 0
	local totalviswax = tonumber(frame.args[4]) or 0
        local attempts = tonumber(frame.args[5]) or 0
 
--Set up logic to determine whether to prompt for more rune choices or give profit determination
 
	local r1known = 0
	local r2known = 0
	local r3known = 0
 
        if r1 > 0 then
                r1known = 1
        end
 
        if r2 > 0 then
                r2known = 1
        end
 
        if r3 > 0 then
                r3known = 1
        end
 
	local total_knowns = r1known + r2known + r3known
 
	local costofrunes = 0
 
--Finds total cost of runes
 
	if total_knowns == 3 then
	        costofrunes = rune_quantities[r1] * prices[r1] +  prices[r1] * math.floor(rune_quantities[r1] * attempts * .005) + rune_quantities[r2] * prices[r2] + prices[r2] * math.floor(rune_quantities[r2]  * attempts * .005) + rune_quantities[r3] * prices[r3] + prices[r3] * math.floor(rune_quantities[r1] *  attempts * .005)
	end
 
	local vis_wax_price = tonumber(frame:expandTemplate{ title = 'GEP', args = { "Vis wax" } })
 
	local profit = vis_wax_price * totalviswax - costofrunes
 
        if total_knowns < 3 then
                return "Please Select a rune for each Slot"
        else 
                return "The cost of runes for " .. totalviswax .. " out of 100 vis wax, at " .. attempts .. " attempt(s) is " .. coins._amount(costofrunes) .. "." .. "<br>Expected profit: " .. coins._amount(profit)
        end
 
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.