Module:Skills/Archaeology: Difference between revisions

attempting to add a display of the average value of an action similar to template:chestDrops
(Fixed a thing related to dig sites)
(attempting to add a display of the average value of an action similar to template:chestDrops)
Line 46: Line 46:
local lootTable = Shared.shallowClone(digSite.artefacts[string.lower(size)])
local lootTable = Shared.shallowClone(digSite.artefacts[string.lower(size)])
local lootValue = 0
local totalWt = 0
local totalWt = 0
for i, row in ipairs(lootTable) do
for i, row in ipairs(lootTable) do
Line 103: Line 104:
local fmt = (dropChance < 0.10 and '%.2g') or '%.2f'
local fmt = (dropChance < 0.10 and '%.2g') or '%.2f'
table.insert(result, 'style="text-align:right"|'..string.format(fmt, dropChance * 100)..'%')
table.insert(result, 'style="text-align:right"|'..string.format(fmt, dropChance * 100)..'%')
lootValue = lootValue + (dropChance * 0.01 * thisItem.sellsFor * ((row.minQuantity + row.maxQuantity)/ 2))
end
end
table.insert(result, '\r\n|}')
table.insert(result, '\r\n|}')
table.insert(result, '\r\nThe average value of one action is '..Icons.GP(Shared.round(lootValue, 2, 0))..'.')
return table.concat(result, '')
return table.concat(result, '')