1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5
<title>Reference</title>
6
<link rel="stylesheet" href="../luadoc.css" type="text/css" />
7
<!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
14
<div id="product_logo"></div>
15
<div id="product_name"><big><b></b></big></div>
16
<div id="product_description"></div>
17
</div> <!-- id="product" -->
27
<li><a href="../index.html">Index</a></li>
42
<a href="../files/CoreMudlet.html">CoreMudlet.lua</a>
46
<a href="../files/DB.html">DB.lua</a>
50
<a href="../files/DebugTools.html">DebugTools.lua</a>
53
<li><strong>GUIUtils.lua</strong></li>
56
<a href="../files/Logging.html">Logging.lua</a>
60
<a href="../files/LuaGlobal.html">LuaGlobal.lua</a>
64
<a href="../files/Other.html">Other.lua</a>
68
<a href="../files/StringUtils.html">StringUtils.lua</a>
72
<a href="../files/TableUtils.html">TableUtils.lua</a>
76
<a href="../files/geyser/Geyser.html">geyser/Geyser.lua</a>
80
<a href="../files/geyser/GeyserColor.html">geyser/GeyserColor.lua</a>
84
<a href="../files/geyser/GeyserContainer.html">geyser/GeyserContainer.lua</a>
88
<a href="../files/geyser/GeyserGauge.html">geyser/GeyserGauge.lua</a>
92
<a href="../files/geyser/GeyserGeyser.html">geyser/GeyserGeyser.lua</a>
96
<a href="../files/geyser/GeyserLabel.html">geyser/GeyserLabel.lua</a>
100
<a href="../files/geyser/GeyserMiniConsole.html">geyser/GeyserMiniConsole.lua</a>
104
<a href="../files/geyser/GeyserReposition.html">geyser/GeyserReposition.lua</a>
108
<a href="../files/geyser/GeyserSetConstraints.html">geyser/GeyserSetConstraints.lua</a>
112
<a href="../files/geyser/GeyserTests.html">geyser/GeyserTests.lua</a>
116
<a href="../files/geyser/GeyserUtil.html">geyser/GeyserUtil.lua</a>
120
<a href="../files/geyser/GeyserWindow.html">geyser/GeyserWindow.lua</a>
129
</div> <!-- id="navigation" -->
133
<h1>File <code>GUIUtils.lua</code></h1>
142
<table class="function_list">
145
<td class="name" nowrap><a href="#PadHexNum">PadHexNum</a> (incString)</td>
146
<td class="summary">Pads a hex number to ensure a minimum of 2 digits.</td>
150
<td class="name" nowrap><a href="#RGB2Hex">RGB2Hex</a> (red, green, blue)</td>
151
<td class="summary">Converts an RGB value into an HTML compliant(label usable) HEX number.</td>
155
<td class="name" nowrap><a href="#bg">bg</a> (colorName)</td>
156
<td class="summary">Sets current background color to a named color.</td>
160
<td class="name" nowrap><a href="#cecho">cecho</a> (...)</td>
161
<td class="summary">Echo string with embedded color name information.</td>
165
<td class="name" nowrap><a href="#cinsertText">cinsertText</a> (...)</td>
166
<td class="summary">Inserts string with embedded color name information.</td>
170
<td class="name" nowrap><a href="#color_table">color_table</a> ()</td>
171
<td class="summary">The <i>color_table table</i> holds definition of color names.</td>
175
<td class="name" nowrap><a href="#createConsole">createConsole</a> (consoleName, fontSize, charsPerLine, numberOfLines, Xpos, Ypos)</td>
176
<td class="summary">Make a new console window with ease.</td>
180
<td class="name" nowrap><a href="#createGauge">createGauge</a> (gaugeName, width, height, Xpos, Ypos, gaugeText, color1, color2, color3)</td>
181
<td class="summary">Make your very own customized gauge with this function.</td>
185
<td class="name" nowrap><a href="#decho">decho</a> (...)</td>
186
<td class="summary">Echo string with embedded decimal color information.</td>
190
<td class="name" nowrap><a href="#deselect">deselect</a> ()</td>
191
<td class="summary">Clears the current selection in the main window or miniConsole window.</td>
195
<td class="name" nowrap><a href="#dinsertText">dinsertText</a> (...)</td>
196
<td class="summary">Inserts string with embedded decimal color information.</td>
200
<td class="name" nowrap><a href="#fg">fg</a> (colorName)</td>
201
<td class="summary">Sets current foreground color to a named color.</td>
205
<td class="name" nowrap><a href="#gagLine">gagLine</a> ()</td>
206
<td class="summary">Function will gag the whole line.</td>
210
<td class="name" nowrap><a href="#gaugesTable">gaugesTable</a> ()</td>
211
<td class="summary">The <i>gaugesTable table</i>.</td>
215
<td class="name" nowrap><a href="#getRGB">getRGB</a> (colorName)</td>
216
<td class="summary">Get RGB component from color name.</td>
220
<td class="name" nowrap><a href="#handleWindowResizeEvent">handleWindowResizeEvent</a> ()</td>
221
<td class="summary">Default resizeEvent handler function.</td>
225
<td class="name" nowrap><a href="#hecho">hecho</a> (...)</td>
226
<td class="summary">Echo string with embedded hex color information.</td>
230
<td class="name" nowrap><a href="#hinsertText">hinsertText</a> (...)</td>
231
<td class="summary">Inserts string with embedded hex color information.</td>
235
<td class="name" nowrap><a href="#moveGauge">moveGauge</a> (gaugeName, newX, newY)</td>
236
<td class="summary">Move a custom gauge.</td>
240
<td class="name" nowrap><a href="#prefix">prefix</a> (what, func, fg, bg, window)</td>
241
<td class="summary">Prefixes text at the beginning of the current line when used in a trigger.</td>
245
<td class="name" nowrap><a href="#replaceAll">replaceAll</a> (word, what)</td>
246
<td class="summary">Replaces all occurrences of what in the current line with <i>with</i>.</td>
250
<td class="name" nowrap><a href="#replaceLine">replaceLine</a> (what)</td>
251
<td class="summary">Replace the whole with a string you'd like.</td>
255
<td class="name" nowrap><a href="#replaceWildcard">replaceWildcard</a> (what, replacement)</td>
256
<td class="summary">Replaces the given wildcard (as a number) with the given text.</td>
260
<td class="name" nowrap><a href="#resizeGauge">resizeGauge</a> (gaugeName, width, height)</td>
261
<td class="summary"><b><u>TODO</u></b> resizeGauge(gaugeName, width, height) </td>
265
<td class="name" nowrap><a href="#setGauge">setGauge</a> (gaugeName, currentValue, maxValue, gaugeText)</td>
266
<td class="summary">Use this function when you want to change the gauges look according to your values.</td>
270
<td class="name" nowrap><a href="#setGaugeStyleSheet">setGaugeStyleSheet</a> (gaugeName, css, cssback)</td>
271
<td class="summary"><b><u>TODO</u></b> setGaugeStyleSheet(gaugeName, css, cssback) </td>
275
<td class="name" nowrap><a href="#setGaugeText">setGaugeText</a> (gaugeName, gaugeText, color1, color2, color3)</td>
276
<td class="summary">Set the text on a custom gauge.</td>
280
<td class="name" nowrap><a href="#showColors">showColors</a> (...)</td>
281
<td class="summary">Prints out a formatted list of all available named colors, optional arg specifies number of columns to print in, defaults to 3 </td>
285
<td class="name" nowrap><a href="#suffix">suffix</a> (what, func, fg, bg, window)</td>
286
<td class="summary">Suffixes text at the end of the current line when used in a trigger.</td>
290
<td class="name" nowrap><a href="#xEcho">xEcho</a> (style, insert, win, str)</td>
291
<td class="summary">Generic color echo and insert function (allowing hecho, decho, cecho, hinsertText, dinsertText and cinsertText).</td>
307
<h2><a name="functions"></a>Functions</h2>
308
<dl class="function">
312
<dt><a name="PadHexNum"></a>
313
<b><big>PadHexNum </big></b>(incString)</dt>
316
Pads a hex number to ensure a minimum of 2 digits.
336
<li>Following command will returns "F0". <pre> PadHexNum("F")
350
<dt><a name="RGB2Hex"></a>
351
<b><big>RGB2Hex </big></b>(red, green, blue)</dt>
354
Converts an RGB value into an HTML compliant(label usable) HEX number. This function is colorNames aware and can take any defined global color as its first argument.
382
<li>Both following commands will returns "FFFFFF". <pre> RGB2Hex(255,255,255)
394
<li><b>MISSING LINK: 'showColor'</b>
404
<dt><a name="bg"></a>
405
<b><big>bg </big></b>(colorName)</dt>
408
Sets current background color to a named color.
428
<li>Set background color to magenta. <pre> bg("magenta")
439
<li><a href='GUIUtils.html#fg'>fg</a>
441
<li><a href='GUIUtils.html#showColors'>showColors</a>
451
<dt><a name="cecho"></a>
452
<b><big>cecho </big></b>(...)</dt>
455
Echo string with embedded color name information.
475
<li>Consider following example: <pre> cecho("<green>green text <blue>blue text <red>red text")
486
<li><a href='GUIUtils.html#xEcho'>xEcho</a>
488
<li><a href='GUIUtils.html#cinsertText'>cinsertText</a>
498
<dt><a name="cinsertText"></a>
499
<b><big>cinsertText </big></b>(...)</dt>
502
Inserts string with embedded color name information.
527
<li><a href='GUIUtils.html#xEcho'>xEcho</a>
529
<li><a href='GUIUtils.html#cecho'>cecho</a>
539
<dt><a name="color_table"></a>
540
<b><big>color_table </big></b>()</dt>
543
The <i>color_table table</i> holds definition of color names. These are intended to be used in conjunction with fg() and bg() colorizer functions.
559
<li><a href='GUIUtils.html#showColors'>showColors</a>
561
<li><a href='GUIUtils.html#bg'>bg</a>
563
<li><a href='GUIUtils.html#fg'>fg</a>
573
<dt><a name="createConsole"></a>
574
<b><big>createConsole </big></b>(consoleName, fontSize, charsPerLine, numberOfLines, Xpos, Ypos)</dt>
577
Make a new console window with ease. The default background is black and text color white. If you wish to change the color you can easily do this when updating your text or manually somewhere, using setFgColor() and setBackgroundColor().
617
<li>This will create a miniconsole window that has a font size of 8pt, will display 80 characters in width, hold a maximum of 20 lines and be place at 200x400 of your Mudlet window. <pre> createConsole("myConsoleWindow", 8, 80, 20, 200, 400)
631
<dt><a name="createGauge"></a>
632
<b><big>createGauge </big></b>(gaugeName, width, height, Xpos, Ypos, gaugeText, color1, color2, color3)</dt>
635
Make your very own customized gauge with this function.
688
<li>This would make a gauge at that's 300px width, 20px in height, located at Xpos and Ypos and is green. <pre> createGauge("healthBar", 300, 20, 30, 300, nil, 0, 255, 0)
691
<li>The second example is using the same names you'd use for something like fg() or bg(). <pre> createGauge("healthBar", 300, 20, 30, 300, nil, "green")
694
<li>Finally we'll add some text to our gauche. <pre> createGauge("healthBar", 300, 20, 30, 300, "Now with some text", "green")
709
<dt><a name="decho"></a>
710
<b><big>decho </big></b>(...)</dt>
713
Echo string with embedded decimal color information. <br/><br/> Color changes can be made using the format <FR,FG,FB:BR,BG,BB> where each field is a number from 0 to 255. The background portion can be omitted using <FR,FG,FB> or the foreground portion can be omitted using <:BR,BG,BB>.
733
<li>Print red test on green background. <pre> decho("<255,0,0:0,255,0>test")
744
<li><a href='GUIUtils.html#xEcho'>xEcho</a>
746
<li><a href='GUIUtils.html#dinsertText'>dinsertText</a>
756
<dt><a name="deselect"></a>
757
<b><big>deselect </big></b>()</dt>
760
Clears the current selection in the main window or miniConsole window. <br/> (Note: <i>deselect(windowName)</i> is implemented in Core Mudlet.)
772
<li>Clear selection in main window. <pre> deselect()
775
<li>Clear selection in myMiniConsole window. <pre> deselect("myMiniConsole")
790
<dt><a name="dinsertText"></a>
791
<b><big>dinsertText </big></b>(...)</dt>
794
Inserts string with embedded decimal color information.
819
<li><a href='GUIUtils.html#xEcho'>xEcho</a>
821
<li><a href='GUIUtils.html#decho'>decho</a>
831
<dt><a name="fg"></a>
832
<b><big>fg </big></b>(colorName)</dt>
835
Sets current foreground color to a named color.
855
<li>Set foreground color to black. <pre> fg("black")
866
<li><a href='GUIUtils.html#bg'>bg</a>
868
<li><a href='GUIUtils.html#showColors'>showColors</a>
878
<dt><a name="gagLine"></a>
879
<b><big>gagLine </big></b>()</dt>
882
Function will gag the whole line. <b>Use deleteLine() instead.</b>
901
<dt><a name="gaugesTable"></a>
902
<b><big>gaugesTable </big></b>()</dt>
905
The <i>gaugesTable table</i>. First we need to make this table which will be used later to store important data in.
924
<dt><a name="getRGB"></a>
925
<b><big>getRGB </big></b>(colorName)</dt>
928
Get RGB component from color name.
948
<li>Following will display "0.255.0" on your screen. <pre> local red, green, blue = getRGB("green")
949
echo(red .. "." .. green .. "." .. blue )
963
<dt><a name="handleWindowResizeEvent"></a>
964
<b><big>handleWindowResizeEvent </big></b>()</dt>
967
Default resizeEvent handler function. Overwrite this function to make a custom event handler if the main window is being resized. <br/><br/> The standard implementation of this function does nothing. However, this function gets called whenever the main window is being manually resized. You can overwrite this function in your own scripts to handle window resize events yourself and e.g. adjust the screen position and size of your mini console windows, labels or other relevant GUI elements in your scripts that depend on the size of the main Window. To override this function you can simply put a function with the same name in one of your scripts thus overwriting the original empty implementation of this function. <pre> function handleWindowResizeEvent()
968
-- determine the size of your screen
971
WindowWidth, WindowHeight = getMainWindowSize();
972
-- move mini console "sys" to the far right side of the screen whenever the screen gets resized
973
moveWindow("sys",WindowWidth-300,0)
994
<dt><a name="hecho"></a>
995
<b><big>hecho </big></b>(...)</dt>
998
Echo string with embedded hex color information. <br/><br/> Color changes can be made within the string using the format |cFRFGFB,BRBGBB where FR is the foreground red value, FG is the foreground green value, FB is the foreground blue value, BR is the background red value, etc., BRBGBB is optional. |r can be used within the string to reset the colors to default.
1023
<li><a href='GUIUtils.html#xEcho'>xEcho</a>
1025
<li><a href='GUIUtils.html#hinsertText'>hinsertText</a>
1035
<dt><a name="hinsertText"></a>
1036
<b><big>hinsertText </big></b>(...)</dt>
1039
Inserts string with embedded hex color information.
1064
<li><a href='GUIUtils.html#xEcho'>xEcho</a>
1066
<li><a href='GUIUtils.html#hecho'>hecho</a>
1076
<dt><a name="moveGauge"></a>
1077
<b><big>moveGauge </big></b>(gaugeName, newX, newY)</dt>
1080
Move a custom gauge.
1108
<li>This would move the health bar gauge to the location 1200, 400. <pre> moveGauge("healthBar", 1200, 400)
1119
<li><a href='GUIUtils.html#createGauge'>createGauge</a>
1129
<dt><a name="prefix"></a>
1130
<b><big>prefix </big></b>(what, func, fg, bg, window)</dt>
1133
Prefixes text at the beginning of the current line when used in a trigger.
1169
<li>Prefix the hours, minutes and seconds onto our prompt even though Mudlet has a button for that. <pre> prefix(os.date("%H:%M:%S "))
1180
<li><a href='GUIUtils.html#suffix'>suffix</a>
1190
<dt><a name="replaceAll"></a>
1191
<b><big>replaceAll </big></b>(word, what)</dt>
1194
Replaces all occurrences of what in the current line with <i>with</i>.
1218
<li>This will replace all occurrences of John with the word Doe. <pre> replaceAll("John", "Doe")
1232
<dt><a name="replaceLine"></a>
1233
<b><big>replaceLine </big></b>(what)</dt>
1236
Replace the whole with a string you'd like.
1261
<li><a href='CoreMudlet.html#deleteLine'>deleteLine</a>
1271
<dt><a name="replaceWildcard"></a>
1272
<b><big>replaceWildcard </big></b>(what, replacement)</dt>
1275
Replaces the given wildcard (as a number) with the given text.
1299
<li>Replace "goodbye" with "hello" on a trigger of "^You wave (goodbye)\.$" <pre> replaceWildcard(2, "hello")
1300
</pre> Is equivalent to doing: <pre> selectString(matches[2], 1)
1315
<dt><a name="resizeGauge"></a>
1316
<b><big>resizeGauge </big></b>(gaugeName, width, height)</dt>
1319
<b><u>TODO</u></b> resizeGauge(gaugeName, width, height)
1355
<dt><a name="setGauge"></a>
1356
<b><big>setGauge </big></b>(gaugeName, currentValue, maxValue, gaugeText)</dt>
1359
Use this function when you want to change the gauges look according to your values. Typical usage would be in a prompt with your current health or whatever value, and throw in some variables instead of the numbers.
1392
<li>In that example, we'd change the looks of the gauge named healthBar and make it fill to half of its capacity. The height is always remembered. <pre> setGauge("healthBar", 200, 400)
1395
<li>Change the text on your gauge. <pre> setGauge("healthBar", 200, 400, "some text")
1410
<dt><a name="setGaugeStyleSheet"></a>
1411
<b><big>setGaugeStyleSheet </big></b>(gaugeName, css, cssback)</dt>
1414
<b><u>TODO</u></b> setGaugeStyleSheet(gaugeName, css, cssback)
1450
<dt><a name="setGaugeText"></a>
1451
<b><big>setGaugeText </big></b>(gaugeName, gaugeText, color1, color2, color3)</dt>
1454
Set the text on a custom gauge.
1469
gaugeText: An empty gaugeText will clear the text entirely.
1473
color1: Colors are optional and will default to 0,0,0(black) if not passed as args.
1491
<li> <pre> setGaugeText("healthBar", "HP: 100%", 40, 40, 40)
1494
<li> <pre> setGaugeText("healthBar", "HP: 100%", "red")
1506
<li><a href='GUIUtils.html#createGauge'>createGauge</a>
1516
<dt><a name="showColors"></a>
1517
<b><big>showColors </big></b>(...)</dt>
1520
Prints out a formatted list of all available named colors, optional arg specifies number of columns to print in, defaults to 3
1541
<li>Print list in 3 columns by default. <pre> showColors()
1544
<li>Print list in 2 columns. <pre> showColors(2)
1556
<li><a href='GUIUtils.html#color_table'>color_table</a>
1566
<dt><a name="suffix"></a>
1567
<b><big>suffix </big></b>(what, func, fg, bg, window)</dt>
1570
Suffixes text at the end of the current line when used in a trigger.
1611
<li><a href='GUIUtils.html#prefix'>prefix</a>
1621
<dt><a name="xEcho"></a>
1622
<b><big>xEcho </big></b>(style, insert, win, str)</dt>
1625
Generic color echo and insert function (allowing hecho, decho, cecho, hinsertText, dinsertText and cinsertText).
1636
style: Hex, Decimal or Color
1640
insert: boolean flag to determine echo/insert behaviour
1644
win: windowName optional
1648
str: text with embedded color information
1662
<li><a href='GUIUtils.html#cecho'>cecho</a>
1664
<li><a href='GUIUtils.html#decho'>decho</a>
1666
<li><a href='GUIUtils.html#hecho'>hecho</a>
1668
<li><a href='GUIUtils.html#cinsertText'>cinsertText</a>
1670
<li><a href='GUIUtils.html#dinsertText'>dinsertText</a>
1672
<li><a href='GUIUtils.html#hinsertText'>hinsertText</a>
1688
</div> <!-- id="content" -->
1690
</div> <!-- id="main" -->
1693
<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
1694
</div> <!-- id="about" -->
1696
</div> <!-- id="container" -->
b'\\ No newline at end of file'