Firetron's InputAmountSpread

stable
By Firetron in Miscellaneous Published December 2020 👁 1,209 views 💬 0 comments

Description

Creates a group of inputs for Firetron's GetAmountSpread. Custom Command Dependencies: None Test code:
if not Load('done', false) then

  local p = {listDynamic = CC_InputAmountSpread('Amount Spread')}

  local spreadAmounts = CC_GetAmountSpread(p)

  for i = 1, #spreadAmounts do

    Log('Spread Amount: '..spreadAmounts[i])

  end

  Save('done', true)

end
HaasScript
--  ============================================================================
--    Firetron's InputAmountSpread
--
--    Creates a group of inputs for Firetron's GetAmountSpread.
--
--    Custom Command Dependencies:
--    None
--
--    Discord: @FiretronP75
--  ============================================================================

--  ========================================================
--    Variables
--  ========================================================

--  ------------------------------------
--    Definition
--  ------------------------------------

local defaultValue
local description
local index
local inputSuggestions
local isRequired
local label
local name
local options
local output
local outputSuggestions
local tooltip
local type

--  ------------------------------------
--    Enumeration
--  ------------------------------------

local SpreadType = {
  exp   = 'exp',
  fib   = 'fib',
  mult  = 'mult',
  per   = 'per',
  total = 'total',
}

--  ------------------------------------
--    Parameter
--  ------------------------------------

local pCount
local pGroup
local pOffset
local pSpreadFactor
local pSpreadType
local pTotal

--  ========================================================
--    Command Definition
--  ========================================================

name        = 'InputAmountSpread'
description = 'Creates a group of inputs for Firetron\'s GetAmountSpread.'
DefineCommand(name, description)

--  ========================================================
--    Parameter Definition
--  ========================================================

type             = StringType
name             = 'group'
description      = 'The group of the input fields.'
isRequired       = false
defaultValue     = 'Amount Spread'
inputSuggestions = 'Text'
pGroup           = DefineParameter(type, name, description, isRequired, defaultValue, inputSuggestions)

--  ========================================================
--    Input Definitions
--  ========================================================

label        = 'Count'
defaultValue = 1
tooltip      = 'How many amounts are in the spread.'
pCount       = Input(label, defaultValue, tooltip, pGroup)

label         = 'Offset'
defaultValue  = 0
tooltip       = 'How many amounts to skip over at the start of the spread.'
pOffset       = Input(label, defaultValue, tooltip, pGroup)

label         = 'Spread Factor'
defaultValue  = 1
tooltip       = 'How much to order. May be total amount or amount per order or fibonacci amount per order or multiplied amount per order or exponential ammount per order.'
pSpreadFactor = Input(label, defaultValue, tooltip, pGroup)

label        = 'Spread Type'
defaultValue = SpreadType.per
options      = SpreadType
tooltip      = '"total" if you specified a total amount, "per" if you specified an amount per order, "fib" if you specified a fibonacci amount per order, "mult" if you specified an amount to be multiplied by the order index, "exp" if you specified an amount to be exponentially multiplied by the order index.'
pSpreadType  = InputOptions(label, defaultValue, options, tooltip, pGroup)

label        = 'Total'
defaultValue = 0
tooltip      = 'Total amount to divide up. Set to 0 to disable. If enabled, each value in the amount spread will be converted to a rationed amount of the total. When the spreadType is "total" this is redundant.'
pTotal       = Input(label, defaultValue, tooltip, pGroup)

--  ========================================================
--    Output Definitions
--  ========================================================

output = {
  count        = pCount,
  offset       = pOffset,
  spreadFactor = pSpreadFactor,
  spreadType   = pSpreadType,
  total        = pTotal,
}

type              = ListDynamicType
description       = 'ListDynamic with named elements.'
outputSuggestions = 'CC_GetAmountSpread'
DefineOutput(type, output, description, outputSuggestions)

index       = 1
type        = NumberType
name        = 'count'
description = 'How many amounts are in the spread.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

index       = 2
type        = NumberType
name        = 'offset'
description = 'How many amounts to skip over at the start of the spread.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

index       = 3
type        = NumberType
name        = 'spreadFactor'
description = 'How much to order. May be total amount or amount per order or fibonacci amount per order or multiplied amount per order or exponential ammount per order.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

index       = 4
type        = StringType
name        = 'spreadType'
description = '"total" if you specified a total amount, "per" if you specified an amount per order, "fib" if you specified a fibonacci amount per order, "mult" if you specified an amount to be multiplied by the order index, "exp" if you specified an amount to be exponentially multiplied by the order index.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

index       = 5
type        = NumberType
name        = 'total'
description = 'Total amount to divide up. Set to 0 to disable. If enabled, each value in the amount spread will be converted to a rationed amount of the total. When the spreadType is "total" this is redundant.'
DefineOutputIndex(index, type, name, description, outputSuggestions)

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!