So, showColors() is handy, but I sometimes wish it did a bit more. But I don't know that we want to keep adding options to the function in mudlet core.
Enter displayColors(options), a showColors() derivative I worked up based on what I learned while making showColors() sort based on color rather than just randomly. So, displayColors(options) takes a table of... well, options. You can replicate default showColors() behaviour using displayColors({columnSort = false, removeDupes = false}) . cols, search, and sort work the same as the arguments to the current showColors(), just as keys in the options table now.
Valid options are
--option defaults
options = {
cols = 4, --number of columns to display colors in
search = "", --filter the colors using a simple string.find search, defaults of "" means it doesn't filter (shows all eligible colors)
sort = false, --sort alphabetically rather than by color if true
echoOnly = false, --just echo to the screen, do not make them clickable.
window = "main", --where to echo the colors to. can be any miniconsole or userwindow, or 'main'. Can take Geyser objects as well as string names
removeDupes = true, --removes the duplicate snake_case colors, as well as the gray versions of grey.
columnSort = true, --prints by column not by row (showColors is by row)
justText = false, --instead of the bars showColor uses, just put colored text on black background
color_table = color_table, --by default it displays color_table, but you can feed it a custom table of colors to display instead. Must use the same format as color_table
}
So, some examples:
All defaults:
displayColors({columnSort = false}) :
I made a test table called test_colors which has just extreme red, green, and blue in it to demonstrate custom color tables:
displayColors({color_table = test_colors})
- displayColors-customcolors.png (3.76 KiB) Viewed 4572 times
For the following screenshot, the main window contains displayColors({columnSort = false, removeDupes = false}) which is essentially the same as showColors(), and I created the miniconsole using testMC = Geyser.MiniConsole:new({x="-600", y=0, width = 600, height = 600}), before displaying to it with displayColors({window = testMC})
And a new option, displayColors({justText = true})