Utility Functions
Location: addon_suite/util
Color
Location: addon_suite/util/color
There are two types of color used, RGBColor and ColorTable. The former is preferred, as ColorTable is deprecated.
RGBColor
Example: Create Laser violet as an RGBColor
local laserViolet = {
r = 204,
g = 153,
b = 255
}
to_rgb
Converts a color to RGBColor
Arguments
| name | description |
|---|---|
| value | A hex code or ColorTable |
Example: Create Laser violet as an RGBColor
local laserViolet = to_rgb(0xcc99ff)
hue_to_rgb
Arguments:
| name | description |
|---|---|
| hue | The hue of the color, 0-360 |
| intensity | The intensity of the color, 0 - 255 |
Converts a hue to an RGBColor. This is currently not exact, and is subject to change the internal math.
color_lerp
| name | description |
|---|---|
| colA | The starting Color |
| colB | The ending color |
| lerpValue | The position along the lerp, 0=A, 1=B |
color_to_srgb
Converts a RGBColor to be interpreted in srgb. Useful for displaying in linear color gammas - such as LEDs.
hex_to_srgb
Same as color_to_srgb, except it takes in a hex value
Example: Make the sign laser violet
local laserViolet = hex_to_srgb(0xcc99ff)
sign:add(0, set(laserViolet.r, laserViolet.g, laserViolet.g))
Deprecated
The following is deprecated and should be avoided
ColorTable
Example: Create Laser violet as an ColorTable
local laserViolet = {
204,
153,
255
}
rgb_color_to_rgb_table
Converts RGBColor to ColorTable
| name | description |
|---|---|
| rgbColor | An RGBColor |
Example: Create Laser violet as an ColorTable
local laserViolet = rgb_color_to_rgb_table({
r = 204,
g = 153,
b = 255
})
color_table_to_srgb
Same as color_to_srgb, except with ColorTable instead of RGBColor
color_table_lerp
Same as color_lerp, except with ColorTable instead of RGBColor
color_srgb_table_hex
Same as hex_to_srgb, except with ColorTable instead of RGBColor
Strings
Location: addon_suite/util/strings
pad_number_to_string_length
Pads a string or number to be at least the specified length
Arguments
| name | Optional | description |
|---|---|---|
| value | No | The string or number |
| length | No | The minimum length |
| padding | Yes | The padding string, defaults to 0 |