Print: Difference between revisions
imported>Fredg1 mNo edit summary |
mNo edit summary |
||
Line 40: | Line 40: | ||
see_also={{SeeAlso|dump|logprint|print_html|chat_notify}}| | see_also={{SeeAlso|dump|logprint|print_html|chat_notify}}| | ||
cli_equiv=The CLI commands "fprint," "echo" and "fecho" have similar functionality, minus the color option. However, "cecho" (also "colorecho") does have this option for color.| | cli_equiv=The CLI commands "fprint," "echo" and "fecho" have similar functionality, minus the color option. However, "cecho" (also "colorecho") does have this option for color.| | ||
special=A list of common color commands that can be used: | special=A list of common color commands that can be used: maroon, red, orange, yellow, olive, green, lime, teal, aqua, blue, navy, fuchsia, purple, black, gray, silver, white.<br> More advance colors can be used by entering their Hexadecimal code as the string. <br>Using an invalid color name or code can cause odd colors to be chosen; see the [[Talk:Print|Talk Page]] for details. | ||
<br />As of r8638, attempting to print a string beginning with a slash(/) will cause KoLmafia to print a blank line instead. To avoid this behavior, you must specify the second argument for the text color. Any color will do, and even a blank string (<code>""</code>) will work. | <br />As of r8638, attempting to print a string beginning with a slash(/) will cause KoLmafia to print a blank line instead. To avoid this behavior, you must specify the second argument for the text color. Any color will do, and even a blank string (<code>""</code>) will work. | ||
| | | |
Latest revision as of 14:55, 20 November 2024
Function Syntax
void print(string message ,string color )
- message is the text to print
- color is an html color name or code
Print the specified text message to the CLI. If the optional color parameter is specified and a valid html color code or entity, it will print in that color. See the CSS 2.1 color specification for a description of valid color syntax and keywords.
Code Sample
Prints stuff in color and black. Note that it prints black twice: first and last.
print("This is black.");
foreach color in $strings[blue, green, olive, darkorange, magenta, black]
print("This is "+color+".", color);
CLI Equivalent
The CLI commands "fprint," "echo" and "fecho" have similar functionality, minus the color option. However, "cecho" (also "colorecho") does have this option for color.
See Also
Special
A list of common color commands that can be used: maroon, red, orange, yellow, olive, green, lime, teal, aqua, blue, navy, fuchsia, purple, black, gray, silver, white.
More advance colors can be used by entering their Hexadecimal code as the string.
Using an invalid color name or code can cause odd colors to be chosen; see the Talk Page for details.
As of r8638, attempting to print a string beginning with a slash(/) will cause KoLmafia to print a blank line instead. To avoid this behavior, you must specify the second argument for the text color. Any color will do, and even a blank string (""
) will work.