Module:Calculator/ItemEconomy: Difference between revisions

m
Add multiplier from Module:ItemEconomy
m (Somehow things turn into a string magically....)
m (Add multiplier from Module:ItemEconomy)
Line 49: Line 49:
end
end


local function calculateFactor(a, b)
local function createTable(target, calcAmount, useRoW, ecoType, multiplier)
    local highest = math.max(a, b)
    local lowest = math.min(a, b)
 
    if lowest == 0 then
    lowest = 1
    end
 
    local factor = highest / lowest
    return string.format("x%.2f", factor)
end
 
local function createTable(userAmount, calcAmount, useRoW, ecoType, multiplier)
local RoWYN = useRoW and "Yes" or "No"
local RoWYN = useRoW and "Yes" or "No"
Line 68: Line 56:
if ecoType == ECOIN then
if ecoType == ECOIN then
addTableRow(tbl, "Desired Output", number.formatnum(userAmount))
addTableRow(tbl, "Desired Output", number.formatnum(target))
addTableRow(tbl, "Estimated Input", number.formatnum(calcAmount))
addTableRow(tbl, "Estimated Input", number.formatnum(calcAmount))
else
else
addTableRow(tbl, "Starting Items", number.formatnum(userAmount))
addTableRow(tbl, "Starting Items", number.formatnum(target))
addTableRow(tbl, "Estimated Output", number.formatnum(calcAmount))
addTableRow(tbl, "Estimated Output", number.formatnum(calcAmount))
end
end
addTableRow(tbl, "Economy Factor", calculateFactor(userAmount, calcAmount))
addTableRow(tbl, "Economy Factor", calculateFactor(target, calcAmount))
addTableRow(tbl, "[[Ring of Wealth]] benefits", RoWYN)
addTableRow(tbl, "[[Ring of Wealth]] benefits", RoWYN)
Line 111: Line 99:
end
end


local tbl = createTable(target, result, row, economyType)
local multiplier = eco.estimatedOutputMultiplieritemEconomy
local tbl = createTable(target, result, row, economyType, multiplier)
          
          
     return tostring(tbl)
     return tostring(tbl)
2,875

edits