Firetron's InputSpread

stable
By Firetron in Miscellaneous Published February 2021 👁 1,191 views 💬 0 comments

Description

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

  local p = {omni = CC_InputSpread('Spread')}

  local spread = CC_GetSpread(p)

  for i = 1, #spread do

    Log('Spread Value: '..spread[i])

  end

  Save('done', true)

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

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

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

local dDefault
local dDescription
local dIndex
local dLabel
local dName
local dOptions
local dOutput
local dRequired
local dSuggestions
local dTooltip
local dType

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

local Direction = {
  above = 'above',
  below = 'below',
}

local Type = {
  doub  = 'doub',
  exp   = 'exp',
  fib   = 'fib',
  fixed = 'fixed',
  mult  = 'mult',
}

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

local pBase
local pCount
local pDirection
local pFactor
local pGroup
local pIsPercent
local pOffset
local pType

--  ----------------

local pIsBaseShown
local pIsCountShown
local pIsDirectionShown
local pIsFactorShown
local pIsPercentShown
local pIsOffsetShown
local pIsTypeShown

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

dName        = 'InputSpread'
dDescription = 'Creates a group of inputs for Firetron\'s GetSpread.'
DefineCommand(dName, dDescription)

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

dType        = StringType
dName        = 'group'
dDescription = 'The group of the input fields.'
dRequired    = false
dDefault     = 'Spread'
dSuggestions = 'Text'
pGroup       = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

dType        = BooleanType
dName        = 'pIsBaseShown'
dDescription = 'Shows the input.'
dRequired    = false
dDefault     = true
dSuggestions = 'Boolean'
pIsBaseShown = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

dType         = BooleanType
dName         = 'pIsCountShown'
dDescription  = 'Shows the input.'
dRequired     = false
dDefault      = true
dSuggestions  = 'Boolean'
pIsCountShown = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

dType             = BooleanType
dName             = 'pIsDirectionShown'
dDescription      = 'Shows the input.'
dRequired         = false
dDefault          = true
dSuggestions      = 'Boolean'
pIsDirectionShown = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

dType          = BooleanType
dName          = 'pIsFactorShown'
dDescription   = 'Shows the input.'
dRequired      = false
dDefault       = true
dSuggestions   = 'Boolean'
pIsFactorShown = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

dType           = BooleanType
dName           = 'pIsPercentShown'
dDescription    = 'Shows the input.'
dRequired       = false
dDefault        = true
dSuggestions    = 'Boolean'
pIsPercentShown = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

dType          = BooleanType
dName          = 'pIsOffsetShown'
dDescription   = 'Shows the input.'
dRequired      = false
dDefault       = true
dSuggestions   = 'Boolean'
pIsOffsetShown = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

dType        = BooleanType
dName        = 'pIsTypeShown'
dDescription = 'Shows the input.'
dRequired    = false
dDefault     = true
dSuggestions = 'Boolean'
pIsTypeShown = DefineParameter(dType, dName, dDescription, dRequired, dDefault, dSuggestions)

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

if pIsBaseShown then

  dLabel   = 'Base'
  dDefault = 100
  dTooltip = 'Base value to spread out from. This value will not be included. The first value will be placed at the factor away from this value.'
  pBase    = Input(dLabel, dDefault, dTooltip, pGroup)

end

if pIsCountShown then

  dLabel   = 'Count'
  dDefault = 5
  dTooltip = 'How many values are in the spread.'
  pCount   = Input(dLabel, dDefault, dTooltip, pGroup)

end

if pIsDirectionShown then

  dLabel     = 'Direction'
  dDefault   = Direction.below
  dOptions   = Direction
  dTooltip   = '"above" will spread values above the base value, "below" will spread values below the base value.'
  pDirection = InputOptions(dLabel, dDefault, dOptions, dTooltip, pGroup)

end

if pIsFactorShown then

  dLabel   = 'Factor'
  dDefault = 2
  dTooltip = 'How far to space values apart. May be a doubled, exponential, fibonacci, fixed, or multiplied value.'
  pFactor  = Input(dLabel, dDefault, dTooltip, pGroup)

end

if pIsPercentShown then

  dLabel     = 'Is Percent'
  dDefault   = false
  dTooltip   = 'Set to true to treat the factor as a percent.'
  pIsPercent = Input(dLabel, dDefault, dTooltip, pGroup)

end

if pIsOffsetShown then

  dLabel   = 'Offset'
  dDefault = 0
  dTooltip = 'How many values to skip over at the start of the spread. Does not effect the count.'
  pOffset  = Input(dLabel, dDefault, dTooltip, pGroup)

end

if pIsTypeShown then

  dLabel   = 'Type'
  dDefault = Type.fixed
  dOptions = Type
  dTooltip = '"doub" for doubled factor, "exp" for exponential factor, "fib" for fibonacci factor, "fixed" for fixed factor, "mult" for multiplied factor.'
  pType    = InputOptions(dLabel, dDefault, dOptions, dTooltip, pGroup)

end

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

dOutput = {
  base      = pBase,
  count     = pCount,
  direction = pDirection,
  factor    = pFactor,
  isPercent = pIsPercent,
  offset    = pOffset,
  type      = pType,
}

dType        = ListDynamicType
dDescription = 'ListDynamic with named elements.'
dSuggestions = 'CC_GetSpread'
DefineOutput(dType, dOutput, dDescription, dSuggestions)

dIndex       = 1
dType        = NumberType
dName        = 'base'
dDescription = 'Base value to spread out from. This value will not be included. The first value will be placed at the factor away from this value.'
DefineOutputIndex(dIndex, dType, dName, dDescription, dSuggestions)

dIndex       = 2
dType        = NumberType
dName        = 'count'
dDescription = 'How many values are in the spread.'
DefineOutputIndex(dIndex, dType, dName, dDescription, dSuggestions)

dIndex       = 3
dType        = StringType
dName        = 'direction'
dDescription = '"above" will spread values above the base value, "below" will spread values below the base value.'
DefineOutputIndex(dIndex, dType, dName, dDescription, dSuggestions)

dIndex       = 4
dType        = NumberType
dName        = 'factor'
dDescription = 'How far to space values apart. May be a doubled, exponential, fibonacci, fixed, or multiplied value.'
DefineOutputIndex(dIndex, dType, dName, dDescription, dSuggestions)

dIndex       = 5
dType        = BooleanType
dName        = 'isPercent'
dDescription = 'Set to true to treat the factor as a percent.'
DefineOutputIndex(dIndex, dType, dName, dDescription, dSuggestions)

dIndex       = 6
dType        = NumberType
dName        = 'offset'
dDescription = 'How many values to skip over at the start of the spread. Does not effect the count.'
DefineOutputIndex(dIndex, dType, dName, dDescription, dSuggestions)

dIndex       = 7
dType        = StringType
dName        = 'type'
dDescription = '"doub" for doubled factor, "exp" for exponential factor, "fib" for fibonacci factor, "fixed" for fixed factor, "mult" for multiplied factor.'
DefineOutputIndex(dIndex, dType, dName, dDescription, dSuggestions)

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!