Difference between revisions of "Manual:Display Functions"

From Mudlet
Jump to navigation Jump to search
(→‎showColors: updated for filterColor argument in 3.0)
Line 8: Line 8:
  
 
;Example
 
;Example
<lua>
+
<syntaxhighlight lang="lua">
 
-- ask it to display a table
 
-- ask it to display a table
 
display({a = "somevalue", 1,2,3})
 
display({a = "somevalue", 1,2,3})
 
-- or some other target
 
-- or some other target
 
display(target)
 
display(target)
</lua>
+
</syntaxhighlight>
  
 
===showColors===
 
===showColors===
Line 27: Line 27:
  
 
;Example:
 
;Example:
<lua>
+
<syntaxhighlight lang="lua">
 
-- display as four columns:
 
-- display as four columns:
 
showColors(4)
 
showColors(4)
Line 33: Line 33:
 
-- show only red colours:
 
-- show only red colours:
 
showColors("red")
 
showColors("red")
</lua>
+
</syntaxhighlight>
 
The output for this is:
 
The output for this is:
  
Line 46: Line 46:
  
 
;Example
 
;Example
<lua>
+
<syntaxhighlight lang="lua">
 
--This will effectively have the same result as a call to deleteLine() but the buffer line will not be entirely removed.  
 
--This will effectively have the same result as a call to deleteLine() but the buffer line will not be entirely removed.  
 
--Consequently, further calls to echo() etc. sort of functions are possible without using wrapLine() unnecessarily.
 
--Consequently, further calls to echo() etc. sort of functions are possible without using wrapLine() unnecessarily.
Line 52: Line 52:
 
selectString(line,1);
 
selectString(line,1);
 
replace("");
 
replace("");
</lua>
+
</syntaxhighlight>

Revision as of 04:08, 29 June 2017

Display Functions

A collection of functions for displaying or formatting information on the screen.

display

display(value)
This function will do it's best to show whatever you ask it (a number, string, table, function). This function can be useful for seeing what values does a table have, for example. Note that this doesn't handle recursive references and will loop infinitely at the moment (Mudlet 2.0-test4). If a value is a string, it'll be in single quotes, and if it's a number, it won't be quoted.
Example
-- ask it to display a table
display({a = "somevalue", 1,2,3})
-- or some other target
display(target)

showColors

showColors(columns, filterColor)
shows the named colors currently available in Mudlet's color table. These colors are stored in color_table, in table form. The format is color_table.colorName = {r,g,b}.
See Also: bg(), fg(), cecho()
Parameters
  • columns:
Optional: number of columns to print the color table in. Passed as a number.
  • filterColor:
Optional: limits the display to only certain colours that contain this word.
Example
-- display as four columns:
showColors(4)

-- show only red colours:
showColors("red")

The output for this is:

showColors(4)

wrapLine

wrapLine( windowName, lineNumber )
Wrap line lineNumber of mini console (window) windowName. This function will interpret \n characters, apply word wrap and display the new lines on the screen. This function may be necessary if you use deleteLine() and thus erase the entire current line in the buffer, but you want to do some further echo() calls after calling deleteLine(). You will then need to re-wrap the last line of the buffer to actually see what you have echoed and get you \n interpreted as newline characters properly. Using this function is no good programming practice and should be avoided. There are better ways of handling situations where you would call deleteLine() and echo afterwards.
Example
--This will effectively have the same result as a call to deleteLine() but the buffer line will not be entirely removed. 
--Consequently, further calls to echo() etc. sort of functions are possible without using wrapLine() unnecessarily.

selectString(line,1);
replace("");