2,875
edits
m (Replace Shared module with Number module) |
(Implement Economy module changes) |
||
Line 24: | Line 24: | ||
-- Returns the estimated output items and TRUE/FALSE if the Ring of Wealth has a benefit. | -- Returns the estimated output items and TRUE/FALSE if the Ring of Wealth has a benefit. | ||
-- | -- | ||
local function calculateOutput( | local function calculateOutput(target, itemEconomy) | ||
local estimatedOutput = eco.estimatedOutput( | local estimatedOutput = eco.estimatedOutput(target, itemEconomy) | ||
local | local useRoW = eco.ringOfWealthHasEffect(itemEconomy) | ||
return math.floor(estimatedOutput), | return math.floor(estimatedOutput), useRoW | ||
end | end | ||
Line 34: | Line 34: | ||
-- Returns the estimated input items and TRUE/FALSE if the Ring of Wealth has a benefit. | -- Returns the estimated input items and TRUE/FALSE if the Ring of Wealth has a benefit. | ||
-- | -- | ||
local function calculateInput( | local function calculateInput(target, itemEconomy) | ||
local estimatedInput = eco.estimatedInput( | local estimatedInput = eco.estimatedInput(target, itemEconomy) | ||
local useRoW = eco.ringOfWealthHasEffect(itemEconomy) | |||
local | |||
return math.ceil(estimatedInput), | return math.ceil(estimatedInput), useRoW | ||
end | end | ||
Line 64: | Line 62: | ||
end | end | ||
local function createTable(userAmount, calcAmount, useRoW, ecoType) | local function createTable(userAmount, calcAmount, useRoW, ecoType, multiplier) | ||
local RoWYN = useRoW and "Yes" or "No" | local RoWYN = useRoW and "Yes" or "No" | ||
Line 90: | Line 88: | ||
function p._main(args) | function p._main(args) | ||
local | local target = args.targetAmount | ||
local economyType = parseEconomy(args.economyType) | local economyType = parseEconomy(args.economyType) | ||
local | -- Create and fill ItemEconomy object. | ||
local itemEconomy = eco.ItemEconomy:new() | |||
itemEconomy.inputsPerAction = number.toNumberOrDefault(args.inputsPerAction, 1) | |||
itemEconomy.outputsPerAction = number.toNumberOrDefault(args.outputsPerAction, 1) | |||
itemEconomy.preservationChance = number.toNumberOrDefault(args.preservationChance, 0) | |||
itemEconomy.duplicationChance = number.toNumberOrDefault(args.duplicationChance, 0) | |||
itemEconomy.extraItemChance = number.toNumberOrDefault(args.extraItemChance, 0) | |||
itemEconomy.extraItemAmount = number.toNumberOrDefault(args.extraItemAmount, 0) | |||
itemEconomy.flatExtraItems = number.toNumberOrDefault(args.flatExtraItems, 0) | |||
itemEconomy.extraBaseItemChance = number.toNumberOrDefault(args.extraBaseItemChance, 0) | |||
itemEconomy.extraBaseItems = number.toNumberOrDefault(args.extraBaseItems, 0) | |||
local result = 0 | local result = 0 | ||
local row = false | local row = false | ||
if economyType == ECOOUT then | if economyType == ECOOUT then | ||
result, row = calculateOutput( | result, row = calculateOutput(target, itemEconomy) | ||
else | else | ||
result, row = calculateInput( | result, row = calculateInput(target, itemEconomy) | ||
end | end | ||
local tbl = createTable( | local tbl = createTable(target, result, row, economyType) | ||
return tostring(tbl) | return tostring(tbl) |
edits