local function fnum(x) -- Formats numbers in the default language, means it will add comma separators if type(x) == "number" then return lang:formatNum(x) end return nil end local function getArtefactData(artefactName) return data.artefacts[string.gsub(tostring(artefactName), ' ?%(damaged%)', '')] end local function artefactXP(artefactName) --returns restoration xp of an artefact from a specific hotspot local artData = getArtefactData(artefactName) if artData ~= nil then return artData.xp end end local function FindProfits(h,hotspot) -- returns the average value of all materials gained from a hotspot. local numMaterialsTable = {} local totalProfits = 0 local numMaterials = 0 for i,v in ipairs (hotspot.materials) do local chance = v[2] local materialsGained = h * (chance/10000) numMaterialsTable[v[1]] = materialsGained numMaterials = numMaterials + 1 end for i,v in pairs(numMaterialsTable) do totalProfits = totalProfits + (gemw._price(i)) end totalProfits = totalProfits / numMaterials -- Gets the average profit from a hotspot in an hour return totalProfits end local function GetNumArtefactMaterials(havg,r) -- Returns chance per hit to gain each material in a specific hotspot. local numMaterialsTable = {} for i,v in pairs (r.materials) do local chance = v[2] numMaterialsTable[v[1]] = chance/10000 end return numMaterialsTable -- Return dictionary with materials name as index end local function SoilPrice(havg,r) --returns total profit of all soil collected, checks soil type from specific hotspot if r.soil then soilNum = havg * 0.14 return gemw._price(r.soil) * soilNum else return 0 end end local function TotalRestoringPrice(havg, r, precision) --returns avg price of restoring one artefact from a specific hotspot local numArtefacts = 0 local artefactsToRestore = r.artefacts local costTable = {} for l, m in ipairs(artefactsToRestore) do local artData = getArtefactData(m[1]) if artData ~= nil then for j, k in pairs (artData.mats) do if not string.match(j,"damaged") and not string.match(j,"Phoenix") and not string.match(j,"mushroom ink") then costTable[#costTable + 1] = k * gemw._price(j) end end end end for i,v in ipairs (r.artefacts) do numArtefacts = numArtefacts + 1 end local sumSingularPrice = 0 for i=1, #costTable do sumSingularPrice = sumSingularPrice + costTable[i] end avgRestore = sumSingularPrice / numArtefacts return avgRestore end local function GetChronoteValue(hotspotName) -- gets chronote value of artefacts from a specific hotspot local artefactName = data.hotspots[hotspotName].artefacts[1][1] local artData = getArtefactData(artefactName) if artData ~= nil then return artData.chronotes end end local function getMattockName(mattockTable, mattockLevel, mattockAugmentable) -- Returns mattock name based on parameters given for k,v in pairs(t) do if v.Level == mattockLevel and v.Augmentable == mattockAugmentable then return k end end return nil end function remainingExp(curLvl, curXP, tgtLvl, tgtXP) -- Gets remaining xp to a certain lvl and xp goal. local remaining if curLvl > 120 and curXP == 1 then curXP = curLvl elseif curXP <= 120 and curLvl == 1 then curLvl = curXP curXP = 1 end if tgtLvl > 120 and tgtXP == 0 then tgtXP = tgtLvl elseif tgtXP <= 120 and tgtLvl == 0 then tgtLvl = tgtXP tgtXP = 0 end if curXP == 1 then curXP = xp({args = {curLvl, elite = 0}}) else curLvl = level({args = {curXP, elite = 0}}) end if tgtLvl > 0 or tgtXP > 0 then if tgtXP == 0 then tgtXP = xp({args = {tgtLvl, elite = 0}}) else tgtLvl = level({args = {tgtXP, elite = 0}}) end end -- Prevent negative values local remaining = math.ceil(tgtXP - curXP) if remaining < 0 then remaining = 0 end return curLvl, curXP, tgtLvl, tgtXP, remaining end