[CMD]GetColor

stable
By Strooth in Miscellaneous Published March 2021 👁 1,122 views 💬 0 comments

Description

A custom command for setting color in scripts which use multiple positions and is used in my mod of plot average enter price Default color, Name for input section, Color you want to use in script or select from input CC_GetColor("Teal", "SomeName", "Red")
HaasScript
DefineIntervalOptimization(CurrentInterval())
local allcolors = { none = 'none', c_Aqua = 'Aqua', c_Black = 'Black', c_Blue = 'Blue', c_Cyan = 'Cyan', c_DarkGray = 'DarkGray', c_DarkGreen = 'DarkGreen', c_Fuchsia = 'Fuchsia', c_Gold = 'Gold', c_Gray = 'Gray', c_Green = 'Green', c_Maroon = 'Maroon', c_Olive = 'Olive', c_Orange = 'Orange', c_Purple = 'Purple', c_Red = 'Red', c_SkyBlue = 'SkyBlue', c_Teal = 'Teal', c_White = 'White', c_Yellow = 'Yellow', random = 'Random'}
local ran = {'Aqua','Black','Blue','Cyan','DarkGray','DarkGreen','Fuchsia','Gold','Gray','Green','Maroon','Olive','Orange','Purple','Red','SkyBlue','Teal','White','Yellow'}
local dName        = 'GetColor'
DefineCommand(dName, dName)
local pdefault    = DefineParameter(StringType, 'Default', 'The the default value', false, 'none', 'Color')
local pname    = DefineParameter(StringType, 'Name', 'The name of the command if using it more than once', false, 'Color', 'Color')
local gc_params = {
icolor    = InputOptions(pname, allcolors['none'], allcolors, 'All Colors to Select From'),
pcolor    = DefineParameter(StringType, dName, dName, false, 'none', dName),
}
local rn = Parse(Round(Random(1, 19), 0), NumberType)
local gcolor 
IfNull(gcolor, ran[rn])
if pdefault != 'none' and gc_params.pcolor == 'none' and gc_params.icolor == 'none' then gcolor = pdefault
elseif gc_params.pcolor != 'none' then gcolor = gc_params.pcolor 
elseif gc_params.icolor == 'Random' then gcolor = ran[rn]
elseif gc_params.icolor !='none' then gcolor = gc_params.icolor
else 
gcolor = ran[rn]
end
gcolor = StringJoin('c_', gcolor)
local c = {c_Aqua = Aqua,c_Black = Black,c_Blue = Blue,c_Cyan = Cyan,c_DarkGray = DarkGray,c_DarkGreen = DarkGreen,c_Fuchsia = Fuchsia,c_Gold = Gold,c_Gray = Gray,c_Green = Green,c_Maroon = Maroon,c_Olive = Olive,c_Orange = Orange,c_Purple = Purple,c_Red = Red,c_SkyBlue = SkyBlue,c_Teal = Teal,c_White = White,c_Yellow = Yellow}
local out = c[gcolor]
DefineOutput(DynamicType, out, 'Color', 'Color')

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!