WolfieeifloW
WEHZ Helper
- Reaction score
- 372
Introduction:
A cool little library made by me.
All you do is input a color and the string you want to color.
There's two different versions (Blue and Red) .
Usage:
It takes a color and the word you want colored.
So in your function, for example:
JASS:
private function Warning takes nothing returns nothing
call BJDebugMsg(ColorIt("red", "WARNING!"))
endfunction
Where "red" is the color and "WARNING!" is the word you want colored.
That BJDebugMsg() would result in:
Code:
[color=red]WARNING![/color]
An example of ColorIt in action:
JASS:
scope TestColor initializer TCInit
private function TCActions takes nothing returns nothing
call DisplayTextToPlayer(Player(0), 0, 0, "Player " + ColorIt("gold", GetPlayerName(GetTriggerPlayer())) + " has asked for " + ColorIt("red", "help") + "!")
//Display to 'Player 1 (Red)' that the triggering player needs help;
//The players name will be colored "gold" because of ColorIt("gold", GetPlayerName(GetTriggerPlayer()))
// Tells ColorIt you want the players name colored gold --^ ^-- Tells ColorIt you want the triggering players name colored
//The text "help" will be colored "red" because of ColorIt("red", "help")
// Tells ColorIt you want your text colored red --^ ^-- Tell ColorIt you want the text "help" colored
endfunction
//====================================================================================================
private function TCInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "-help", true) //Register if a player types "-help"
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction(t, function TCActions)
endfunction
endscope
Code:
ColorIt Blue:
JASS:
// +------------------------------------------------------------+
// | |
// | -=-=- ColorIt Blue -=-=- |
// | -=-=- By Wolfie[NoCT] -=-=- |
// | Requires Jass NewGen |
// | |
// +------------------------------------------------------------+
// | |
// | ColorIt Blue; |
// | - Provides an easier way to manage colors |
// | - Uses a loop to check for a valid color |
// | |
// +------------------------------------------------------------+
library ColorItBlue initializer CIBInit
// +---------------------------------+
// | -=-=- MODIFY HERE -=-=- |
// | -=-=- MODIFY HERE -=-=- |
// | -=-=- MODIFY HERE -=-=- |
// +---------------------------------+
globals
constant integer COLORSNUM = 40
//Change this to the number of array slots used
constant string DEFAULT = "ffffff"
//Change this to the color you want strings to
//Default to if users enter an invalid color
//Don't touch these!
string array COLORNAME//Don't touch these!
string array COLORCODE//Don't touch these!
//Don't touch these!
endglobals
// +--------------------------------------------------------------+
// | Set the colors name into COLORNAME[] |
// | Set the hexcode of the color into COLORCODE[] |
// | Remember to change COLORSNUM to the number of slot used! |
// +--------------------------------------------------------------+
function CIBActions takes nothing returns nothing
set COLORNAME[0] = "aqua"
set COLORCODE[0] = "00ffff"
set COLORNAME[1] = "azure"
set COLORCODE[1] = "f0ffff"
set COLORNAME[2] = "beige"
set COLORCODE[2] = "f5f5dc"
set COLORNAME[3] = "black"
set COLORCODE[3] = "000000"
set COLORNAME[4] = "blue"
set COLORCODE[4] = "0000ff"
set COLORNAME[5] = "brown"
set COLORCODE[5] = "a52a2a"
set COLORNAME[6] = "coral"
set COLORCODE[6] = "ff7f50"
set COLORNAME[7] = "crimson"
set COLORCODE[7] = "dc143c"
set COLORNAME[8] = "cyan"
set COLORCODE[8] = "99b4d1"
set COLORNAME[9] = "darkblue"
set COLORCODE[9] = "00008b"
set COLORNAME[10] = "darkgreen"
set COLORCODE[10] = "006400"
set COLORNAME[11] = "darkorange"
set COLORCODE[11] = "ff8c00"
set COLORNAME[12] = "darkred"
set COLORCODE[12] = "8b0000"
set COLORNAME[13] = "gold"
set COLORCODE[13] = "ffd700"
set COLORNAME[14] = "grey"
set COLORCODE[14] = "808080"
set COLORNAME[15] = "green"
set COLORCODE[15] = "008000"
set COLORNAME[16] = "hotpink"
set COLORCODE[16] = "ff0099"
set COLORNAME[17] = "indigo"
set COLORCODE[17] = "4b0082"
set COLORNAME[18] = "lavender"
set COLORCODE[18] = "e6e6fa"
set COLORNAME[19] = "lightblue"
set COLORCODE[19] = "add8e6"
set COLORNAME[20] = "lime"
set COLORCODE[20] = "00ff00"
set COLORNAME[21] = "magenta"
set COLORCODE[21] = "ff00ff"
set COLORNAME[22] = "maroon"
set COLORCODE[22] = "800000"
set COLORNAME[23] = "navy"
set COLORCODE[23] = "000080"
set COLORNAME[24] = "olive"
set COLORCODE[24] = "808000"
set COLORNAME[25] = "orange"
set COLORCODE[25] = "ffa500"
set COLORNAME[26] = "orchid"
set COLORCODE[26] = "da70d6"
set COLORNAME[27] = "pink"
set COLORCODE[27] = "ffc0cb"
set COLORNAME[28] = "plum"
set COLORCODE[28] = "dda0dd"
set COLORNAME[29] = "purple"
set COLORCODE[29] = "800080"
set COLORNAME[30] = "red"
set COLORCODE[30] = "ff0000"
set COLORNAME[31] = "salmon"
set COLORCODE[31] = "fa8072"
set COLORNAME[32] = "silver"
set COLORCODE[32] = "c0c0c0"
set COLORNAME[33] = "snow"
set COLORCODE[33] = "fffafa"
set COLORNAME[34] = "tan"
set COLORCODE[34] = "d2b48c"
set COLORNAME[35] = "teal"
set COLORCODE[35] = "008080"
set COLORNAME[36] = "tomato"
set COLORCODE[36] = "ff6347"
set COLORNAME[37] = "turquoise"
set COLORCODE[37] = "40e0d0"
set COLORNAME[38] = "violet"
set COLORCODE[38] = "ee82ee"
set COLORNAME[39] = "yellow"
set COLORCODE[39] = "ffff00"
//set COLORNAME[40] = "ColorName"
//set COLORCODE[40] = "ColorCode"
//[...]
endfunction
// +------------------------------------------+
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// | -=-=- NO TOUCHIE PAST HERE -=-=- |
// +------------------------------------------+
function ColorIt takes string Color, string Word returns string Colored
local integer i = 0
local boolean cc = false
loop
exitwhen i == COLORSNUM
if (Color != COLORNAME<i>) then
set cc = false
else
return ("|cff" + COLORCODE<i> + Word + "|r")
endif
set i = i + 1
endloop
return ("|cff" + DEFAULT + Word + "|r")
endfunction
//====================================================================================================
private function CIBInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.01, false)
call TriggerAddAction(t, function CIBActions)
endfunction
endlibrary</i></i>
ColorIt Red:
JASS:
// +------------------------------------------------------------+
// | |
// | -=-=- ColorIt Red -=-=- |
// | -=-=- By Wolfie[NoCT] -=-=- |
// | Requires Jass NewGen |
// | |
// +------------------------------------------------------------+
// | |
// | ColorIt Red; |
// | - A more advanced version |
// | - Utilizes Elseif's to return values |
// | |
// +------------------------------------------------------------+
library ColorItRed
globals
constant string DEFAULT = "|cffffffff"
endglobals
function ColorIt takes string Color, string Word returns string Colored
if (Color == "aqua") then
return ("|cff00ffff" + Word + "|r")
elseif (Color == "azure") then
return ("|cfff0ffff" + Word + "|r")
elseif (Color == "beige") then
return ("|cfff5f5dc" + Word + "|r")
elseif (Color == "black") then
return ("|cff000000" + Word + "|r")
elseif (Color == "blue") then
return ("|cff0000ff" + Word + "|r")
elseif (Color == "brown") then
return ("|cffa52a2a" + Word + "|r")
elseif (Color == "coral") then
return ("|cffff7f50" + Word + "|r")
elseif (Color == "crimson") then
return ("|cffdc143c" + Word + "|r")
elseif (Color == "cyan") then
return ("|cff99b4d1" + Word + "|r")
elseif (Color == "darkblue") then
return ("|cff00008b" + Word + "|r")
elseif (Color == "darkgreen") then
return ("|cff006400" + Word + "|r")
elseif (Color == "darkorange") then
return ("|cffff8c00" + Word + "|r")
elseif (Color == "darkred") then
return ("|cff8b0000" + Word + "|r")
elseif (Color == "gold") then
return ("|cffffd700" + Word + "|r")
elseif (Color == "grey" or Color == "gray") then
return ("|cff808080" + Word + "|r")
elseif (Color == "green") then
return ("|cff008000" + Word + "|r")
elseif (Color == "hotpink") then
return ("|cffff0099" + Word + "|r")
elseif (Color == "indigo") then
return ("|cff4b0082" + Word + "|r")
elseif (Color == "lavender") then
return ("|cffe6e6fa" + Word + "|r")
elseif (Color == "lightblue") then
return ("|cffadd8e6" + Word + "|r")
elseif (Color == "lime") then
return ("|cff00ff00" + Word + "|r")
elseif (Color == "magenta") then
return ("|cffff00ff" + Word + "|r")
elseif (Color == "maroon") then
return ("|cff800000" + Word + "|r")
elseif (Color == "navy") then
return ("|cff000080" + Word + "|r")
elseif (Color == "olive") then
return ("|cff808000" + Word + "|r")
elseif (Color == "orange") then
return ("|cffffa500" + Word + "|r")
elseif (Color == "orchid") then
return ("|cffda70d6" + Word + "|r")
elseif (Color == "pink") then
return ("|cffffc0cb" + Word + "|r")
elseif (Color == "plum") then
return ("|cffdda0dd" + Word + "|r")
elseif (Color == "purple") then
return ("|cff800080" + Word + "|r")
elseif (Color == "red") then
return ("|cffff0000" + Word + "|r")
elseif (Color == "salmon") then
return ("|cfffa8072" + Word + "|r")
elseif (Color == "silver") then
return ("|cffc0c0c0" + Word + "|r")
elseif (Color == "snow") then
return ("|cfffffafa" + Word + "|r")
elseif (Color == "tan") then
return ("|cffd2b48c" + Word + "|r")
elseif (Color == "teal") then
return ("|cff008080" + Word + "|r")
elseif (Color == "tomato") then
return ("|cffff6347" + Word + "|r")
elseif (Color == "turquoise") then
return ("|cff40e0d0" + Word + "|r")
elseif (Color == "violet") then
return ("|cffee82ee" + Word + "|r")
elseif (Color == "yellow") then
return ("|cffffff00" + Word + "|r")
//elseif (Color == "ColorName") then
//return ("ColorCode" + Word + "|r")
else
return (DEFAULT + Word + "|r")
endif
endfunction
endlibrary
NOTE: If someone can make a Hexcode converter for this that would be awesome;
Eg. The user types in "red" and the converter retrieves "|cffff0000".