Difference between revisions of "Manual:UI Functions"

From Mudlet
Jump to navigation Jump to search
(→‎selectCaptureGroup: fix documentation for indexing)
 
(31 intermediate revisions by 7 users not shown)
Line 247: Line 247:
 
;Formatting
 
;Formatting
  
<syntaxhighlight>
+
<syntaxhighlight lang="text">
 
<b>  - bold
 
<b>  - bold
 
</b> - bold off
 
</b> - bold off
Line 273: Line 273:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
cecho("Hi! This text is <red>red, <blue>blue, <green> and green.")
 
cecho("Hi! This text is <red>red, <blue>blue, <green> and green.")
 +
 +
cecho("Hi! This text is <ansi_001>red, <ansi_004>blue, <ansi_002> and green<reset> using ansi keys.")
  
 
cecho("<:green>Green background on normal foreground. Here we add an <ivory>ivory foreground.")
 
cecho("<:green>Green background on normal foreground. Here we add an <ivory>ivory foreground.")
Line 353: Line 355:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
 +
==cecho2decho==
 +
 +
; convertedString = cecho2decho(str)
 +
 +
:Converts a cecho formatted string to a decho formatted one.
 +
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
 +
 +
{{MudletVersion|4.18}}
 +
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from cecho to decho
 +
;Returns
 +
* a string formatted for decho
 +
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to a decho string and use decho to display it
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
decho(cecho2decho(cechoString))
 +
</syntaxhighlight>
 +
 +
==cecho2hecho==
 +
 +
; convertedString = cecho2hecho(str)
 +
 +
:Converts a cecho formatted string to an hecho formatted one.
 +
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
 +
 +
{{MudletVersion|4.18}}
 +
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from cecho to decho
 +
;Returns
 +
* a string formatted for hecho
 +
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to an hecho string and use hecho to display it
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
hecho(cecho2hecho(cechoString))
 +
</syntaxhighlight>
 +
 +
==cecho2html==
 +
 +
; convertedString = cecho2html(str[, resetFormat])
 +
 +
:Converts a cecho formatted string to an html formatted one.
 +
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]
 +
 +
{{MudletVersion|4.18}}
 +
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from cecho to decho
 +
* ''resetFormat''
 +
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 +
;Returns
 +
* a string formatted for html
 +
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- create the base string
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
 +
-- create a label to display the result onto
 +
testLabel = Geyser.Label:new({name = "testLabel"})
 +
 +
-- convert the cecho string to an html one, using the default formatting of testLabel created above
 +
local htmlString = cecho2html(cechoString, testLabel:getFormat())
 +
 +
-- and finally echo it to the label to see
 +
-- I use rawEcho as that displays the html exactly as given.
 +
testLabel:rawEcho(htmlString)
 +
</syntaxhighlight>
  
 
==cechoPopup==
 
==cechoPopup==
Line 768: Line 847:
 
: Parameters to set set the window size and location - in Mudlet version 2.1 and below it's best to set them via [[Manual:Lua_Functions#moveWindow|moveWindow()]] and [[Manual:Lua_Functions#resizeWindow|resizeWindow()]], as createMiniConsole() will only set them once. Starting with Mudlet version 3.0, however, that is fine and calling createMiniConsole() will re-position your miniconsole appropriately.
 
: Parameters to set set the window size and location - in Mudlet version 2.1 and below it's best to set them via [[Manual:Lua_Functions#moveWindow|moveWindow()]] and [[Manual:Lua_Functions#resizeWindow|resizeWindow()]], as createMiniConsole() will only set them once. Starting with Mudlet version 3.0, however, that is fine and calling createMiniConsole() will re-position your miniconsole appropriately.
  
==createScrollBox==
+
;Note: Profile switching and autowrap
;createScrollBox([name of parent window], name, x, y, width, height)
+
: When using miniconsoles with autowrap enabled across multiple profiles, text may appear cut off on the right side immediately after switching profiles. This occurs because Qt's widget geometry isn't fully updated until the event loop processes visibility changes.
  
: creates a graphical elements able to hold other graphical elements such as labels, miniconsoles, command lines etc. in it.
+
: If you're implementing custom autowrap logic outside of Geyser, defer width-dependent calculations using <code>tempTimer(0, function() ... end)</code> to allow geometry updates to complete:
If the added elements don't fit into the ScrollBox scrollbars appear and allow scrolling.
 
: Returns true or false.
 
  
: See also: [[Manual:Lua_Functions#createLabel|createLabel()]], [[Manual:Lua_Functions#hideWindow|hideWindow()]], [[Manual:Lua_Functions#showWindow|showWindow()]], [[Manual:Lua_Functions#resizeWindow|resizeWindow()]], [[Manual:Lua_Functions#moveWindow|moveWindow()]], [[Manual:Lua_Functions#setWindow|setWindow()]]
+
<syntaxhighlight lang="lua">
 +
-- Example: Refreshing miniconsole wrap after profile becomes active
 +
function refreshMyConsoleWrap()
 +
  -- Defer to next event loop iteration so geometry is correct
 +
  tempTimer(0, function()
 +
    local fontWidth = calcFontSize(myConsole)
 +
    local consoleWidth = myConsole:get_width()
 +
   
 +
    -- Validate width before using
 +
    if consoleWidth >= 50 then
 +
      setWindowWrap(myConsole, math.floor(consoleWidth / fontWidth))
 +
    end
 +
  end)
 +
end
 +
</syntaxhighlight>
 +
 
 +
: Geyser's <code>Geyser.MiniConsole</code> handles this automatically as of Mudlet 4.21.
 +
 
 +
==createScrollBox==
 +
;createScrollBox([name of parent window], name, x, y, width, height)
 +
 
 +
: creates a graphical elements able to hold other graphical elements such as labels, miniconsoles, command lines etc. in it.
 +
If the added elements don't fit into the ScrollBox scrollbars appear and allow scrolling.
 +
: Returns true or false.
 +
 
 +
: See also: [[Manual:Lua_Functions#createLabel|createLabel()]], [[Manual:Lua_Functions#hideWindow|hideWindow()]], [[Manual:Lua_Functions#showWindow|showWindow()]], [[Manual:Lua_Functions#resizeWindow|resizeWindow()]], [[Manual:Lua_Functions#moveWindow|moveWindow()]], [[Manual:Lua_Functions#setWindow|setWindow()]]
  
 
{{MudletVersion|4.15}}
 
{{MudletVersion|4.15}}
Line 911: Line 1,013:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==dechoLink==
+
==decho2cecho==
;dechoLink([windowName], text, command, hint, true)
+
 
: Echos a piece of text as a clickable link, at the end of the current selected line - similar to [[Manual:Lua_Functions#decho|decho()]]. This version allows you to use colours within your link text.
+
; convertedString = decho2cecho(str)
 +
 
 +
:Converts a decho formatted string to a cecho formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''str''
: (optional) allows selection between sending the link to a miniconsole or the "main" window.
+
: string you wish to convert from decho to cecho
* ''text:''
+
;Returns
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#decho|decho()]].
+
* a string formatted for cecho
* ''command:''
 
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 
* ''hint:''
 
: text for the tooltip to be displayed when the mouse is over the link.
 
* ''true:''
 
: requires argument for the colouring to work.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- echo a link named 'press me!' that'll send the 'hi' command to the game
+
-- convert to a decho string and use cecho to display it
dechoLink("<50,50,0:0,255,0>press me!", function() send("hi") end, "This is a tooltip", true)
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
 +
cecho(decho2cecho(dechoString))
 +
</syntaxhighlight>
 +
 
 +
==decho2hecho==
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
; convertedString = decho2hecho(str)
dechoLink("<50,50,0:0,255,0>press me!", [[send("hi")]], "This is a tooltip", true)
 
</syntaxhighlight>
 
  
==dechoPopup==
+
:Converts a decho formatted string to an hecho formatted one.
;dechoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
+
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like [[#decho|decho()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
 
  
{{MudletVersion|4.1}}
+
{{MudletVersion|4.18}}
  
; Parameters
+
;Parameters
* ''windowName:''
+
* ''str''
: (optional) name of the window to echo to. Use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
+
: string you wish to convert from decho to decho
* ''text:''
+
;Returns
: the text to display
+
* a string formatted for hecho
* ''{commands}:''
+
 
: a table of lua code strings to do or a functions (since Mudlet 4.11). ie, <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
+
;Example
* ''{hints}:''
+
<syntaxhighlight lang="lua">
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
+
-- convert to an hecho string and use hecho to display it
* ''useCurrentFormatElseDefault:''
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
+
hecho(decho2hecho(dechoString))
 +
</syntaxhighlight>
 +
 
 +
==decho2html==
 +
 
 +
; convertedString = decho2html(str[, resetFormat])
 +
 
 +
:Converts a decho formatted string to an html formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from decho to decho
 +
* ''resetFormat''
 +
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 +
;Returns
 +
* a string formatted for html
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Create some text as a clickable with a popup menu:
+
-- create the base string
dechoPopup("<255,0,0>activities<r> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
-- create a label to display the result onto
dechoPopup("<255,0,0>activities<r> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
+
testLabel = Geyser.Label:new({name = "testLabel"})
</syntaxhighlight>
 
  
==dinsertLink==
+
-- convert the decho string to an html one, using the default formatting of testLabel created above
;dinsertLink([windowName], text, command, hint, true)
+
local htmlString = decho2html(dechoString, testLabel:getFormat())
: Echos a piece of text as a clickable link, at the end of the current cursor position - similar to [[#dinsertText|dinsertText()]]. This version allows you to use colours within your link text.
 
  
: See also: [[#insertLink|insertLink()]], [[#hinsertLink|hinsertLink()]]
+
-- and finally echo it to the label to see
 +
-- I use rawEcho as that displays the html exactly as given.
 +
testLabel:rawEcho(htmlString)
 +
</syntaxhighlight>
  
{{MudletVersion|4.1}}
+
==dechoLink==
 +
;dechoLink([windowName], text, command, hint, true)
 +
: Echos a piece of text as a clickable link, at the end of the current selected line - similar to [[Manual:Lua_Functions#decho|decho()]]. This version allows you to use colours within your link text.
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: optional parameter, allows selection between sending the link to a miniconsole or the main window.
+
: (optional) allows selection between sending the link to a miniconsole or the "main" window.
 
* ''text:''
 
* ''text:''
 
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#decho|decho()]].
 
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#decho|decho()]].
Line 986: Line 1,109:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
-- echo a link named 'press me!' that'll send the 'hi' command to the game
 
-- echo a link named 'press me!' that'll send the 'hi' command to the game
dinsertLink("<255,0,0>press <165,42,42:255,255,255>me!", function() send("hi") end, "This is a tooltip", true)
+
dechoLink("<50,50,0:0,255,0>press me!", function() send("hi") end, "This is a tooltip", true)
  
 
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
dinsertLink("<255,0,0>press <165,42,42:255,255,255>me!", [[send("hi")]], "This is a tooltip", true)
+
dechoLink("<50,50,0:0,255,0>press me!", [[send("hi")]], "This is a tooltip", true)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==dinsertPopup==
+
==dechoPopup==
;dinsertPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
+
;dechoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current cursor position, like [[#dinsertText|dinsertText()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
+
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like [[#decho|decho()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
  
 
{{MudletVersion|4.1}}
 
{{MudletVersion|4.1}}
Line 1,004: Line 1,127:
 
: the text to display
 
: the text to display
 
* ''{commands}:''
 
* ''{commands}:''
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
+
: a table of lua code strings to do or a functions (since Mudlet 4.11). ie, <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
 
* ''{hints}:''
 
* ''{hints}:''
: a table of strings which will be shown on the popup and right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
+
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
 
* ''useCurrentFormatElseDefault:''
 
* ''useCurrentFormatElseDefault:''
 
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
 
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Line 1,013: Line 1,136:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
-- Create some text as a clickable with a popup menu:
 
-- Create some text as a clickable with a popup menu:
dinsertPopup("<255,0,0>activities<r> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
+
dechoPopup("<255,0,0>activities<r> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
  
 
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
dinsertPopup("<255,0,0>activities<r> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
+
dechoPopup("<255,0,0>activities<r> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== deleteLabel ==
+
==dinsertLink==
; deleteLabel(labelName)
+
;dinsertLink([windowName], text, command, hint, true)
 +
: Echos a piece of text as a clickable link, at the end of the current cursor position - similar to [[#dinsertText|dinsertText()]]. This version allows you to use colours within your link text.
  
: Deletes and removes a label from the screen. Note that if you'd like to show the label again, it is much more performant to hide/show it instead.
+
: See also: [[#insertLink|insertLink()]], [[#hinsertLink|hinsertLink()]]
  
: Note that you shouldn't use the Geyser label associated with the label you delete afterwards - that doesn't make sense and Geyser right now wouldn't know that it's been deleted, either.
+
{{MudletVersion|4.1}}
  
: See also: [[#hideWindow|hideWindow()]], [[#showWindow|showWindow()]], [[#createLabel|createLabel()]]
+
;Parameters
 +
* ''windowName:''
 +
: optional parameter, allows selection between sending the link to a miniconsole or the main window.
 +
* ''text:''
 +
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#decho|decho()]].
 +
* ''command:''
 +
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 +
* ''hint:''
 +
: text for the tooltip to be displayed when the mouse is over the link.
 +
* ''true:''
 +
: requires argument for the colouring to work.
  
; Parameters
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- echo a link named 'press me!' that'll send the 'hi' command to the game
 +
dinsertLink("<255,0,0>press <165,42,42:255,255,255>me!", function() send("hi") end, "This is a tooltip", true)
  
* ''labelName'': name of the label to delete.
+
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 +
dinsertLink("<255,0,0>press <165,42,42:255,255,255>me!", [[send("hi")]], "This is a tooltip", true)
 +
</syntaxhighlight>
  
<syntaxhighlight lang="lua">
+
==dinsertPopup==
createLabel("a very basic label",300,400,100,200,1)
+
;dinsertPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
setBackgroundColor("a very basic label", 255, 204, 0, 200)
+
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current cursor position, like [[#dinsertText|dinsertText()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
 
+
 
-- delete the label after 3 seconds
+
{{MudletVersion|4.1}}
tempTimer(3, function()
+
 
  deleteLabel("a very basic label")
+
; Parameters
end)
+
* ''windowName:''
 +
: (optional) name of the window to echo to. Use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
 +
* ''text:''
 +
: the text to display
 +
* ''{commands}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
 +
* ''{hints}:''
 +
: a table of strings which will be shown on the popup and right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- Create some text as a clickable with a popup menu:
 +
dinsertPopup("<255,0,0>activities<r> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
 +
 
 +
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 +
dinsertPopup("<255,0,0>activities<r> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.5}}
+
==deleteCommandLine==
 +
 
 +
;deleteCommandLine(commandLineName)
 +
:Deletes a command line with the given name. This performs complete cleanup, removing the command line from memory and all tracking structures.
 +
 
 +
{{note}} If you are using the Geyser layout manager, use <code>myCommandLine:delete()</code> instead. This will handle proper cleanup from Geyser's internal structures.
 +
 
 +
{{note}} While disabling a command line with [[Manual:UI_Functions#disableCommandLine|disableCommandLine()]] keeps it in memory but hidden, deleting it completely removes it. Deleted command lines cannot be shown again - you would need to create a new one. It's more efficient to enable/disable command lines than to delete and recreate them if you'll need them again.
 +
 
 +
{{note}} The main command line ("main") cannot be deleted - attempting to do so will return false with an error message.
 +
 
 +
;See also: [[Manual:UI_Functions#createCommandLine|createCommandLine()]], [[Manual:UI_Functions#enableCommandLine|enableCommandLine()]], [[Manual:UI_Functions#disableCommandLine|disableCommandLine()]]
  
==deleteLine==
+
{{MudletVersion|4.20}}
;deleteLine([windowName])
 
: Deletes the current line under the user cursor. This is a high speed gagging tool and is very good at this task, but is only meant to be use when a line should be omitted entirely in the output. If you echo() to that line it will not be shown, and lines deleted with deleteLine() are simply no longer rendered. This is purely visual - triggers will still fire on the line as expected.
 
: See also: [[Manual:Lua_Functions#replace|replace()]], [[Manual:Lua_Functions#wrapLine|wrapLine()]]
 
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''commandLineName'': The name of the command line to delete. Cannot be "main".
: (optional) name of the window to delete the line in. If no name is given, it just deletes the line it is used on.
 
  
{{note}} for replacing text, [[Manual:Lua_Functions#replace|replace()]] is the proper option; doing the following: <code>selectCurrentLine(); replace(""); cecho("new line!\n")</code> is better.
+
;Returns
 +
* true on success
 +
* false and an error message if the command line doesn't exist or is "main"
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- deletes the line - just put this command into the big script box. Keep the case the same -
+
-- Create a custom command line
-- it has to be deleteLine(), not Deleteline(), deleteline() or anything else
+
createCommandLine("myCommandLine", 10, 400, 300, 30)
deleteLine()
+
 
 +
-- Later, delete it completely
 +
local success, err = deleteCommandLine("myCommandLine")
 +
if not success then
 +
  cecho(f"<red>Error: {err}\n")
 +
end
 +
 
 +
-- This will fail - cannot delete main command line
 +
local success, err = deleteCommandLine("main")
 +
-- success = false, err = "the main command line cannot be deleted"
  
--This example creates a temporary line trigger to test if the next line is a prompt, and if so gags it entirely.
+
-- With Geyser:
--This can be useful for keeping a pile of prompts from forming if you're gagging chat channels in the main window
+
local myCommandLine = Geyser.CommandLine:new({
--Note: isPrompt() only works on servers which send a GA signal with their prompt.
+
  name = "myGeyserCommandLine",
tempLineTrigger(1, 1, [[if isPrompt() then deleteLine() end]])
+
  x = 100, y = 400,
 +
  width = 300, height = 30,
 +
})
  
-- example of deleting multiple lines:
+
-- Delete it (handles all cleanup automatically)
deleteLine()                           -- delete the current line
+
myCommandLine:delete()
moveCursor(0,getLineNumber()-1)        -- move the cursor back one line
 
deleteLine()                            -- delete the previous line now
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==deselect==
+
== deleteLabel ==
;deselect([window name])
+
; deleteLabel(labelName)
: This is used to clear the current selection (to no longer have anything selected). Should be used after changing the formatting of text, to keep from accidentally changing the text again later with another formatting call.
 
: See also: [[#selectString|selectString()]], [[#selectCurrentLine|selectCurrentLine()]]
 
  
;Parameters
+
: Deletes and removes a label from the screen. Note that if you'd like to show the label again, it is much more performant to hide/show it instead.
* ''window name:''
 
: (optional) The name of the window to stop having anything selected in. If name is not provided the main window will have its selection cleared.
 
  
;Example
+
: Note that you shouldn't use the Geyser label associated with the label you delete afterwards - that doesn't make sense and Geyser right now wouldn't know that it's been deleted, either.
<syntaxhighlight lang="lua">
 
--This will change the background on an entire line in the main window to red, and then properly clear the selection to keep further
 
--changes from effecting this line as well.
 
selectCurrentLine()
 
bg("red")
 
deselect()
 
</syntaxhighlight>
 
  
==disableClickthrough==
+
: See also: [[#hideWindow|hideWindow()]], [[#showWindow|showWindow()]], [[#createLabel|createLabel()]]
; disableClickthrough(label)
 
: Disables clickthrough for a label - making it act 'normal' again and receive clicks, doubleclicks, onEnter, and onLeave events. This is the default behaviour for labels.
 
: See also: [[#enableClickthrough|enableClickthrough()]]
 
  
;Parameters
+
; Parameters
* ''label:''
 
: Name of the label to restore clickability on.
 
  
{{MudletVersion|3.17}}
+
* ''labelName'': name of the label to delete.
  
==disableCommandLine==
+
<syntaxhighlight lang="lua">
; disableCommandLine(windowName)
+
createLabel("a very basic label",300,400,100,200,1)
: Disables the command line for the miniConsole named ''windowName''
+
setBackgroundColor("a very basic label", 255, 204, 0, 200)
: See Also: [[Manual:Lua_Functions#enableCommandLine|enableCommandLine()]]
 
  
;Parameters
+
-- delete the label after 3 seconds
* ''windowName:''
+
tempTimer(3, function()
: The name of the miniConsole to disable the command line in.
+
  deleteLabel("a very basic label")
 +
end)
 +
</syntaxhighlight>
  
{{MudletVersion|4.10}}
+
{{MudletVersion|4.5}}
  
==disableHorizontalScrollBar==
+
==deleteLine==
; disableHorizontalScrollBar([windowName])
+
;deleteLine([windowName])
: Disables the horizontal scroll bar for the miniConsole/userwindow ''windowName'' or the main window
+
: Deletes the current line under the user cursor. This is a high speed gagging tool and is very good at this task, but is only meant to be use when a line should be omitted entirely in the output. If you echo() to that line it will not be shown, and lines deleted with deleteLine() are simply no longer rendered. This is purely visual - triggers will still fire on the line as expected.
: See Also: [[Manual:Lua_Functions#enableHorizontalScrollBar|enableHorizontalScrollBar()]]
+
: See also: [[Manual:Lua_Functions#replace|replace()]], [[Manual:Lua_Functions#wrapLine|wrapLine()]]
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: The name of the window to disable the scroll bar in. If "main" or not provided it is the main console.
+
: (optional) name of the window to delete the line in. If no name is given, it just deletes the line it is used on.
  
{{MudletVersion|4.10}}
+
{{note}} for replacing text, [[Manual:Lua_Functions#replace|replace()]] is the proper option; doing the following: <code>selectCurrentLine(); replace(""); cecho("new line!\n")</code> is better.
  
==disableScrollBar==
+
;Example
; disableScrollBar([windowName])
+
<syntaxhighlight lang="lua">
: Disables the scroll bar for the miniConsole/userwindow ''windowName'' or the main window
+
-- deletes the line - just put this command into the big script box. Keep the case the same -
: See Also: [[Manual:Lua_Functions#enableScrollBar|enableScrollBar()]]
+
-- it has to be deleteLine(), not Deleteline(), deleteline() or anything else
 +
deleteLine()
  
;Parameters
+
--This example creates a temporary line trigger to test if the next line is a prompt, and if so gags it entirely.
* ''windowName:''
+
--This can be useful for keeping a pile of prompts from forming if you're gagging chat channels in the main window
: (optional) The name of the window to disable the scroll bar in. If "main" or not provided it is the main console.
+
--Note: isPrompt() only works on servers which send a GA signal with their prompt.
 +
tempLineTrigger(1, 1, [[if isPrompt() then deleteLine() end]])
  
==dreplace==
+
-- example of deleting multiple lines:
;dreplace([window, ]text)
+
deleteLine()                            -- delete the current line
: Replaces the output line from the game with a colour-tagged string.
+
moveCursor(0,getLineNumber()-1)        -- move the cursor back one line
See Also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#dinsertText|dinsertText()]]
+
deleteLine()                            -- delete the previous line now
;Parameters
+
</syntaxhighlight>
* ''window:''
+
 
*: The window to replace the selection in. Optional, defaults to the main window if not provided.
+
==deleteMiniConsole==
* ''text:''
+
 
*: The text to display, as with [[Manual:Lua_Functions#decho|decho()]]
+
;deleteMiniConsole(miniConsoleName)
:
+
:Deletes a miniconsole with the given name. This performs complete cleanup, removing the miniconsole from memory and all tracking structures.
 +
 
 +
{{note}} If you are using the Geyser layout manager, use <code>myMiniConsole:delete()</code> instead. This will handle proper cleanup from Geyser's internal structures.
 +
 
 +
{{note}} While hiding a miniconsole with [[Manual:Lua_Functions#hideWindow|hideWindow()]] keeps it in memory for later use, deleting it completely removes it. Deleted miniconsoles cannot be shown again - you would need to create a new one. It's more efficient to hide/show miniconsoles than to delete and recreate them if you'll need them again.
 +
 
 +
{{note}} The "main" console cannot be deleted.
 +
 
 +
;See also: [[Manual:Lua_Functions#createMiniConsole|createMiniConsole()]], [[Manual:Lua_Functions#createConsole|createConsole()]], [[Manual:Lua_Functions#hideWindow|hideWindow()]], [[Manual:Lua_Functions#showWindow|showWindow()]]
  
;Example
+
{{MudletVersion|4.20}}
<syntaxhighlight lang="lua">
 
    selectCaptureGroup(1)
 
    dreplace("<255,0,255>[ALERT!]: <r>"..matches[2])
 
</syntaxhighlight>
 
  
==dreplaceLine==
 
;dreplaceLine ([window], text)
 
: Replaces the output line from the game with a colour-tagged string.
 
{{MudletVersion|4.12}}
 
See Also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#dinsertText|dinsertText()]]
 
 
;Parameters
 
;Parameters
* ''window'' (optional):
+
* ''miniConsoleName'': The name of the miniconsole to delete.
the window to copy the text from. Defaults to "main".
+
 
* ''text:''
+
;Returns
*: The text to display, with RGB color values inside angle brackets <>, ie ''<128,0,0>''. If you'd like to use a background color, put it after a colon : - ''<:128,0,0>''. You can use the ''<r>'' tag to reset to the default color.
+
* true on success
:
+
* false and an error message if the miniconsole doesn't exist
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">dreplaceLine("<255,0,255>[ALERT!]: <r>"..line)
+
<syntaxhighlight lang="lua">
</syntaxhighlight>
+
-- Create a miniconsole
 +
createMiniConsole("myConsole", 10, 10, 300, 200)
 +
echo("myConsole", "Hello, World!")
  
==echoLink==
+
-- Later, delete it completely
;echoLink([windowName], text, command, hint, [useCurrentFormatElseDefault])
+
local success, err = deleteMiniConsole("myConsole")
: Echos a piece of text as a clickable link, at the end of the current selected line - similar to [[Manual:Lua_Functions#echo|echo()]].
+
if not success then
 +
  cecho(f"<red>Error: {err}\n")
 +
end
  
: See also: [[#cechoLink|cechoLink()]], [[#hechoLink|hechoLink()]]
+
-- With Geyser:
 +
local myConsole = Geyser.MiniConsole:new({
 +
  name = "myGeyserConsole",
 +
  x = 100, y = 100,
 +
  width = 300, height = 200,
 +
})
  
;Parameters
+
-- Delete it (handles all cleanup automatically)
* ''windowName:''
+
myConsole:delete()
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
+
</syntaxhighlight>
* ''text:''
 
: Text to display in the echo. Same as a normal echo().
 
* ''command:''
 
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 
* ''hint:''
 
: Text for the tooltip to be displayed when the mouse is over the link.
 
* ''useCurrentFormatElseDefault:''
 
: If true, then the link will use the current selection style (colors, underline, etc). If missing or false, it will use the default link style - blue on black underlined text.
 
  
;Example
+
==deleteMultiline==
<syntaxhighlight lang="lua">
 
-- echo a link named 'press me!' that'll send the 'hi' command to the game
 
echoLink("press me!", function() send("hi") end, "This is a tooltip")
 
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 
echoLink("press me!", [[send("hi")]], "This is a tooltip")
 
  
-- do the same, but send this link to a miniConsole
+
; ok,err = deleteMultiline([triggerDelta])
echoLink("my miniConsole", "press me!", function() send("hi") end, "This is a tooltip")
 
</syntaxhighlight>
 
  
{{note}} The ''hint'' can contain the same sort of "rich-text" as can be used for "labels" - and if the ''command'' is set to be the empty string ''""'' then this can be a means to show extra information for the text when the mouse is hovered over it but without a command being run should it be clicked upon, e.g.:
+
:Deletes all lines between when the multiline trigger fires and when the first trigger matched. Put another way, it deletes everything since the pattern in slot 1 matched.
 +
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]
  
[[File:Screenshot showing example of fancy visual link.png|center|frame|link=|Screenshot showing example of fancy visual link]]
+
{{MudletVersion|4.18}}
  
==echoUserWindow==
+
{{note}} This deletes all the lines since the first match of the multiline trigger matched. Do not use this if you do not want to delete ALL of those lines.
;echoUserWindow(windowName, text)
 
:This function will print text to both mini console windows, dock windows and labels. It is outdated however - [[Manual:Lua_Functions#echo|echo()]] instead.
 
  
==echoPopup==
+
;Parameters
;echoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
+
* ''[optional]triggerDelta:''
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
+
: The line delta from the multiline trigger it is being called from. It is best to pass this in to ensure all lines are caught. If not given it will try to guess based on the number of patterns how many lines at most it might have to delete.
  
; Parameters
+
;Returns
* ''windowName:''
+
* true if the function was able to run successfully, nil+error if something went wrong.
: (optional) name of the window to echo to. Use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
 
* ''text:''
 
: the text to display
 
* ''{commands}:''
 
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
 
* ''{hints}:''
 
: a table of strings which will be shown on the popup and right-click menu. i.e. <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
 
* ''useCurrentFormatElseDefault:''
 
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Create some text as a clickable with a popup menu:
+
-- if this trigger has a line delta of 3, you would call
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
+
deleteMultiline(3)
  
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
+
-- same thing, but with error handling
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
+
local ok,err = deleteMultiline(3)
 +
if not ok then
 +
  cecho("\n<firebrick>I could not delete the lines because: " .. err)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==enableClickthrough==
+
; Additional development notes
; enableClickthrough(label)
+
 
: Make a label 'invisible' to clicks - so if you have another label underneath, it'll be clicked on instead of this one on top.
+
==deleteScrollBox==
: This affects clicks, double-clicks, right-clicks, as well as the onEnter/onLeave events.
+
 
: See also: [[#disableClickthrough|disableClickthrough()]]
+
;deleteScrollBox(scrollBoxName)
 +
:Deletes a scrollbox with the given name. This performs complete cleanup, removing the scrollbox and all its contents from memory and tracking structures.
 +
 
 +
{{note}} If you are using the Geyser layout manager, use <code>myScrollBox:delete()</code> instead. This will handle proper cleanup from Geyser's internal structures.
  
;Parameters
+
{{note}} While hiding a scrollbox with [[Manual:Lua_Functions#hideWindow|hideWindow()]] keeps it in memory for later use, deleting it completely removes it. Deleted scrollboxes cannot be shown again - you would need to create a new one. It's more efficient to hide/show scrollboxes than to delete and recreate them if you'll need them again.
* ''label:''
 
: The name of the label to enable clickthrough on.
 
  
{{MudletVersion|3.17}}
+
;See also: [[Manual:Lua_Functions#createScrollBox|createScrollBox()]]
  
==enableCommandLine==
+
{{MudletVersion|4.20}}
; enableCommandLine(windowName)
 
: Enables the command line for the miniConsole named ''windowName''
 
: See Also: [[Manual:Lua_Functions#disableCommandLine|disableCommandLine()]]
 
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''scrollBoxName'': The name of the scrollbox to delete.
: The name of the miniConsole to enable the command line in.
 
  
{{note}} The command line name is the same as the miniConsole name
+
;Returns
 +
* true on success
 +
* false and an error message if the scrollbox doesn't exist
  
{{MudletVersion|4.10}}
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- Create a scrollbox
 +
createScrollBox("myScrollBox", 10, 10, 300, 400)
  
==enableHorizontalScrollBar==
+
-- Later, delete it completely
; enableHorizontalScrollBar([windowName])
+
local success, err = deleteScrollBox("myScrollBox")
: Enables the horizontal scroll bar for the miniConsole/userwindow ''windowName'' or the main window
+
if not success then
: See Also: [[Manual:Lua_Functions#disableHorizontalScrollBar|disableHorizontalScrollBar()]]
+
  cecho(f"<red>Error: {err}\n")
 +
end
  
;Parameters
+
-- With Geyser:
* ''windowName:''
+
local myScrollBox = Geyser.ScrollBox:new({
: The name of the window to enable the scroll bar in. If "main" or not provided it is the main console.
+
  name = "myGeyserScrollBox",
 +
  x = 100, y = 100,
 +
  width = 300, height = 400,
 +
})
  
{{MudletVersion|4.10}}
+
-- Delete it (handles all cleanup automatically)
 +
myScrollBox:delete()
 +
</syntaxhighlight>
  
==enableScrollBar==
+
==deselect==
; enableScrollBar([windowName])
+
;deselect([window name])
: Enables the scroll bar for the miniConsole/userwindow ''windowName'' or the main window
+
: This is used to clear the current selection (to no longer have anything selected). Should be used after changing the formatting of text, to keep from accidentally changing the text again later with another formatting call.
: See Also: [[Manual:Lua_Functions#disableScrollBar|disableScrollBar()]]
+
: See also: [[#selectString|selectString()]], [[#selectCurrentLine|selectCurrentLine()]]
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''window name:''
: The name of the window to enable the scroll bar in. If "main" or not provided it is the main console.
+
: (optional) The name of the window to stop having anything selected in. If name is not provided the main window will have its selection cleared.
 
 
==fg==
 
; fg([window], colorName)
 
: If used on a selection, sets the foreground color to ''colorName'' - otherwise, it will set the color of the next text-inserting calls (''echo(), insertText, echoLink()'', and others)
 
: See Also: [[Manual:Lua_Functions#bg|bg()]], [[Manual:Lua_Functions#setBgColor|setBgColor()]]
 
 
 
;Parameters
 
* ''window:''
 
: (optional) name of the miniconsole to operate on. If you'd like it to work on the main window, don't specify anything or use ''main'' (since Mudlet 3.0).
 
* ''colorName:''
 
: The name of the color to set the foreground to - list of possible names: [[File:ShowColors.png|50px|frameless|Color Table]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--This would change the color of the text on the current line to green
+
--This will change the background on an entire line in the main window to red, and then properly clear the selection to keep further
 +
--changes from effecting this line as well.
 
selectCurrentLine()
 
selectCurrentLine()
fg("green")
+
bg("red")
resetFormat()
+
deselect()
 
 
--This will echo red, green, blue in their respective colors
 
fg("red")
 
echo("red ")
 
fg("green")
 
echo("green ")
 
fg("blue")
 
echo("blue ")
 
resetFormat()
 
 
 
-- example of working on a miniconsole
 
fg("my console", "red")
 
echo("my console", "red text")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getAvailableFonts==
+
==disableClickthrough==
; getAvailableFonts()
+
; disableClickthrough(label)
: This returns a "font - true" key-value list of available fonts which you can use to verify that Mudlet has access to a given font.
+
: Disables clickthrough for a label - making it act 'normal' again and receive clicks, doubleclicks, onEnter, and onLeave events. This is the default behaviour for labels.
: To install a new font with your package, include the font file in your zip/mpackage and it'll be automatically installed for you.
+
: See also: [[#enableClickthrough|enableClickthrough()]]
  
: See also: [[#getFont|getFont()]], [[#setFont|setFont()]]
+
;Parameters
 +
* ''label:''
 +
: Name of the label to restore clickability on.
  
{{MudletVersion|3.10}}
+
{{MudletVersion|3.17}}
  
;Example
+
==disableCommandLine==
<syntaxhighlight lang="lua">
+
; disableCommandLine(windowName)
-- check if Ubuntu Mono is a font we can use
+
: Disables the command line for the miniConsole named ''windowName''
if getAvailableFonts()["Ubuntu Mono"] then
+
: See Also: [[Manual:Lua_Functions#enableCommandLine|enableCommandLine()]]
  -- make the miniconsole use the font at size 16
 
  setFont("my miniconsole", "Ubuntu Mono")
 
  setFontSize("my miniconsole", 16)
 
end
 
</syntaxhighlight>
 
 
 
==getBackgroundColor==
 
;getBackgroundColor([windowName])
 
: Gets the background for the given label, miniconsole, or userwindow.
 
: Returns 4 values - red, green, blue, transparency. Colors returned are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
 
  
 
;Parameters
 
;Parameters
 +
* ''windowName:''
 +
: The name of the miniConsole to disable the command line in.
  
* ''windowName:''
+
{{MudletVersion|4.10}}
: (optional) name of the label/miniconsole/userwindow to getthe background color from, or "main" for the main window.
 
  
: {{MudletVersion|4.15}}
+
==disableHorizontalScrollBar==
 +
; disableHorizontalScrollBar([windowName])
 +
: Disables the horizontal scroll bar for the miniConsole/userwindow ''windowName'' or the main window
 +
: See Also: [[Manual:Lua_Functions#enableHorizontalScrollBar|enableHorizontalScrollBar()]]
  
;Example
+
;Parameters
<syntaxhighlight lang="lua">
+
* ''windowName:''
local r, g, b, a = getBackgroundColor()
+
: The name of the window to disable the scroll bar in. If "main" or not provided it is the main console.
local rW, gW, bW, aW = getBackgroundColor("myWindow")
 
</syntaxhighlight>
 
  
==getBgColor==
+
{{MudletVersion|4.10}}
; getBgColor(windowName)
 
: This function returns the rgb values of the background color of the first character of the current selection on mini console (window) windowName. If windowName is omitted Mudlet will use the main screen.
 
  
: See also: [[#setBgColor|setBgColor()]]
+
==disableScrollBar==
 +
; disableScrollBar([windowName])
 +
: Disables the scroll bar for the miniConsole/userwindow ''windowName'' or the main window
 +
: See Also: [[Manual:Lua_Functions#enableScrollBar|enableScrollBar()]]
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: A window to operate on - either a miniconsole or the main window.
+
: (optional) The name of the window to disable the scroll bar in. If "main" or not provided it is the main console.
  
;Example
+
==disableScrolling==
<syntaxhighlight lang="lua">
+
;disableScrolling([windowName])
local r,g,b;
+
: Disables whether the split-screen bar is shown while scrolling in a miniconsole.
selectString("troll",1)
 
r,g,b = getBgColor()
 
if r == 255 and g == 0 and b == 0 then
 
    echo("HELP! troll is highlighted in red letters, the monster is aggressive!\n");
 
end
 
</syntaxhighlight>
 
  
==getBorderBottom==
+
;Parameters
;getBorderBottom()
+
* ''windowName:''
: Returns the size of the bottom border of the main window in pixels.  
+
: The name of the miniconsole window to disable the split-screen bar. "main" is not a valid option.
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderBottom|setBorderBottom()]]
 
  
: {{MudletVersion|4.0}}
+
==dreplace==
 +
;dreplace([window, ]text)
 +
: Replaces the output line from the game with a colour-tagged string.
 +
See Also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#dinsertText|dinsertText()]]
 +
;Parameters
 +
* ''window:''
 +
*: The window to replace the selection in. Optional, defaults to the main window if not provided.
 +
* ''text:''
 +
*: The text to display, as with [[Manual:Lua_Functions#decho|decho()]]
 +
:
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">
+
<syntaxhighlight lang="lua">
setBorderBottom(150)
+
    selectCaptureGroup(1)
getBorderBottom()
+
    dreplace("<255,0,255>[ALERT!]: <r>"..matches[2])
-- returns: 150
+
</syntaxhighlight>
</syntaxhighlight>
 
  
==getBorderLeft==
+
==dreplaceLine==
;getBorderLeft()
+
;dreplaceLine ([window], text)
: Returns the size of the left border of the main window in pixels.  
+
: Replaces the output line from the game with a colour-tagged string.
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderLeft|setBorderLeft()]]
+
{{MudletVersion|4.12}}
 +
See Also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#dinsertText|dinsertText()]]
 +
;Parameters
 +
* ''window'' (optional):
 +
:  the window to copy the text from. Defaults to "main".
 +
* ''text:''
 +
*: The text to display, with RGB color values inside angle brackets <>, ie ''<128,0,0>''. If you'd like to use a background color, put it after a colon : - ''<:128,0,0>''. You can use the ''<r>'' tag to reset to the default color.
 +
:
  
: {{MudletVersion|4.0}}
+
;Example
 +
<syntaxhighlight lang="lua">dreplaceLine("<255,0,255>[ALERT!]: <r>"..line)
 +
</syntaxhighlight>
  
;Example
+
==echoLink==
<syntaxhighlight lang="lua">
+
;echoLink([windowName], text, command, hint, [useCurrentFormatElseDefault])
setBorderLeft(5)
+
: Echos a piece of text as a clickable link, at the end of the current selected line - similar to [[Manual:Lua_Functions#echo|echo()]].
getBorderLeft()
 
-- returns: 5
 
</syntaxhighlight>
 
  
==getBorderRight==
+
: See also: [[#cechoLink|cechoLink()]], [[#hechoLink|hechoLink()]]
;getBorderRight()
 
: Returns the size of the right border of the main window in pixels.
 
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderRight|setBorderRight()]]
 
  
: {{MudletVersion|4.0}}
+
;Parameters
 +
* ''windowName:''
 +
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
 +
* ''text:''
 +
: Text to display in the echo. Same as a normal echo().
 +
* ''command:''
 +
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 +
* ''hint:''
 +
: Text for the tooltip to be displayed when the mouse is over the link.
 +
* ''useCurrentFormat:''
 +
: If true, then the link will use the current selection style (colors, underline, etc). If missing or false, it will use the default link style - blue on black underlined text.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setBorderRight(50)
+
-- echo a link named 'press me!' that'll send the 'hi' command to the game
getBorderRight()
+
echoLink("press me!", function() send("hi") end, "This is a tooltip")
-- returns: 50
+
 
</syntaxhighlight>
+
-- want to capture a value, say from matches?
 +
local thing = matches[2]
 +
echolink(" Yes!", f[[echo("Captured {matches[2]}\n")]], f"Click on {thing}")
  
==getBorderSizes==
+
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
;getBorderSizes()
+
echoLink("press me!", [[send("hi")]], "This is a tooltip")
: Returns the a named table with the sizes of all borders of the main window in pixels.
 
: See also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#getBorderTop|getBorderTop()]], [[Manual:Lua_Functions#getBorderRight|getBorderRight()]],[[Manual:Lua_Functions#getBorderBottom|getBorderBottom()]], [[Manual:Lua_Functions#getBorderLeft|getBorderLeft()]]
 
  
: {{MudletVersion|4.0}}
+
-- do the same, but send this link to a miniConsole
 +
echoLink("my miniConsole", "press me!", function() send("hi") end, "This is a tooltip")
  
;Example
+
--  
<syntaxhighlight lang="lua">
 
setBorderSizes(100, 50, 150, 0)
 
getBorderSizes()
 
-- returns: { top = 100, right = 50, bottom = 150, left = 0 }
 
getBorderSizes().right
 
-- returns: 50
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getBorderTop==
+
{{note}} The ''hint'' can contain the same sort of "rich-text" as can be used for "labels" - and if the ''command'' is set to be the empty string ''""'' then this can be a means to show extra information for the text when the mouse is hovered over it but without a command being run should it be clicked upon, e.g.:
;getBorderTop()
+
 
: Returns the size of the top border of the main window in pixels.  
+
[[File:Screenshot showing example of fancy visual link.png|center|frame|link=|Screenshot showing example of fancy visual link]]
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderTop|setBorderTop()]]
 
  
: {{MudletVersion|4.0}}
+
==echoUserWindow==
 +
;echoUserWindow(windowName, text)
 +
:This function will print text to both mini console windows, dock windows and labels. It is outdated however - [[Manual:Lua_Functions#echo|echo()]] instead.
  
;Example
+
==echoPopup==
<syntaxhighlight lang="lua">
 
setBorderTop(100)
 
getBorderTop()
 
-- returns: 100
 
</syntaxhighlight>
 
  
==getClipboardText==
+
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])
;getClipboardText()
+
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if there is one extra hint then the first one will be used as a (maybe containing Qt rich-text markup) tool-tip for the text otherwise the remaining hints will be concatenated, one-per-line, as a tool-tip when the text is hovered over by the pointer.
: Returns any text that is currently present in the clipboard.  
 
: See also: [[#setClipboardText | setClipboardText()]]
 
  
: {{note}} Note: Available in Mudlet 4.10+
+
; Parameters
 +
* ''windowName:''
 +
: (optional) name of the window as a string to echo to. Use either ''main'' or omit for the main window, or the miniconsole's or user-window's name otherwise.
 +
* ''text:''
 +
: the text string to display.
 +
* ''{commands}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>.
 +
* ''{hints}:''
 +
: a table of strings which will be shown on the right-click menu and as a tool-tip for the ''text''. If the number is the same as that of the ''commands'' table then they all will be used for the right-click menu and listed (one per line) as a plain text tooltip; alternatively if there is one extra in number than the ''commands'' table the first will be used purely for the tool tip and the remainder will be used for the right-click menu. This additional entry may be formatted as Qt style "rich-text" (in the same manner as labels elsewhere in the GUI).
 +
::* If a particular position in the ''commands'' table is an empty string ''""'' but there is something in the ''hints'' table then it will be listed in the right-click menu but as it does not do anything it will be shown ''greyed-out'' i.e. disabled and will not be clickable.
 +
::* If a particular position in '''both''' the ''commands'' and the ''hints'' table are empty strings ''""'' then this item will show as a ''separator'' (usually as a horizontal-line) in the right-click menu and it will not be clickable/do anything.
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if ''true'' or the link default (blue underline) if ''false'', if omitted the default format is used.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local clipboardContents = getClipboardText()
+
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
echo("Clipboard: " .. clipboardContents)
+
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
</syntaxhighlight>
 
  
==getColorWildcard==
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
; getColorWildcard(ansi color number)
+
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
: This function, given an ANSI color number ([[Manual:UI_Functions#isAnsiFgColor|list]]), will return all strings on the current line that match it.
 
  
: See also: [[#isAnsiFgColor|isAnsiFgColor()]],  [[#isAnsiBgColor|isAnsiBgColor()]]
+
-- one can also provide helpful information
  
;Parameters
+
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!
* ''ansi color number:''
+
echoPopup("Fancy popup", {[[echo("Doing command 1 (default one)")]], "", "", [[echo("Doing command 3")]], [[echo("Doing another command (number 4)"]], [[echo("Doing another command (number 5)"]]}, {"<p>This tooltip has HTML type tags in/around it, and it will get word-wrapped automatically to fit into a reasonable rectangle.</p><p><b>Plus</b> it can have those HTML like <i>effects</i> and be easily formatted into more than one paragraph and with <span style=\"color:cyan\">bits</span> in <span style=\"color:lime\">different</span> colors!</p><p>This example also demonstrates how to produce disabled menu (right-click) items, how to insert separators and how it now will handle multiple items with the same hint (prior to PR 6945 such duplicates will all run the command associated with the last one!) If the first command/function is an empty string then clicking on the text will have no effect, but hovering the mouse over the text will still produce the tooltip, this could be useful to display extra information about the text without doing anything by default.</p>", "Command 1 (default)", "", "Command 2 (disabled)", "Command 3", "Another command", "Another command"}, true)
: A color number ([[Manual:UI_Functions#isAnsiFgColor|list]]) to match.
+
echo(" remaining text.\n")
  
;Example
 
<syntaxhighlight lang="lua">
 
-- we can run this script on a line that has the players name coloured differently to easily capture it from
 
-- anywhere on the line
 
local match = getColorWildcard(14) -- this will be a table of every match
 
 
if match then -- if there's a table, then we try and print it on the screen!
 
  echo("\nFound "..table.concat(match, ", ").."!") -- this will combine all captured strings and separate them with a comma so it's easy to read.
 
else -- if there isn't something in match, then we haven't found anything to print on the screen!
 
  echo("\nDidn't find anyone.")
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getColumnCount==
+
==enableClickthrough==
;getColumnCount([windowName])
+
; enableClickthrough(label)
: Gets the maximum number of columns (characters) that a given window can display on a single row, taking into consideration factors such as window width, font size, spacing, etc.
+
: Make a label 'invisible' to clicks - so if you have another label underneath, it'll be clicked on instead of this one on top.
 +
: This affects clicks, double-clicks, right-clicks, as well as the onEnter/onLeave events.
 +
: See also: [[#disableClickthrough|disableClickthrough()]]
  
;Parameters:
+
;Parameters
* ''windowName'':
+
* ''label:''
: (optional) name of the window whose number of columns we want to calculate. By default it operates on the main window.
+
: The name of the label to enable clickthrough on.
  
{{MudletVersion|3.7}}
+
{{MudletVersion|3.17}}
  
;Example
+
==enableCommandLine==
<syntaxhighlight lang="lua">
+
; enableCommandLine(windowName)
print("Maximum number of columns on the main window "..getColumnCount())
+
: Enables the command line for the miniConsole named ''windowName''
</syntaxhighlight>
+
: See Also: [[Manual:Lua_Functions#disableCommandLine|disableCommandLine()]]
 
 
==getColumnNumber==
 
;getColumnNumber([windowName])
 
: Gets the absolute column number of the current user cursor.
 
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
+
: The name of the miniConsole to enable the command line in.
  
{{note}} the argument is available since Mudlet 3.0.
+
{{note}} The command line name is the same as the miniConsole name
  
;Example
+
{{MudletVersion|4.10}}
<syntaxhighlight lang="lua">
 
HelloWorld = Geyser.MiniConsole:new({
 
  name="HelloWorld",
 
  x="70%", y="50%",
 
  width="30%", height="50%",
 
})
 
  
HelloWorld:echo("hello!\n")
+
==enableHorizontalScrollBar==
HelloWorld:echo("hello!\n")
+
; enableHorizontalScrollBar([windowName])
HelloWorld:echo("hello!\n")
+
: Enables the horizontal scroll bar for the miniConsole/userwindow ''windowName'' or the main window
 +
: See Also: [[Manual:Lua_Functions#disableHorizontalScrollBar|disableHorizontalScrollBar()]]
  
moveCursor("HelloWorld", 3, getLastLineNumber("HelloWorld"))
+
;Parameters
-- should say 3, because we moved the cursor in the HellWorld window to the 3rd position in the line
+
* ''windowName:''
print("getColumnNumber: "..tostring(getColumnNumber("HelloWorld")))
+
: The name of the window to enable the scroll bar in. If "main" or not provided it is the main console.
  
moveCursor("HelloWorld", 1, getLastLineNumber("HelloWorld"))
+
{{MudletVersion|4.10}}
-- should say 3, because we moved the cursor in the HellWorld window to the 1st position in the line
 
print("getColumnNumber: "..tostring(getColumnNumber("HelloWorld")))
 
</syntaxhighlight>
 
  
==getCurrentLine==
+
==enableScrollBar==
;getCurrentLine([windowName])
+
; enableScrollBar([windowName])
: Returns the content of the current line under the user cursor in the buffer. The Lua variable '''line''' holds the content of ''getCurrentLine()'' before any triggers have been run on this line. When triggers change the content of the buffer, the variable line will not be adjusted and thus hold an outdated string. ''line = getCurrentLine()'' will update line to the real content of the current buffer. This is important if you want to copy the current line after it has been changed by some triggers. ''selectString( line,1 )'' will return false and won't select anything because line no longer equals ''getCurrentLine()''. Consequently, ''selectString( getCurrentLine(), 1 )'' is what you need.
+
: Enables the scroll bar for the miniConsole/userwindow ''windowName'' or the main window
 +
: See Also: [[Manual:Lua_Functions#disableScrollBar|disableScrollBar()]]
  
; Parameters
+
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: (optional) name of the window in which to select text.
+
: The name of the window to enable the scroll bar in. If "main" or not provided it is the main console.
 
 
;Example
 
<syntaxhighlight lang="lua">
 
print("Currently selected line: "..getCurrentLine())
 
</syntaxhighlight>
 
  
==getFgColor==
+
==enableScrolling==
; getFgColor(windowName)
+
;enableScrolling([windowName])
: This function returns the rgb values of the color of the first character of the current selection on mini console (window) windowName. If windowName is omitted Mudlet will use the main screen.
+
: Enables whether the split-screen bar is shown while scrolling in a miniconsole.
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: A window to operate on - either a miniconsole or the main window.
+
: The name of the miniconsole window to enable the split-screen bar. "main" is not a valid option.
  
;Example
+
==fg==
<syntaxhighlight lang="lua">
+
; fg([window], colorName)
selectString("troll",1)
+
: If used on a selection, sets the foreground color to ''colorName'' - otherwise, it will set the color of the next text-inserting calls (''echo(), insertText, echoLink()'', and others)
local r,g,b = getFgColor()
+
: See Also: [[Manual:Lua_Functions#bg|bg()]], [[Manual:Lua_Functions#setBgColor|setBgColor()]]
if r == 255 and g == 0 and b == 0 then
 
  echo("HELP! troll is written in red letters, the monster is aggressive!\n")
 
end
 
</syntaxhighlight>
 
 
 
==getFont==
 
;getFont([windowName])
 
: Gets the current font of the given window or console name. Can be used to get font of the main console, dockable userwindows and miniconsoles.
 
: See also: [[#setFont|setFont()]], [[#setFontSize|setFontSize()]], [[#openUserWindow|openUserWindow()]], [[#getAvailableFonts|getAvailableFonts()]]
 
 
 
{{MudletVersion|3.4}}
 
{{note}} Since Mudlet 3.10, returns the actual font that was used in case you didn't have the required font when using [[#setFont|setFont()]].
 
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''window:''
: The window name to get font size of - can either be none or "main" for the main console, or a miniconsole/userwindow name.
+
: (optional) name of the miniconsole to operate on. If you'd like it to work on the main window, don't specify anything or use ''main'' (since Mudlet 3.0).
 +
* ''colorName:''
 +
: The name of the color to set the foreground to - list of possible names: [[File:ShowColors.png|50px|frameless|Color Table]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- The following will get the "main" console font size.
+
--This would change the color of the text on the current line to green
display("Font in the main window: "..getFont())
+
selectCurrentLine()
 +
fg("green")
 +
resetFormat()
  
display("Font in the main window: "..getFont("main"))
+
--This will echo red, green, blue in their respective colors
 +
fg("red")
 +
echo("red ")
 +
fg("green")
 +
echo("green ")
 +
fg("blue")
 +
echo("blue ")
 +
resetFormat()
  
-- This will get the font size of a user window named "user window awesome".
+
-- example of working on a miniconsole
display("Font size: " .. getFont("user window awesome"))
+
fg("my console", "red")
 +
echo("my console", "red text")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getFontSize==
+
==getAvailableFonts==
;getFontSize([windowName])
+
; getAvailableFonts()
: Gets the current font size of the given window or console name. Can be used to get font size of the Main console as well as dockable UserWindows.
+
: This returns a "font - true" key-value list of available fonts which you can use to verify that Mudlet has access to a given font.
: See also: [[#setFontSize|setFontSize()]], [[#openUserWindow|openUserWindow()]]
+
: To install a new font with your package, include the font file in your zip/mpackage and it'll be automatically installed for you.
  
;Parameters
+
: See also: [[#getFont|getFont()]], [[#setFont|setFont()]]
* ''windowName:''
 
: The window name to get font size of - can either be none or "main" for the main console, or a UserWindow name.
 
  
{{MudletVersion|3.4}}
+
{{MudletVersion|3.10}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- The following will get the "main" console font size.
+
-- check if Ubuntu Mono is a font we can use
local mainWindowFontSize = getFontSize()
+
if getAvailableFonts()["Ubuntu Mono"] then
if mainWindowFontSize then
+
  -- make the miniconsole use the font at size 16
    display("Font size: " .. mainWindowFontSize)
+
  setFont("my miniconsole", "Ubuntu Mono")
 +
  setFontSize("my miniconsole", 16)
 
end
 
end
 +
</syntaxhighlight>
  
local mainWindowFontSize = getFontSize("main")
+
==getBackgroundColor==
if mainWindowFontSize then
+
;getBackgroundColor([windowName])
    display("Font size: " .. fs2)
+
: Gets the background for the given label, miniconsole, or userwindow.
end
+
: Returns 4 values - red, green, blue, transparency. Colors returned are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
  
-- This will get the font size of a user window named "user window awesome".
+
;Parameters
local awesomeWindowFontSize = getFontSize("user window awesome")
+
 
if awesomeWindowFontSize then
+
* ''windowName:''
    display("Font size: " .. awesomeWindowFontSize)
+
: (optional) name of the label/miniconsole/userwindow to getthe background color from, or "main" for the main window.
end
 
</syntaxhighlight>
 
  
==getHTMLformat==
+
: {{MudletVersion|4.15}}
;spanTag = getHTMLformat(formatTable)
 
  
:Takes in a table of formatting options in the same style as [[Manual:Lua_Functions#getTextFormat|getTextFormat()]] and returns a span tag which will format text after it as the table describes.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
local r, g, b, a = getBackgroundColor()
 +
local rW, gW, bW, aW = getBackgroundColor("myWindow")
 +
</syntaxhighlight>
  
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
+
==getBgColor==
 +
; getBgColor(windowName)
 +
: This function returns the rgb values of the background color of the first character of the current selection on mini console (window) windowName. If windowName is omitted Mudlet will use the main screen.
  
{{MudletVersion|4.15}}
+
: See also: [[#setBgColor|setBgColor()]]
  
 
;Parameters
 
;Parameters
*''formatTable:''
+
* ''windowName:''
:Table with formatting options configured. Keys are foreground, background, bold, underline, overline, strikeout, italic, and reverse. All except for foreground and background should be boolean (true/false) values. Foreground and background are either { r, g, b, a } tables, or strings with QSS formatting directives
+
: A window to operate on - either a miniconsole or the main window.
 
 
;Returns
 
*A string with the html span tag to format text in accordance with the format table.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Returns a span tag for bold, red text on a green background
+
local r,g,b;
local span = getHTMLformat({
+
selectString("troll",1)
  foreground = { 255, 0, 0 },
+
r,g,b = getBgColor()
  background = "#00FF00",
+
if r == 255 and g == 0 and b == 0 then
  bold = true
+
    echo("HELP! troll is highlighted in red letters, the monster is aggressive!\n");
})
+
end
 
 
-- span will be '<span style="color: rgb(255, 0, 0);background-color: #00FF00; font-weight: bold; font-style: normal; text-decoration: none;">'
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getImageSize==
+
==getBorderBottom==
;getImageSize(imageLocation)
+
;getBorderBottom()
: Returns the width and the height of the given image. If the image can't be found, loaded, or isn't a valid image file - nil+error message will be returned instead.
+
: Returns the size of the bottom border of the main window in pixels.  
: See also: [[#createLabel|createLabel()]]
+
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderBottom|setBorderBottom()]]
  
;Parameters
+
: {{MudletVersion|4.0}}
* ''imageLocation:''
 
: Path to the image.
 
 
 
{{MudletVersion|4.5}}
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local path = getMudletHomeDir().."/my-image.png"
+
setBorderBottom(150)
 +
getBorderBottom()
 +
-- returns: 150
 +
</syntaxhighlight>
  
cecho("Showing dimensions of the picture in: "..path.."\n")
+
==getBorderLeft==
 +
;getBorderLeft()
 +
: Returns the size of the left border of the main window in pixels.
 +
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderLeft|setBorderLeft()]]
  
local width, height = getImageSize(path)
+
: {{MudletVersion|4.0}}
  
if not width then
+
;Example
  -- in case of an problem, we don't get a height back - but the error message
+
<syntaxhighlight lang="lua">
  cecho("error: "..height.."\n")
+
setBorderLeft(5)
else
+
getBorderLeft()
  cecho(string.format("They are: %sx%s", width, height))
+
-- returns: 5
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getLabelFormat==
+
==getBorderRight==
;formatTable = getLabelFormat(labelName)
+
;getBorderRight()
 +
: Returns the size of the right border of the main window in pixels.
 +
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderRight|setBorderRight()]]
  
: Returns a format table like the one returned by getTextFormat and suitable for getHTMLformat which will format text the same way as simply doing an echo to the label would
+
: {{MudletVersion|4.0}}
  
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getHTMLformat|getHTMLformat()]]
+
;Example
 +
<syntaxhighlight lang="lua">
 +
setBorderRight(50)
 +
getBorderRight()
 +
-- returns: 50
 +
</syntaxhighlight>
 +
 
 +
==getBorderSizes==
 +
;getBorderSizes()
 +
: Returns the a named table with the sizes of all borders of the main window in pixels.
 +
: See also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#getBorderTop|getBorderTop()]], [[Manual:Lua_Functions#getBorderRight|getBorderRight()]],[[Manual:Lua_Functions#getBorderBottom|getBorderBottom()]], [[Manual:Lua_Functions#getBorderLeft|getBorderLeft()]]
 +
 
 +
: {{MudletVersion|4.0}}
  
{{MudletVersion|4.15}}
+
;Example
 +
<syntaxhighlight lang="lua">
 +
setBorderSizes(100, 50, 150, 0)
 +
getBorderSizes()
 +
-- returns: { top = 100, right = 50, bottom = 150, left = 0 }
 +
getBorderSizes().right
 +
-- returns: 50
 +
</syntaxhighlight>
  
;Parameters
+
==getBorderTop==
*''labelName:''
+
;getBorderTop()
: The name of the label to scan the format of
+
: Returns the size of the top border of the main window in pixels.
 +
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderTop|setBorderTop()]]
  
;Returns
+
: {{MudletVersion|4.0}}
*A table with all the formatting options to achieve a default text format for label labelName.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- creates a test label, sets a stylesheet, and then returns the default format table for that label.
+
setBorderTop(100)
createLabel("testLabel", 10, 10, 300, 200, 1)
+
getBorderTop()
setLabelStyleSheet([[
+
-- returns: 100
  color: rgb(0,0,180);
+
</syntaxhighlight>
  border-width: 1px;
+
 
  border-style: solid;
+
==getClipboardText==
  border-color: gold;
+
;getClipboardText()
  border-radius: 10px;
+
: Returns any text that is currently present in the clipboard.  
  font-size: 12.0pt;
+
: See also: [[#setClipboardText | setClipboardText()]]
  background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);
 
]])
 
local fmt = getLabelFormat("testLabel"))
 
  
--[[
+
: {{note}} Note: Available in Mudlet 4.10+
{
 
  background = "rgba(0, 0, 0, 0)", -- this is transparent
 
  bold = false,
 
  foreground = "rgb(0,0,180)",
 
  italic = false,
 
  overline = false,
 
  reverse = false,
 
  strikeout = false,
 
  underline = false
 
}
 
--]]
 
  
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
local clipboardContents = getClipboardText()
 +
echo("Clipboard: " .. clipboardContents)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getLabelSizeHint==
+
==getColorWildcard==
;width, height = getLabelSizeHint(labelName)
+
; getColorWildcard(ansi color number)
 +
: This function, given an ANSI color number ([[Manual:UI_Functions#isAnsiFgColor|list]]), will return all strings on the current line that match it.
  
: Returns the suggested labelsize as width and height
+
: See also: [[#isAnsiFgColor|isAnsiFgColor()]], [[#isAnsiBgColor|isAnsiBgColor()]]
 
 
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getHTMLformat|getHTMLformat()]]
 
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
*''labelName:''
+
* ''ansi color number:''
: The name of the label to get the suggested size from
+
: A color number ([[Manual:UI_Functions#isAnsiFgColor|list]]) to match.
 
 
;Returns
 
*suggested width and height (to fit text and/or an image on a label)
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- text resizing example
+
-- we can run this script on a line that has the players name coloured differently to easily capture it from
-- create the label
+
-- anywhere on the line
createLabel("textLabel",400,400,300,300,1)
+
local match = getColorWildcard(14) -- this will be a table of every match
-- put some text on it
 
echo("textLabel", "This is my Test.\nAnother Test")
 
-- resizes the label to fit the text
 
resizeWindow("textLabel", getLabelSizeHint("textLabel"))
 
 
 
-- image resizing example
 
-- create the label
 
createLabel("imageLabel",400,400,300,300,1)
 
-- put some image on it
 
setBackgroundImage("imageLabel", getMudletHomeDir.."/myLabelImage.png")
 
-- resizes the label to fit the image
 
resizeWindow("imageLabel", getLabelSizeHint("imageLabel"))
 
  
 +
if match then -- if there's a table, then we try and print it on the screen!
 +
  echo("\nFound "..table.concat(match, ", ").."!") -- this will combine all captured strings and separate them with a comma so it's easy to read.
 +
else -- if there isn't something in match, then we haven't found anything to print on the screen!
 +
  echo("\nDidn't find anyone.")
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getLabelStyleSheet==
+
==getColumnCount==
;getLabelStyleSheet(labelName)
+
;getColumnCount([windowName])
: Returns the stylesheet set on a given label, which is used to customise the labels look and feel.
+
: Gets the maximum number of columns (characters) that a given window can display on a single row, taking into consideration factors such as window width, font size, spacing, etc.
  
;See also:[[Manual:Lua_Functions#setLabelStyleSheet|getTextFormat()]]
+
;Parameters:
 +
* ''windowName'':
 +
: (optional) name of the window whose number of columns we want to calculate. By default it operates on the main window.
  
{{MudletVersion|4.15}}
+
{{MudletVersion|3.7}}
 
 
;Parameters
 
*''labelName:''
 
: The name of the label to get the stylesheet from
 
 
 
;Returns
 
*stylesheet as a string
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
createLabel("test", 50, 50, 100, 100, 0)
+
print("Maximum number of columns on the main window "..getColumnCount())
setLabelStyleSheet("test", [[
+
</syntaxhighlight>
  background-color: white;
+
 
  border: 10px solid green;
+
==getColumnNumber==
  font-size: 12px;
+
;getColumnNumber([windowName])
  ]])
+
: Gets the absolute column number of the current user cursor.
echo("test", "test")
 
 
 
-- now retrieve it and display:
 
local stylesheet = getLabelStyleSheet("test")
 
cecho(f"<green>the label's stylesheet is now: \n<white>{stylesheet}\n")
 
</syntaxhighlight>
 
 
 
==getLastLineNumber==
 
;getLastLineNumber(windowName)
 
:Returns the latest line's number in the main window or the miniconsole. This could be different from [[Manual:UI_Functions#getLineNumber|getLineNumber()]] if the cursor was moved around.
 
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: name of the window to use. Either use ''main'' for the main window, or the name of the miniconsole.
+
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
 +
 
 +
{{note}} the argument is available since Mudlet 3.0.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- get the latest line's # in the buffer
+
HelloWorld = Geyser.MiniConsole:new({
local latestline = getLastLineNumber("main")
+
  name="HelloWorld",
</syntaxhighlight>
+
  x="70%", y="50%",
 +
  width="30%", height="50%",
 +
})
  
==getLineCount==
+
HelloWorld:echo("hello!\n")
;getLineCount([windowName])
+
HelloWorld:echo("hello!\n")
:Gets the absolute amount of lines in the current console buffer
+
HelloWorld:echo("hello!\n")
  
; Parameters
+
moveCursor("HelloWorld", 3, getLastLineNumber("HelloWorld"))
*''windowName''
+
-- should say 3, because we moved the cursor in the HellWorld window to the 3rd position in the line
: Optional name of the window to get the line count of. Defaults to the main window.
+
print("getColumnNumber: "..tostring(getColumnNumber("HelloWorld")))
  
;Example
+
moveCursor("HelloWorld", 1, getLastLineNumber("HelloWorld"))
 
+
-- should say 3, because we moved the cursor in the HellWorld window to the 1st position in the line
<syntaxhighlight>
+
print("getColumnNumber: "..tostring(getColumnNumber("HelloWorld")))
echo("Main window has " .. getLineCount() .. " lines of text in it.")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getLines==
+
==getCurrentLine==
;getLines([windowName,] from_line_number, to_line_number)
+
;getCurrentLine([windowName])
: Returns a section of the content of the screen text buffer. Returns a Lua table with the content of the lines on a per line basis. The form value is ''result = {relative_linenumber = line}''.
+
: Returns the content of the current line under the user cursor in the buffer. The Lua variable '''line''' holds the content of ''getCurrentLine()'' before any triggers have been run on this line. When triggers change the content of the buffer, the variable line will not be adjusted and thus hold an outdated string. ''line = getCurrentLine()'' will update line to the real content of the current buffer. This is important if you want to copy the current line after it has been changed by some triggers. ''selectString( line,1 )'' will return false and won't select anything because line no longer equals ''getCurrentLine()''. Consequently, ''selectString( getCurrentLine(), 1 )'' is what you need.
  
:Absolute line numbers are used.
+
; Parameters
 
+
* ''windowName:''
;Parameters
+
: (optional) name of the window in which to select text.
* ''windowName''
 
: (optional) name of the miniconsole/userwindow to get lines for, or "main" for the main window (Mudlet 3.17+)
 
* ''from_line_number:''
 
: First line number
 
* ''to_line_number:''
 
: End line number
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- retrieve & echo the last line:
+
print("Currently selected line: "..getCurrentLine())
echo(getLines(getLineNumber()-1, getLineNumber())[1])
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
<syntaxhighlight lang="lua">
+
==getFgColor==
-- find out which server and port you are connected to (as per Mudlet settings dialog):
+
; getFgColor(windowName)
local t = getLines(0, getLineNumber())
+
: This function returns the rgb values of the color of the first character of the current selection on mini console (window) windowName. If windowName is omitted Mudlet will use the main screen.
  
local server, port
+
;Parameters
 +
* ''windowName:''
 +
: A window to operate on - either a miniconsole or the main window.
  
for i = 1, #t do
+
;Example
  local s, p = t[i]:match("looking up the IP address of server:(.-):(%d+)")
+
<syntaxhighlight lang="lua">
  if s then server, port = s, p break end
+
selectString("troll",1)
 +
local r,g,b = getFgColor()
 +
if r == 255 and g == 0 and b == 0 then
 +
  echo("HELP! troll is written in red letters, the monster is aggressive!\n")
 
end
 
end
 
display(server)
 
display(port)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getLineNumber==
+
==getFont==
;getLineNumber([windowName])
+
;getFont([windowName])
: Returns the absolute line number of the current user cursor (the y position). The cursor by default is on the current line the triggers are processing - which you can move around with [[Manual:Lua_Functions#moveCursor|moveCursor()]] and [[Manual:Lua_Functions#moveCursorEnd|moveCursorEnd()]]. This function can come in handy in combination when using with [[Manual:Lua_Functions#moveCursor|moveCursor()]] and [[Manual:Lua_Functions#getLines|getLines()]].
+
: Gets the current font of the given window or console name. Can be used to get font of the main console, dockable userwindows and miniconsoles.
 +
: See also: [[#setFont|setFont()]], [[#setFontSize|setFontSize()]], [[#openUserWindow|openUserWindow()]], [[#getAvailableFonts|getAvailableFonts()]]
 +
 
 +
{{MudletVersion|3.4}}
 +
{{note}} Since Mudlet 3.10, returns the actual font that was used in case you didn't have the required font when using [[#setFont|setFont()]].
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: (optional) name of the miniconsole to operate on. If you'd like it to work on the main window, don't specify anything.
+
: The window name to get font size of - can either be none or "main" for the main console, or a miniconsole/userwindow name.
 
 
{{note}}
 
The argument is available since Mudlet 3.0.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- use getLines() in conjuction with getLineNumber() to check if the previous line has a certain word
+
-- The following will get the "main" console font size.
if getLines(getLineNumber()-1, getLineNumber())[1]:find("attacks") then echo("previous line had the word 'attacks' in it!\n") end
+
display("Font in the main window: "..getFont())
  
-- check how many lines you've got in your miniconsole after echoing some text.
+
display("Font in the main window: "..getFont("main"))
-- Note the use of moveCursorEnd() to update getLineNumber()'s output
 
HelloWorld = Geyser.MiniConsole:new({
 
  name="HelloWorld",
 
  x="70%", y="50%",
 
  width="30%", height="50%",
 
})
 
  
print(getLineNumber("HelloWorld"))
+
-- This will get the font size of a user window named "user window awesome".
 
+
display("Font size: " .. getFont("user window awesome"))
HelloWorld:echo("hello!\n")
 
HelloWorld:echo("hello!\n")
 
HelloWorld:echo("hello!\n")
 
 
 
-- update the cursors position, as it seems to be necessary to do
 
moveCursorEnd("HelloWorld")
 
print(getLineNumber("HelloWorld"))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getMainConsoleWidth==
+
==getFontSize==
;getMainConsoleWidth()
+
;getFontSize([windowName])
: Returns a single number; the width of the main console (game output) in pixels. This also accounts for any borders that have been set.
+
: Gets the current font size of the given window or console name. Can be used to get font size of the Main console as well as dockable UserWindows.
 +
: See also: [[#setFontSize|setFontSize()]], [[#openUserWindow|openUserWindow()]]
  
: See also: [[#getMainWindowSize|getMainWindowSize()]]
+
;Parameters
 +
* ''windowName:''
 +
: The window name to get font size of - can either be none or "main" for the main console, or a UserWindow name.
  
; Parameters
+
{{MudletVersion|3.4}}
:None
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Save width of the main console to a variable for future use.
+
-- The following will get the "main" console font size.
consoleWidth = getMainConsoleWidth()
+
local mainWindowFontSize = getFontSize()
</syntaxhighlight>
+
if mainWindowFontSize then
 +
    display("Font size: " .. mainWindowFontSize)
 +
end
  
==getMouseEvents==
+
local mainWindowFontSize = getFontSize("main")
; events = getMouseEvents()
+
if mainWindowFontSize then
 +
    display("Font size: " .. fs2)
 +
end
  
:Returns a table of registered mouse events, including any of the additional arguments they may have.
+
-- This will get the font size of a user window named "user window awesome".
 +
local awesomeWindowFontSize = getFontSize("user window awesome")
 +
if awesomeWindowFontSize then
 +
    display("Font size: " .. awesomeWindowFontSize)
 +
end
 +
</syntaxhighlight>
  
{{MudletVersion|4.13}}
+
==getHTMLformat==
 +
;spanTag = getHTMLformat(formatTable)
  
;See also: [[Manual:Lua_Functions#addMouseEvent|addMouseEvent()]], [[Manual:Lua_Functions#removeMouseEvent|removeMouseEvent()]]
+
:Takes in a table of formatting options in the same style as [[Manual:Lua_Functions#getTextFormat|getTextFormat()]] and returns a span tag which will format text after it as the table describes.
  
;Returns
+
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
* Returns a table with mouse event ''uniqueName'' as indexes, containing all the creation arguments as the sub-table members.
 
  
==getMousePosition==
+
{{MudletVersion|4.15}}
;getMousePosition()
 
: Returns the coordinates of the mouse's position, relative to the Mudlet window itself.
 
  
; Parameters
+
;Parameters
:None
+
*''formatTable:''
 +
:Table with formatting options configured. Keys are foreground, background, bold, underline, overline, strikeout, italic, and reverse. All except for foreground and background should be boolean (true/false) values. Foreground and background are either { r, g, b, a } tables, or strings with QSS formatting directives
  
{{MudletVersion|3.1}}
+
;Returns
 +
*A string with the html span tag to format text in accordance with the format table.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Retrieve x and y position of the mouse to determine where to create a new label, then use that position to create a new label
+
-- Returns a span tag for bold, red text on a green background
local x, y = getMousePosition()
+
local span = getHTMLformat({
createLabel("clickGeneratedLabel", x, y, 100, 100, 1)
+
  foreground = { 255, 0, 0 },
-- if the label already exists, just move it
+
  background = "#00FF00",
moveWindow("clickGeneratedLabel", x, y)
+
  bold = true
-- and make it easier to notice
+
})
setBackgroundColor("clickGeneratedLabel", 255, 204, 0, 200)
+
 
 +
-- span will be '<span style="color: rgb(255, 0, 0);background-color: #00FF00; font-weight: bold; font-style: normal; text-decoration: none;">'
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getProfileTabNumber==
+
==getImageSize==
;getProfileTabNumber()
+
;getImageSize(imageLocation)
: Returns the current tab number you're in. If you have just one profile loaded, it'll always return 1 - otherwise it'll be the nth tab that is currently open.
+
: Returns the width and the height of the given image. If the image can't be found, loaded, or isn't a valid image file - nil+error message will be returned instead.
 +
: See also: [[#createLabel|createLabel()]]
  
; Parameters
+
;Parameters
:None
+
* ''imageLocation:''
 +
: Path to the image.
  
{{MudletVersion|4.11}}
+
{{MudletVersion|4.5}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
print(f"Current playing in tab #{getProfileTabNumber()}.")
+
local path = getMudletHomeDir().."/my-image.png"
</syntaxhighlight>
 
  
==getMainWindowSize==
+
cecho("Showing dimensions of the picture in: "..path.."\n")
;getMainWindowSize()
 
: Returns two numbers, the width and height in pixels of the main window.  
 
: See also: [[#getUserWindowSize|getUserWindowSize()]], [[#setMainWindowSize|setMainWindowSize()]], [[#getMainConsoleWidth|getMainConsoleWidth()]]
 
  
; Parameters
+
local width, height = getImageSize(path)
:None
 
  
;Example
+
if not width then
<syntaxhighlight lang="lua">
+
  -- in case of an problem, we don't get a height back - but the error message
--this will get the size of your main mudlet window and save them
+
  cecho("error: "..height.."\n")
--into the variables mainHeight and mainWidth
+
else
mainWidth, mainHeight = getMainWindowSize()
+
  cecho(string.format("They are: %sx%s", width, height))
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRowCount==
+
==getLabelFormat==
;getRowCount([windowName])
+
;formatTable = getLabelFormat(labelName)
: Gets the maximum number of rows that a given window can display at once, taking into consideration factors such as window height, font type, spacing, etc.
 
  
;Parameters:
+
: Returns a format table like the one returned by getTextFormat and suitable for getHTMLformat which will format text the same way as simply doing an echo to the label would
* ''windowName'':
 
: (optional) name of the window whose maximum number of rows we want to calculate. By default it operates on the main window.
 
  
{{MudletVersion|3.7}}
+
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getHTMLformat|getHTMLformat()]]
  
;Example
+
{{MudletVersion|4.15}}
<syntaxhighlight lang="lua">
 
print("Maximum of rows on the main window "..getRowCount())
 
</syntaxhighlight>
 
  
==getScroll==
+
;Parameters
;getScroll([windowName])
+
*''labelName:''
:Returns line that the window is currently scrolled to.
+
: The name of the label to scan the format of
:See also: [[Manual:Lua_Functions#scrollTo|scrollTo]], [[Manual:Lua_Functions#scrollUp|scrollUp]], [[Manual:Lua_Functions#scrollDown|scrollDown]]
 
  
; Parameters
+
;Returns
*''windowName:''
+
*A table with all the formatting options to achieve a default text format for label labelName.
:(optional) name of the window to ask about.  Default is the main window.
 
 
 
{{MudletVersion|4.17.0}}
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- button to jump to next instance of "Timbo"
+
-- creates a test label, sets a stylesheet, and then returns the default format table for that label.
local current = getScroll()
+
createLabel("testLabel", 10, 10, 300, 200, 1)
local data = getLines(current, getLineCount())
+
setLabelStyleSheet([[
for count, line in ipairs(data) do
+
  color: rgb(0,0,180);
   local match = string.findPattern(line, "Timbo")
+
  border-width: 1px;
   if match then
+
  border-style: solid;
    scrollTo(current + count)
+
  border-color: gold;
    break
+
  border-radius: 10px;
   end
+
  font-size: 12.0pt;
end
+
  background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);
 +
]])
 +
local fmt = getLabelFormat("testLabel"))
 +
 
 +
--[[
 +
{
 +
   background = "rgba(0, 0, 0, 0)", -- this is transparent
 +
  bold = false,
 +
  foreground = "rgb(0,0,180)",
 +
  italic = false,
 +
   overline = false,
 +
  reverse = false,
 +
  strikeout = false,
 +
   underline = false
 +
}
 +
--]]
 +
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getSelection==
+
==getLabelSizeHint==
;getSelection([windowName])
+
;width, height = getLabelSizeHint(labelName)
: Returns the text currently selected with [[#selectString|selectString()]], [[#selectSection|selectSection()]], or [[#selectCurrentLine|selectCurrentLine()]]. Note that this isn't the text currently selected with the mouse.
 
: Also returns the start offset and length of the selection as second and third value.
 
  
;Parameters:
+
: Returns the suggested labelsize as width and height
* ''windowName'':
 
: (optional) name of the window to get the selection from. By default it operates on the main window.
 
  
{{MudletVersion|3.16}}
+
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getHTMLformat|getHTMLformat()]]
  
;Example
+
{{MudletVersion|4.15}}
<syntaxhighlight lang="lua">
 
selectCurrentLine()
 
print("Current line contains: "..getSelection())
 
</syntaxhighlight>
 
 
 
;retrieving the selection
 
<syntaxhighlight lang="lua">
 
text,offset,len = getSelection()
 
-- manipulate the selection, e.g. to discover the color of characters other than the first
 
-- then restore it
 
selectSection(offset, len)
 
</syntaxhighlight>
 
 
 
==getTextFormat==
 
;getTextFormat([windowName])
 
: Gets the current text format of the currently selected text. May be used with other console windows. The returned values come in a table containing text attribute names and their values. The values given will be booleans for: bold, italics, underline, overline, strikeout, and reverse - followed by color triplet tables for the foreground and background colors.
 
: See Also: [[Manual:Lua_Functions#setTextFormat|setTextFormat()]]
 
  
 
;Parameters
 
;Parameters
* ''windowName''
+
*''labelName:''
: (optional) Specify name of selected window. If no name or "main" is given, the format will be gathered from the main console.
+
: The name of the label to get the suggested size from
  
{{MudletVersion|3.20}}
+
;Returns
 +
*suggested width and height (to fit text and/or an image on a label)
  
;Example:
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- A suitable test for getTextFormat()
+
-- text resizing example
-- (copy it into an alias or a script)
+
-- create the label
 +
createLabel("textLabel",400,400,300,300,1)
 +
-- put some text on it
 +
echo("textLabel", "This is my Test.\nAnother Test")
 +
-- resizes the label to fit the text
 +
resizeWindow("textLabel", getLabelSizeHint("textLabel"))
  
clearWindow()
+
-- image resizing example
 +
-- create the label
 +
createLabel("imageLabel",400,400,300,300,1)
 +
-- put some image on it
 +
setBackgroundImage("imageLabel", getMudletHomeDir.."/myLabelImage.png")
 +
-- resizes the label to fit the image
 +
resizeWindow("imageLabel", getLabelSizeHint("imageLabel"))
  
echo("\n")
+
</syntaxhighlight>
  
local SGR = string.char(27)..'['
+
==getLabelStyleSheet==
feedTriggers("Format attributes: '"..SGR.."1mBold"..SGR.."0m' '"..SGR.."3mItalic"..SGR.."0m' '"..SGR.."4mUnderline"..SGR.."0m' '"..SGR.."5mBlink"..SGR.."0m' '"..SGR.."6mF.Blink"..SGR.."0m' '"..SGR.."7mReverse"..SGR.."0m' '"..SGR.."9mStruckout"..SGR.."0m' '"..SGR.."53mOverline"..SGR.."0m'.\n")
+
;getLabelStyleSheet(labelName)
 +
: Returns the stylesheet set on a given label, which is used to customise the labels look and feel.
  
moveCursor(1,1)
+
;See also:[[Manual:Lua_Functions#setLabelStyleSheet|getTextFormat()]]
selectSection(1,1)
 
  
local results = getTextFormat()
+
{{MudletVersion|4.15}}
echo("For first character in test line:\nBold detected: " .. tostring(results["bold"]))
 
echo("\nItalic detected: " .. tostring(results["italic"]))
 
echo("\nUnderline detected: " .. tostring(results["underline"]))
 
echo("\nReverse detected: " .. tostring(results["reverse"]))
 
echo("\nStrikeout detected: " .. tostring(results["strikeout"]))
 
echo("\nOverline detected: " .. tostring(results["overline"]))
 
echo("\nForeground color: (" .. results["foreground"][1] .. ", " .. results["foreground"][2] .. ", " .. results["foreground"][3] .. ")")
 
echo("\nBackground color: (" .. results["background"][1] .. ", " .. results["background"][2] .. ", " .. results["background"][3] .. ")")
 
  
selectSection(21,1)
+
;Parameters
echo("\n\nFor individual parts of test text:")
+
*''labelName:''
echo("\nBold detected (character 21): " .. tostring(results["bold"]))
+
: The name of the label to get the stylesheet from
  
selectSection(28,1)
+
;Returns
echo("\nItalic detected (character 28): " .. tostring(results["italic"]))
+
*stylesheet as a string
  
selectSection(37,1)
+
;Example
echo("\nUnderline detected (character 37): " .. tostring(results["underline"]))
+
<syntaxhighlight lang="lua">
 +
createLabel("test", 50, 50, 100, 100, 0)
 +
setLabelStyleSheet("test", [[
 +
  background-color: white;
 +
  border: 10px solid green;
 +
  font-size: 12px;
 +
  ]])
 +
echo("test", "test")
  
selectSection(67,1)
+
-- now retrieve it and display:
echo("\nReverse detected (character 67): " .. tostring(results["reverse"]))
+
local stylesheet = getLabelStyleSheet("test")
 +
cecho(f"<green>the label's stylesheet is now: \n<white>{stylesheet}\n")
 +
</syntaxhighlight>
  
selectSection(77,1)
+
==getLastLineNumber==
echo("\nStrikeout detected (character 77): " .. tostring(results["strikeout"]))
+
;getLastLineNumber([windowName])
 +
:Returns the latest line's number in the main window or the miniconsole. This could be different from [[Manual:UI_Functions#getLineNumber|getLineNumber()]] if the cursor was moved around.
  
selectSection(89,1)
+
;Parameters
echo("\nOverline detected (character 89): " .. tostring(results["overline"]))
+
* ''windowName:''
echo("\n")
+
: Optional name of the window to use. Defaults to the main window.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- get the latest line's # in the buffer
 +
local latestline = getLastLineNumber("main")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getUserWindowSize==
+
==getLineCount==
;getUserWindowSize(windowName)
+
;getLineCount([windowName])
: Returns two numbers, the width and height in pixels. This is useful for calculating the given userwindow dimensions.
+
:Gets the absolute amount of lines in the current console buffer
: See also: [[#getMainWindowSize|getMainWindowSize()]]
 
  
 
; Parameters
 
; Parameters
* ''windowName''
+
*''windowName''
:the name of the userwindow we will get the dimensions from
+
: Optional name of the window to get the line count of. Defaults to the main window.
  
{{MudletVersion|4.6.1}}
+
;Example
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--this will get the size of your userwindow named "ChatWindow" and save them
+
echo("Main window has " .. getLineCount() .. " lines of text in it.")
--into the variables mainHeight and mainWidth
 
mainWidth, mainHeight = getUserWindowSize("ChatWindow")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getWindowWrap==
+
==getLines==
;getWindowWrap(windowName)
+
;getLines([windowName,] from_line_number, to_line_number)
: gets at what position in the line the will start word wrap.
+
: Returns a section of the content of the screen text buffer. Returns a Lua table with the content of the lines on a per line basis. The form value is ''result = {relative_linenumber = line}''.
 +
 
 +
:Absolute line numbers are used.
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''windowName''
: Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main" or leave empty.
+
: (optional) name of the miniconsole/userwindow to get lines for, or "main" for the main window (Mudlet 3.17+)
 +
* ''from_line_number:''
 +
: First line number
 +
* ''to_line_number:''
 +
: End line number
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setWindowWrap("main", 10)
+
-- retrieve & echo the last line:
display(getWindowWrap("main"))
+
echo(getLines(getLineNumber()-1, getLineNumber())[1])
 
 
-- The following output will result in the main window console:
 
-- 10
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
;Practical Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- display ======== line with maximum possible width without wrapping
+
-- find out which server and port you are connected to (as per Mudlet settings dialog):
echo(string.rep("=", getWindowWrap("main")))
+
local t = getLines(0, getLineNumber())
 +
 
 +
local server, port
 +
 
 +
for i = 1, #t do
 +
  local s, p = t[i]:match("looking up the IP address of server:(.-):(%d+)")
 +
  if s then server, port = s, p break end
 +
end
 +
 
 +
display(server)
 +
display(port)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.11}}
+
==getLineNumber==
 +
;getLineNumber([windowName])
 +
: Returns the absolute line number of the current user cursor (the y position). The cursor by default is on the current line the triggers are processing - which you can move around with [[Manual:Lua_Functions#moveCursor|moveCursor()]] and [[Manual:Lua_Functions#moveCursorEnd|moveCursorEnd()]]. This function can come in handy in combination when using with [[Manual:Lua_Functions#moveCursor|moveCursor()]] and [[Manual:Lua_Functions#getLines|getLines()]].
  
==handleWindowResizeEvent==
+
;Parameters
;handleWindowResizeEvent()
+
* ''windowName:''
: (''deprecated'') This function is deprecated and should not be used; it's only documented here for historical reference - use the [[Manual:Technical_Manual#sysWindowResizeEvent|sysWindowResizeEvent]] event instead.
+
: (optional) name of the miniconsole to operate on. If you'd like it to work on the main window, don't specify anything.
  
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.
+
{{note}}
 +
The argument is available since Mudlet 3.0.
  
; Parameters
+
;Example
:None
 
 
 
; Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function handleWindowResizeEvent()
+
-- use getLines() in conjuction with getLineNumber() to check if the previous line has a certain word
  -- determine the size of your screen
+
if getLines(getLineNumber()-1, getLineNumber())[1]:find("attacks") then echo("previous line had the word 'attacks' in it!\n") end
  WindowWidth=0;
+
 
  WindowHeight=0;
+
-- check how many lines you've got in your miniconsole after echoing some text.
  WindowWidth, WindowHeight = getMainWindowSize();
+
-- Note the use of moveCursorEnd() to update getLineNumber()'s output
 +
HelloWorld = Geyser.MiniConsole:new({
 +
  name="HelloWorld",
 +
  x="70%", y="50%",
 +
  width="30%", height="50%",
 +
})
 +
 
 +
print(getLineNumber("HelloWorld"))
  
  -- move mini console "sys" to the far right side of the screen whenever the screen gets resized
+
HelloWorld:echo("hello!\n")
  moveWindow("sys",WindowWidth-300,0)
+
HelloWorld:echo("hello!\n")
end
+
HelloWorld:echo("hello!\n")
 +
 
 +
-- update the cursors position, as it seems to be necessary to do
 +
moveCursorEnd("HelloWorld")
 +
print(getLineNumber("HelloWorld"))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hasFocus==
+
==getMainConsoleWidth==
;hasFocus()
+
;getMainConsoleWidth()
: Returns ''true'' or ''false'' depending if Mudlet's main window is currently in focus (ie, the user isn't focused on another window, like a browser). If multiple profiles are loaded, this can also be used to check if a given profile is in focus.
+
: Returns a single number; the width of the main console with respect to where the output lines wrap (not the total main console area; see <code>getMainWindowSize()</code> for that). i.e., The maximum size of a line length  (game output) in pixels.
 +
 
 +
: See also: [[#getMainWindowSize|getMainWindowSize()]]
  
 
; Parameters
 
; Parameters
Line 2,137: Line 2,255:
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
if attacked and not hasFocus() then
+
-- Save width of the main console to a variable for future use.
  runaway()
+
consoleWidth = getMainConsoleWidth()
else
 
  fight()
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hecho==
+
==getMouseEvents==
;hecho([windowName], text)
+
; events = getMouseEvents()
:Echoes text that can be easily formatted with colour tags in the hexadecimal format. You can also add the below tags.
+
 
 +
:Returns a table of registered mouse events, including any of the additional arguments they may have.
  
;Formatting
+
{{MudletVersion|4.13}}
  
<syntaxhighlight>
+
;See also: [[Manual:Lua_Functions#addMouseEvent|addMouseEvent()]], [[Manual:Lua_Functions#removeMouseEvent|removeMouseEvent()]]
<b>  - bold
 
</b> - bold off
 
<i>  - italics
 
</i> - italics off
 
<u>  - underline
 
</u> - underline off
 
<o>  - overline
 
</o> - overline off
 
<s>  - strikethrough
 
</s> - strikethrough off
 
</syntaxhighlight>
 
  
:See Also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#cecho|cecho()]]
+
;Returns
 +
* Returns a table with mouse event ''uniqueName'' as indexes, containing all the creation arguments as the sub-table members.
  
{{Note}} Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you hecho it will erase any previous echo sent to the label.
+
==getMousePosition==
 +
;getMousePosition()
 +
: Returns the coordinates of the mouse's position, relative to the Mudlet window itself.
  
;Parameters
+
; Parameters
*''windowName:''
+
:None
:(optional) name of the window to echo to. Can either be omitted or "main" for the main window, else specify the miniconsoles name.
 
*''text:''
 
:The text to display, with color changes made within the string using the format |cFRFGFB,BRBGBB or #FRFGFB,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 or #r can be used within the string to reset the colors to default. Hexadecimal color codes can be found here: https://www.color-hex.com/
 
  
{{note}}
+
{{MudletVersion|3.1}}
Transparency for background in hex-format available in Mudlet 4.10+
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
hecho("\n#ffffff White text!")
+
-- Retrieve x and y position of the mouse to determine where to create a new label, then use that position to create a new label
-- your text in white
+
local x, y = getMousePosition()
hecho("\n#ca0004 Red text! And now reset #rit to the default color")
+
createLabel("clickGeneratedLabel", x, y, 100, 100, 1)
-- your text in red, then reset to default using #r
+
-- if the label already exists, just move it
hecho("\n#ffffff,ca0004 White text with a red background!")
+
moveWindow("clickGeneratedLabel", x, y)
-- your text in white, against a red background
+
-- and make it easier to notice
hecho("\n|c0000ff Blue text, this time using |c instead of #")
+
setBackgroundColor("clickGeneratedLabel", 255, 204, 0, 200)
-- your text in blue, activated with |c vs #.
+
</syntaxhighlight>
hecho("\n#ff0000Red text with #iitalics#/i, |uunderline|/u, #ooverline#/o, #sstrikethrough#/s, and #bbold#/b formatting.")
+
 
-- shows the various individual formatting options
+
==getProfileTabNumber==
hecho("\n#008000#o#uGreen text with both over and underlines.#/o#/u")
+
;getProfileTabNumber()
</syntaxhighlight>
+
: Returns the current tab number you're in. If you have just one profile loaded, it'll always return 1 - otherwise it'll be the nth tab that is currently open.
  
==hecho2ansi==
+
; Parameters
;ansiFormattedString = hecho2ansi(text)
+
:None
  
:Converts hecho formatted text to ansi formatted text. Used by hfeedTriggers, but useful if you want ansi formatted text for any other reason.
+
{{MudletVersion|4.11}}
  
;See also:[[Manual:Lua_Functions#hecho|hecho()]], [[Manual:Lua_Functions#hfeedTriggers|hfeedTriggers()]]
+
;Example
 +
<syntaxhighlight lang="lua">
 +
print(f"Current playing in tab #{getProfileTabNumber()}.")
 +
</syntaxhighlight>
  
{{MudletVersion|4.10+}}
+
==getMainWindowSize==
 +
;getMainWindowSize()
 +
: Returns two numbers, the width and height in pixels of the main window.
 +
: See also: [[#getUserWindowSize|getUserWindowSize()]], [[#setMainWindowSize|setMainWindowSize()]], [[#getMainConsoleWidth|getMainConsoleWidth()]]
  
{{Note}} non-color formatting added in Mudlet 4.15+
+
; Parameters
 
+
:None
;Parameters
 
*''text:''
 
:The hecho formatted text for conversion
 
 
 
;Returns
 
*String converted to ansi formatting
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- replicates the functionality of hfeedTriggers() for a single line.
+
--this will get the size of your main mudlet window and save them
-- you would most likely just use hfeedTriggers, but it makes for a tidy example.
+
--into the variables mainHeight and mainWidth
feedTriggers(hecho2ansi("\n#800000This is red.#r #iitalic#/i, #bbold#/b, #sstrikethrough#/s, #uunderline#/u\n"))
+
mainWidth, mainHeight = getMainWindowSize()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hechoLink==
+
==getRowCount==
;hechoLink([windowName], text, command, hint, true)
+
;getRowCount([windowName])
: Echos a piece of text as a clickable link, at the end of the current selected line - similar to [[Manual:Lua_Functions#hecho|hecho()]]. This version allows you to use colours within your link text.
+
: Gets the maximum number of rows that a given window can display at once, taking into consideration factors such as window height, font type, spacing, etc.
  
: See also: [[#cechoLink|cechoLink()]], [[#dechoLink|dechoLink()]]
+
;Parameters:
 +
* ''windowName'':
 +
: (optional) name of the window whose maximum number of rows we want to calculate. By default it operates on the main window.
  
;Parameters
+
{{MudletVersion|3.7}}
* ''windowName:''
 
: (optional) - allows selection between sending the link to a miniconsole or the ''main'' window.
 
* ''text:''
 
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#hecho|hecho()]].
 
* ''command:''
 
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 
* ''hint:''
 
: text for the tooltip to be displayed when the mouse is over the link.
 
* ''true:''
 
: requires argument for the colouring to work.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- echo a link named 'press me!' that'll send the 'hi' command to the game
+
print("Maximum of rows on the main window "..getRowCount())
hechoLink("|ca00040black!", function() send("hi") end, "This is a tooltip", true)
+
</syntaxhighlight>
  
-- # format also works
+
==getScroll==
hechoLink("#ca00040black!", function() send("hi") end, "This is a tooltip", true)
+
;getScroll([windowName])
 +
:Returns line that the window is currently scrolled to.
 +
:See also: [[Manual:Lua_Functions#scrollTo|scrollTo]], [[Manual:Lua_Functions#scrollUp|scrollUp]], [[Manual:Lua_Functions#scrollDown|scrollDown]]
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
; Parameters
hechoLink("#ca00040black!", [[send("hi")]], "This is a tooltip", true)
+
*''windowName:''
</syntaxhighlight>
+
:(optional) name of the window to ask about.  Default is the main window.
  
==hechoPopup==
+
{{MudletVersion|4.17.0}}
;hechoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
 
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like [[#hecho|hecho()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
 
  
{{MudletVersion|4.1}}
+
;Example
 
+
<syntaxhighlight lang="lua">
; Parameters
+
-- button to jump to next instance of "Timbo"
* ''windowName:''
+
local current = getScroll()
: (optional) name of the window to echo to. Use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
+
local data = getLines(current, getLineCount())
* ''text:''
+
for count, line in ipairs(data) do
: the text to display
+
  local match = string.findPattern(line, "Timbo")
* ''{commands}:''
+
  if match then
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
+
    scrollTo(current + count)
* ''{hints}:''
+
    break
: a table of strings which will be shown on the popup and right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
+
  end
* ''useCurrentFormatElseDefault:''
+
end
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
+
</syntaxhighlight>
 +
 
 +
==getSelection==
 +
;getSelection([windowName])
 +
: Returns the text currently selected with [[#selectString|selectString()]], [[#selectSection|selectSection()]], or [[#selectCurrentLine|selectCurrentLine()]]. Note that this isn't the text currently selected with the mouse.
 +
: Also returns the start offset and length of the selection as second and third value.
 +
 
 +
;Parameters:
 +
* ''windowName'':
 +
: (optional) name of the window to get the selection from. By default it operates on the main window.
 +
 
 +
{{MudletVersion|3.16}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Create some text as a clickable with a popup menu:
+
selectCurrentLine()
hechoPopup("#ff0000activities#r to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
+
print("Current line contains: "..getSelection())
 +
</syntaxhighlight>
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
;retrieving the selection
hechoPopup("#ff0000activities#r to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
+
<syntaxhighlight lang="lua">
 +
text,offset,len = getSelection()
 +
-- manipulate the selection, e.g. to discover the color of characters other than the first
 +
-- then restore it
 +
selectSection(offset, len)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hideGauge==
+
==getTextFormat==
;hideGauge(gaugeName)
+
;getTextFormat([windowName])
: hides the given gauge.
+
: Gets the current text format of the currently selected text. May be used with other console windows. The returned values come in a table containing text attribute names and their values. The values given will be booleans for: bold, italics, underline, overline, strikeout, and reverse - followed by color triplet tables for the foreground and background colors.
 
+
: See Also: [[Manual:Lua_Functions#setTextFormat|setTextFormat()]]
: See also: [[#showGauge|showGauge()]], [[#createGauge|createGauge()]]
 
  
 
;Parameters
 
;Parameters
* ''gaugeName:''
+
* ''windowName''
: name of the gauge to show.
+
: (optional) Specify name of selected window. If no name or "main" is given, the format will be gathered from the main console.
 +
 
 +
{{MudletVersion|3.20}}
  
 
;Example:
 
;Example:
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
hideGauge("my gauge")
+
-- A suitable test for getTextFormat()
showGauge("my gauge")
+
-- (copy it into an alias or a script)
</syntaxhighlight>
 
  
==hinsertLink==
+
clearWindow()
;hinsertLink([windowName], text, command, hint, true)
 
: Echos a piece of text as a clickable link, at the end of the current cursor position - similar to [[#hinsertText|hinsertText()]]. This version allows you to use colours within your link text.
 
  
: See also: [[#insertLink|insertLink()]], [[#dinsertLink|dinsertLink()]]
+
echo("\n")
  
{{MudletVersion|4.1}}
+
local SGR = string.char(27)..'['
 +
feedTriggers("Format attributes: '"..SGR.."1mBold"..SGR.."0m' '"..SGR.."3mItalic"..SGR.."0m' '"..SGR.."4mUnderline"..SGR.."0m' '"..SGR.."5mBlink"..SGR.."0m' '"..SGR.."6mF.Blink"..SGR.."0m' '"..SGR.."7mReverse"..SGR.."0m' '"..SGR.."9mStruckout"..SGR.."0m' '"..SGR.."53mOverline"..SGR.."0m'.\n")
  
;Parameters
+
moveCursor(1,1)
* ''windowName:''
+
selectSection(1,1)
: optional parameter, allows selection between sending the link to a miniconsole or the main window.
 
* ''text:''
 
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#hecho|hecho()]].
 
* ''command:''
 
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 
* ''hint:''
 
: text for the tooltip to be displayed when the mouse is over the link.
 
* ''true:''
 
: requires argument for the colouring to work.
 
  
;Example
+
local results = getTextFormat()
<syntaxhighlight lang="lua">
+
echo("For first character in test line:\nBold detected: " .. tostring(results["bold"]))
-- echo a link named 'press me!' that'll send the 'hi' command to the game
+
echo("\nItalic detected: " .. tostring(results["italic"]))
hinsertLink("#ff0000press #a52a2a,ffffffme!", function() send("hi") end, "This is a tooltip", true)
+
echo("\nUnderline detected: " .. tostring(results["underline"]))
 +
echo("\nReverse detected: " .. tostring(results["reverse"]))
 +
echo("\nStrikeout detected: " .. tostring(results["strikeout"]))
 +
echo("\nOverline detected: " .. tostring(results["overline"]))
 +
echo("\nForeground color: (" .. results["foreground"][1] .. ", " .. results["foreground"][2] .. ", " .. results["foreground"][3] .. ")")
 +
echo("\nBackground color: (" .. results["background"][1] .. ", " .. results["background"][2] .. ", " .. results["background"][3] .. ")")
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
selectSection(21,1)
hinsertLink("#ff0000press #a52a2a,ffffffme!", [[send("hi")]], "This is a tooltip", true)
+
echo("\n\nFor individual parts of test text:")
</syntaxhighlight>
+
echo("\nBold detected (character 21): " .. tostring(results["bold"]))
  
==hinsertPopup==
+
selectSection(28,1)
;hinsertPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
+
echo("\nItalic detected (character 28): " .. tostring(results["italic"]))
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current cursor position, like [[#hinsertText|hinsertText()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
 
  
{{MudletVersion|4.1}}
+
selectSection(37,1)
 +
echo("\nUnderline detected (character 37): " .. tostring(results["underline"]))
  
; Parameters
+
selectSection(67,1)
* ''windowName:''
+
echo("\nReverse detected (character 67): " .. tostring(results["reverse"]))
: (optional) name of the window to echo to. Use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
 
* ''text:''
 
: the text to display
 
* ''{commands}:''
 
: a table of lua code strings to do or a functions (since Mudlet 4.11). ie, <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
 
* ''{hints}:''
 
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
 
* ''useCurrentFormatElseDefault:''
 
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
 
  
;Example
+
selectSection(77,1)
<syntaxhighlight lang="lua">
+
echo("\nStrikeout detected (character 77): " .. tostring(results["strikeout"]))
-- Create some text as a clickable with a popup menu:
 
hinsertPopup("#ff0000activities#r to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
 
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
selectSection(89,1)
hinsertPopup("#ff0000activities#r to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
+
echo("\nOverline detected (character 89): " .. tostring(results["overline"]))
 +
echo("\n")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hreplaceLine==
+
==getUserWindowSize==
;hreplaceLine ([window], text)
+
;getUserWindowSize(windowName)
: Replaces the output line from the game with a colour-tagged string.
+
: Returns two numbers, the width and height in pixels. This is useful for calculating the given userwindow dimensions.
{{MudletVersion|4.12}}
+
: See also: [[#getMainWindowSize|getMainWindowSize()]]
See Also: [[Manual:Lua_Functions#hecho|hecho()]], [[Manual:Lua_Functions#hinsertText|hinsertText()]]
+
 
;Parameters
+
; Parameters
* ''window'' (optional):
+
* ''windowName''
: the window to copy the text from. Defaults to "main".
+
:the name of the userwindow we will get the dimensions from
* ''text:''
+
 
*: The text to display, with hex color values , ie ''#ff00ff''. If you'd like to use a background color, put it after a comma , - ''#,ff99ff''. You can use the ''#r'' tag to reset to the default color.
+
{{MudletVersion|4.6.1}}
:
 
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">hreplaceLine("#ff00ff[ALERT!]: #r"..line)
+
<syntaxhighlight lang="lua">
</syntaxhighlight>
+
--this will get the size of your userwindow named "ChatWindow" and save them
 +
--into the variables mainHeight and mainWidth
 +
mainWidth, mainHeight = getUserWindowSize("ChatWindow")
 +
</syntaxhighlight>
 +
 
 +
==getWindowWrap==
 +
;getWindowWrap(windowName)
 +
: gets at what position in the line the will start word wrap.
  
==hreplace==
 
;hreplace([window, ]text)
 
: Replaces the output line from the game with a colour-tagged string.
 
See Also: [[Manual:Lua_Functions#hecho|hecho()]], [[Manual:Lua_Functions#hinsertText|hinsertText()]]
 
 
;Parameters
 
;Parameters
* ''window:''
+
* ''windowName:''
*: The window to replace the selection in. Optional, defaults to the main window if not provided.
+
: Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main" or leave empty.
* ''text:''
 
*: The text to display, as with [[Manual:Lua_Functions#hecho|hecho()]]
 
:
 
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">
+
<syntaxhighlight lang="lua">
    selectCaptureGroup(1)
+
setWindowWrap("main", 10)
    hreplace("#EE00EE[ALERT!]: #r"..matches[2])
+
display(getWindowWrap("main"))
</syntaxhighlight>
 
  
{{MudletVersion|4.5}}
+
-- The following output will result in the main window console:
 +
-- 10
 +
</syntaxhighlight>
  
==hideToolBar==
+
;Practical Example
;hideToolBar(name)
 
: Hides the toolbar with the given name name and makes it disappear. If all toolbars of a tool bar area (top, left, right) are hidden, the entire tool bar area disappears automatically.
 
 
 
;Parameters
 
* ''name:''
 
: name of the button group to hide
 
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
hideToolBar("my offensive buttons")
+
-- display ======== line with maximum possible width without wrapping
 +
echo(string.rep("=", getWindowWrap("main")))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hideWindow==
+
{{MudletVersion|4.11}}
;hideWindow(name)
+
 
: This function hides a '''mini console''', a '''user window''' or a '''label''' with the given name. To show it again, use [[Manual:Lua_Functions#showWindow|showWindow()]].
+
==handleWindowResizeEvent==
 +
;handleWindowResizeEvent()
 +
: (''deprecated'') This function is deprecated and should not be used; it's only documented here for historical reference - use the [[Manual:Technical_Manual#sysWindowResizeEvent|sysWindowResizeEvent]] event instead.
  
: See also: [[#createMiniConsole|createMiniConsole()]], [[#createLabel|createLabel()]], [[#deleteLabel|deleteLabel()]]
+
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.
  
;Parameters
+
; Parameters
* ''name''
+
:None
: specifies the label or console you want to hide.
 
  
;Example
+
; Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function miniconsoleTest()
+
function handleWindowResizeEvent()
  local windowWidth, windowHeight = getMainWindowSize()
+
  -- determine the size of your screen
 
+
  WindowWidth=0;
  -- create the miniconsole
+
  WindowHeight=0;
  createMiniConsole("sys", windowWidth-650,0,650,300)
+
  WindowWidth, WindowHeight = getMainWindowSize();
  setBackgroundColor("sys",255,69,0,255)
+
 
  setMiniConsoleFontSize("sys", 8)
+
  -- move mini console "sys" to the far right side of the screen whenever the screen gets resized
  -- wrap lines in window "sys" at 40 characters per line - somewhere halfway, as an example
+
  moveWindow("sys",WindowWidth-300,0)
  setWindowWrap("sys", 40)
+
end
 +
</syntaxhighlight>
  
  print("created red window top-right")
+
==hasFocus==
 +
;hasFocus()
 +
: Returns ''true'' or ''false'' depending if Mudlet's main window is currently in focus (ie, the user isn't focused on another window, like a browser). If multiple profiles are loaded, this can also be used to check if a given profile is in focus.
  
  tempTimer(1, function()
+
; Parameters
    hideWindow("sys")
+
:None
    print("hid red window top-right")
 
  end)
 
  
  tempTimer(3, function()
+
;Example
    showWindow("sys")
+
<syntaxhighlight lang="lua">
    print("showed red window top-right")
+
if attacked and not hasFocus() then
   end)
+
  runaway()
 +
else
 +
   fight()
 
end
 
end
 
miniconsoleTest()
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==insertLink==
+
==hecho==
;insertLink([windowName], text, command, hint, [useCurrentLinkFormat])
+
;hecho([windowName], text)
: Inserts a piece of text as a clickable link at the current cursor position - similar to [[Manual:Lua_Functions#insertText|insertText()]].
+
:Echoes text that can be easily formatted with colour tags in the hexadecimal format. You can also add the below tags.
  
: See also: [[#echoLink|echoLink()]], [[#insertText|insertText()]], [[#cinsertLink|cinsertLink()]], [[#dinsertLink|dinsertLink()]], [[#hinsertLink|hinsertLink()]]
+
;Formatting
  
;Parameters
+
<syntaxhighlight lang="text">
* ''windowName:''
+
#b or |b  - bold
: (optional) the window to insert the link in - use either "main" or omit for the main window.
+
#/b or |/b - bold off
* ''text:''
+
#i or |i  - italics
: text to display in the window. Same as a normal [[Manual:Lua_Functions#echo|echo()]].
+
#/i or |/i - italics off
* ''command:''
+
#u or |u  - underline
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
+
#/u or |/u - underline off
* ''hint:''
+
#o or |o  - overline
: text for the tooltip to be displayed when the mouse is over the link.
+
#/o or |/o - overline off
* ''useCurrentLinkFormat:''
+
#s or |s  - strikethrough
: (optional) true or false. If true, then the link will use the current selection style (colors, underline, etc). If missing or false, it will use the default link style - blue on black underlined text.
+
#/s or |/s - strikethrough off
 +
#r or |r  - reset to default
 +
</syntaxhighlight>
  
;Example
+
:See Also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#cecho|cecho()]]
<syntaxhighlight lang="lua">
 
-- link with the default blue on white colors
 
insertLink("hey, click me!", function() echo("you clicked me!\n") end, "Click me popup")
 
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
{{Note}} Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you hecho it will erase any previous echo sent to the label.
insertLink("hey, click me!", [[echo("you clicked me!\n")]], "Click me popup")
 
  
-- use current cursor colors by adding true at the end
+
;Parameters
fg("red")
+
*''windowName:''
insertLink("hey, click me!", function() echo("you clicked me!\n") end, "Click me popup", true)
+
:(optional) name of the window to echo to. Can either be omitted or "main" for the main window, else specify the miniconsoles name.
resetFormat()
+
*''text:''
</syntaxhighlight>
+
:The text to display, with color changes made within the string using the format |cFRFGFB,BRBGBB or #FRFGFB,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 or #r can be used within the string to reset the colors to default. Hexadecimal color codes can be found here: https://www.color-hex.com/
  
{{note}} The ''hint'' can contain the same sort of "rich-text" as can be used for "labels" - and if the ''command'' is set to be the empty string ''""'' then this can be a means to show extra information for the text when the mouse is hovered over it but without a command being run should it be clicked upon, e.g.:
+
{{note}}
 +
Transparency for background in hex-format available in Mudlet 4.10+
  
[[File:Screenshot showing example of fancy visual link.png|center|frame|link=|Screenshot showing example of fancy visual link]]
+
;Example
 
+
<syntaxhighlight lang="lua">
==insertPopup==
+
hecho("\n#ffffff White text!")
;insertPopup([windowName,] text, {commands}, {hints}[, useCurrentLinkFormat])
+
-- your text in white
: Creates text with a left-clickable link, and a right-click menu for more options exactly where the cursor position is, similar to [[Manual:Lua_Functions#insertText|insertText()]]. The inserted text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
+
hecho("\n#ca0004 Red text! And now reset #rit to the default color")
 +
-- your text in red, then reset to default using #r
 +
hecho("\n#ffffff,ca0004 White text with a red background!")
 +
-- your text in white, against a red background
 +
hecho("\n|c0000ff Blue text, this time using |c instead of #")
 +
-- your text in blue, activated with |c vs #.
 +
hecho("\n#ff0000Red text with #iitalics#/i, |uunderline|/u, #ooverline#/o, #sstrikethrough#/s, and #bbold#/b formatting.")
 +
-- shows the various individual formatting options
 +
hecho("\n#008000#o#uGreen text with both over and underlines.#/o#/u")
 +
</syntaxhighlight>
  
; Parameters
+
==hecho2ansi==
* ''windowName:''
+
;ansiFormattedString = hecho2ansi(text)
: (optional) name of the window to echo to - use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
 
* ''text:''
 
: the text inserted for the popup to be applied to.
 
* ''{commands}:''
 
: a table of lua code commands to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>.
 
* ''{hints}:''
 
: a table of strings which will be shown when the pointer hovers over the popup's text and on the right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>.
 
* ''useCurrentLinkFormat:''
 
: (optional) boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
 
  
;Example
+
:Converts hecho formatted text to ansi formatted text. Used by hfeedTriggers, but useful if you want ansi formatted text for any other reason.
<syntaxhighlight lang="lua">
 
-- Create some text as a clickable with a popup menu:
 
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
 
  
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
;See also:[[Manual:Lua_Functions#hecho|hecho()]], [[Manual:Lua_Functions#hfeedTriggers|hfeedTriggers()]]
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
 
</syntaxhighlight>
 
  
==insertText==
+
{{MudletVersion|4.10+}}
;insertText([windowName], text)
 
: Inserts text at cursor postion in window - unlike [[Manual:Lua_Functions#echo|echo()]], which inserts the text at the end of the last line in the buffer (typically the one being processed by the triggers). You can use [[Manual:Lua_Functions#moveCursor|moveCursor()]] to move the cursor into position first.
 
  
: insertHTML() also does the same thing as insertText, if you ever come across it.
+
{{Note}} non-color formatting added in Mudlet 4.15+
  
: See also: [[Manual:Lua_Functions#cinsertText|cinsertText()]]
+
;Parameters
 +
*''text:''
 +
:The hecho formatted text for conversion
  
; Parameters
+
;Returns
* ''windowName:''
+
*String converted to ansi formatting
: (optional) The window to insert the text to.
 
* ''text:''
 
: The text you will insert into the current cursor position.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- move the cursor to the end of the previous line and insert some text
+
-- replicates the functionality of hfeedTriggers() for a single line.
 +
-- you would most likely just use hfeedTriggers, but it makes for a tidy example.
 +
feedTriggers(hecho2ansi("\n#800000This is red.#r #iitalic#/i, #bbold#/b, #sstrikethrough#/s, #uunderline#/u\n"))
 +
</syntaxhighlight>
 +
 
 +
==hecho2cecho==
 +
 
 +
; convertedString = hecho2cecho(str)
 +
 
 +
:Converts a hecho formatted string to a cecho formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
-- move to the previous line
+
{{MudletVersion|4.18}}
moveCursor(0, getLineNumber()-1)
 
-- move the end the of the previous line
 
moveCursor(#getCurrentLine(), getLineNumber())
 
  
fg("dark_slate_gray")
+
;Parameters
insertText(' <- that looks nice.')
+
* ''str''
 +
: string you wish to convert from hecho to cecho
 +
;Returns
 +
* a string formatted for cecho
  
deselect()
+
;Example
resetFormat()
+
<syntaxhighlight lang="lua">
moveCursorEnd()
+
-- convert to a hecho string and use cecho to display it
 +
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
 +
cecho(hecho2cecho(hechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==ioprint==
+
==hecho2decho==
;ioprint(text, some more text, ...)
+
 
:Prints text to the to the stdout. This is only available if you [http://www.wikihow.com/Run-a-Program-on-Command-Prompt launched Mudlet from cmd.exe] on Windows, [http://www.wikihow.com/Open-Applications-Using-Terminal-on-Mac from the terminal] on Mac, or from the terminal on a Linux OS (launch the terminal program, type ''mudlet'' and press enter).
+
; convertedString = hecho2decho(str)
  
Similar to [[Manual:Lua_Functions#echo|echo()]], but does not require a "\n" at the end for a newline and can print several items given to it. It cannot print whole tables. This function works similarly to the print() you will see in guides for Lua.
+
:Converts a hecho formatted string to a decho formatted one.
 +
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
This function is useful in working out potential crashing problems with Mudlet due to your scripts - as you will still see whatever it printed when Mudlet crashes.
+
{{MudletVersion|4.18}}
  
 
;Parameters
 
;Parameters
* ''text:''
+
* ''str''
: The information you want to display.
+
: string you wish to convert from hecho to decho
;Example:
+
;Returns
 +
* a string formatted for decho
 +
 
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
ioprint("hi!")
+
-- convert to a decho string and use decho to display it
ioprint(1,2,3)
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
ioprint(myvariable, someothervariable, yetanothervariable)
+
decho(hecho2decho(hechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==isAnsiBgColor==
+
==hecho2html==
; isAnsiBgColor(bgColorCode)
+
 
: This function tests if the first character of '''the current selection''' in the main console has the background color specified by bgColorCode.
+
; convertedString = hecho2html(str[, resetFormat])
 +
 
 +
:Converts a hecho formatted string to an html formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
  
 
;Parameters
 
;Parameters
* ''bgColorCode:''
+
* ''str''
: A color code to test for, possible codes are:
+
: string you wish to convert from hecho to hecho
 +
* ''resetFormat''
 +
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 +
;Returns
 +
* a string formatted for html
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
0 = default text color
+
-- create the base string
1 = light black
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
2 = dark black
+
 
3 = light red
+
-- create a label to display the result onto
4 = dark red
+
testLabel = Geyser.Label:new({name = "testLabel"})
5 = light green
+
 
6 = dark green
+
-- convert the hecho string to an html one, using the default formatting of testLabel created above
7 = light yellow
+
local htmlString = hecho2html(hechoString, testLabel:getFormat())
8 = dark yellow
 
9 = light blue
 
10 = dark blue
 
11 = light magenta
 
12 = dark magenta
 
13 = light cyan
 
14 = dark cyan
 
15 = light white
 
16 = dark white
 
</syntaxhighlight>
 
  
;Example
+
-- and finally echo it to the label to see
<syntaxhighlight lang="lua">
+
-- I use rawEcho as that displays the html exactly as given.
selectString( matches[1], 1 )
+
testLabel:rawEcho(htmlString)
if isAnsiBgColor( 5 ) then
 
    bg( "red" );
 
    resetFormat();
 
    echo( "yes, the background of the text is light green" )
 
else
 
    echo( "no sorry, some other background color" )
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}}
+
==hechoLink==
The variable named matches[1] holds the matched trigger pattern - even in substring, exact match, begin of line substring trigger patterns or even color triggers that do not know about the concept of capture groups. Consequently, you can always test if the text that has fired the trigger has a certain color and react accordingly. This function is faster than using getBgColor() and then handling the color comparison in Lua.
+
;hechoLink([windowName], text, command, hint, true)
 +
: Echos a piece of text as a clickable link, at the end of the current selected line - similar to [[Manual:Lua_Functions#hecho|hecho()]]. This version allows you to use colours within your link text.
  
''Also note that the color code numbers are Mudlet specific, though they do represent the colors in the 16 ANSI color-set for the main console they are not in the same order and they additionally have the default background color in the zeroth position.''
+
: See also: [[#cechoLink|cechoLink()]], [[#dechoLink|dechoLink()]]
 
 
==isAnsiFgColor==
 
; isAnsiFgColor(fgColorCode)
 
: This function tests if the first character of '''the current selection''' in the main console has the foreground color specified by fgColorCode.
 
  
 
;Parameters
 
;Parameters
* ''fgColorCode:''
+
* ''windowName:''
: A color code to test for, possible codes are:
+
: (optional) - allows selection between sending the link to a miniconsole or the ''main'' window.
 
+
* ''text:''
<syntaxhighlight lang="lua">
+
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#hecho|hecho()]].
0 = default text color
+
* ''command:''
1 = light black
+
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
2 = dark black
+
* ''hint:''
3 = light red
+
: text for the tooltip to be displayed when the mouse is over the link.
4 = dark red
+
* ''true:''
5 = light green
+
: requires argument for the colouring to work.
6 = dark green
 
7 = light yellow
 
8 = dark yellow
 
9 = light blue
 
10 = dark blue
 
11 = light magenta
 
12 = dark magenta
 
13 = light cyan
 
14 = dark cyan
 
15 = light white
 
16 = dark white
 
</syntaxhighlight>
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
selectString( matches[1], 1 )
+
-- echo a link named 'press me!' that'll send the 'hi' command to the game
if isAnsiFgColor( 5 ) then
+
hechoLink("|ca00040black!", function() send("hi") end, "This is a tooltip", true)
    bg( "red" );
 
    resetFormat();
 
    echo( "yes, the text is light green" )
 
else
 
    echo( "no sorry, some other foreground color" )
 
end
 
</syntaxhighlight>
 
  
{{note}}
+
-- # format also works
The variable named matches[1] holds the matched trigger pattern - even in substring, exact match, begin of line substring trigger patterns or even color triggers that do not know about the concept of capture groups. Consequently, you can always test if the text that has fired the trigger has a certain color and react accordingly. This function is faster than using getFgColor() and then handling the color comparison in Lua.
+
hechoLink("#ca00040black!", function() send("hi") end, "This is a tooltip", true)
  
''Also note that the color code numbers are Mudlet specific, though they do represent the colors in the 16 ANSI color-set for the main console they are not in the same order and they additionally have the default foreground color in the zeroth position.''
+
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 +
hechoLink("#ca00040black!", [[send("hi")]], "This is a tooltip", true)
 +
</syntaxhighlight>
  
==loadWindowLayout==
+
==hechoPopup==
;loadWindowLayout()
+
;hechoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
:Resets the layout of userwindows (floating miniconsoles) to the last saved state.
+
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like [[#hecho|hecho()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
  
:See also: [[#saveWindowLayout|saveWindowLayout()]], [[#openUserWindow|openUserWindow()]]
+
{{MudletVersion|4.1}}
  
{{MudletVersion|3.2}}
+
; Parameters
 +
* ''windowName:''
 +
: (optional) name of the window to echo to. Use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
 +
* ''text:''
 +
: the text to display
 +
* ''{commands}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
 +
* ''{hints}:''
 +
: a table of strings which will be shown on the popup and right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
loadWindowLayout()
+
-- Create some text as a clickable with a popup menu:
 +
hechoPopup("#ff0000activities#r to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
 +
 
 +
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 +
hechoPopup("#ff0000activities#r to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==lowerWindow==
+
==hideGauge==
;lowerWindow(labelName)
+
;hideGauge(gaugeName)
:Moves the referenced label/console below all other labels/consoles. For the opposite effect, see: [[#raiseWindow | raiseWindow()]].
+
: hides the given gauge.
 +
 
 +
: See also: [[#showGauge|showGauge()]], [[#createGauge|createGauge()]]
  
 
;Parameters
 
;Parameters
* ''labelName:''
+
* ''gaugeName:''
: the name of the label/console you wish to move below the rest.
+
: name of the gauge to show.
  
{{MudletVersion|3.1}}
+
;Example:
  
; Example:
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
createLabel("blueLabel", 300, 300, 100, 100, 1)   --creates a blue label
+
hideGauge("my gauge")
setBackgroundColor("blueLabel", 50, 50, 250, 255)
+
showGauge("my gauge")
 +
</syntaxhighlight>
  
createLabel("redLabel", 350, 350, 100, 100, 1)   --creates a red label which is placed on TOP of the blue label, as the last made label will sit at the top of the rest
+
==hinsertLink==
setBackgroundColor("redLabel", 250, 50, 50, 255)
+
;hinsertLink([windowName], text, command, hint, true)
 +
: Echos a piece of text as a clickable link, at the end of the current cursor position - similar to [[#hinsertText|hinsertText()]]. This version allows you to use colours within your link text.
  
lowerWindow("redLabel")                         --lowers redLabel, causing blueLabel to be back on top
+
: See also: [[#insertLink|insertLink()]], [[#dinsertLink|dinsertLink()]]
</syntaxhighlight>
 
  
==moveCursor==
+
{{MudletVersion|4.1}}
;moveCursor([windowName], x, y)
 
: Moves the user cursor of the window windowName, or the main window, to the absolute point (x,y). This function returns false if such a move is impossible e.g. the coordinates don’t exist. To determine the correct coordinates use [[Manual:Lua_Functions#getLineNumber|getLineNumber()]], [[Manual:Lua_Functions#getColumnNumber|getColumnNumber()]] and [[Manual:Lua_Functions#getLastLineNumber|getLastLineNumber()]]. The trigger engine will always place the user cursor at the beginning of the current line before the script is run. If you omit the windowName argument, the main screen will be used.
 
 
 
: Returns ''true'' or ''false'' depending on if the cursor was moved to a valid position. Check this before doing further cursor operations - because things like deleteLine() might invalidate this.
 
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: (optional) The window you are going to move the cursor in.
+
: optional parameter, allows selection between sending the link to a miniconsole or the main window.
* ''x:''
+
* ''text:''
: The horizontal axis in the window - that is, the letter position within the line.
+
: text to display in the echo. Same as a normal [[Manual:Lua_Functions#hecho|hecho()]].
* ''y:''
+
* ''command:''
: The vertical axis in the window - that is, the line number.
+
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 +
* ''hint:''
 +
: text for the tooltip to be displayed when the mouse is over the link.
 +
* ''true:''
 +
: requires argument for the colouring to work.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- move cursor to the start of the previous line and insert -<(
+
-- echo a link named 'press me!' that'll send the 'hi' command to the game
-- the first 0 means we want the cursor right at the start of the line,
+
hinsertLink("#ff0000press #a52a2a,ffffffme!", function() send("hi") end, "This is a tooltip", true)
-- and getLineNumber()-1 means we want the cursor on the current line# - 1 which
 
-- equals to the previous line
 
moveCursor(0, getLineNumber()-1)
 
insertText("-<(")
 
  
-- now we move the cursor at the end of the previous line. Because the
+
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
-- cursor is on the previous line already, we can use #getCurrentLine()
+
hinsertLink("#ff0000press #a52a2a,ffffffme!", [[send("hi")]], "This is a tooltip", true)
-- to see how long it is. We also just do getLineNumber() because getLineNumber()
+
</syntaxhighlight>
-- returns the current line # the cursor is on
+
 
moveCursor(#getCurrentLine(), getLineNumber())
+
==hinsertPopup==
insertText(")>-")
+
;hinsertPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
 +
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current cursor position, like [[#hinsertText|hinsertText()]]. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
 +
 
 +
{{MudletVersion|4.1}}
  
-- finally, reset it to the end where it was after our shenaningans - other scripts
+
; Parameters
-- could expect the cursor to be at the end
+
* ''windowName:''
moveCursorEnd()
+
: (optional) name of the window to echo to. Use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
</syntaxhighlight>
+
* ''text:''
 +
: the text to display
 +
* ''{commands}:''
 +
: a table of lua code strings to do or a functions (since Mudlet 4.11). ie, <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
 +
* ''{hints}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- a more complicated example showing how to work with Mudlet functions
+
-- Create some text as a clickable with a popup menu:
 +
hinsertPopup("#ff0000activities#r to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)
  
-- set up the small system message window in the top right corner
+
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
-- determine the size of your screen
+
hinsertPopup("#ff0000activities#r to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)
local WindowWidth, WindowHeight = getMainWindowSize()
+
</syntaxhighlight>
  
-- define a mini console named "sys" and set its background color
+
==hreplaceLine==
createMiniConsole("sys",WindowWidth-650,0,650,300)
+
;hreplaceLine ([window], text)
setBackgroundColor("sys",85,55,0,255)
+
: Replaces the output line from the game with a colour-tagged string.
 
+
{{MudletVersion|4.12}}
-- you *must* set the font size, otherwise mini windows will not work properly
+
See Also: [[Manual:Lua_Functions#hecho|hecho()]], [[Manual:Lua_Functions#hinsertText|hinsertText()]]
setMiniConsoleFontSize("sys", 12)
+
;Parameters
-- wrap lines in window "sys" at 65 characters per line
+
* ''window'' (optional):
setWindowWrap("sys", 60)
+
:  the window to copy the text from. Defaults to "main".
-- set default font colors and font style for window "sys"
+
* ''text:''
setTextFormat("sys",0,35,255,50,50,50,0,0,0)
+
*: The text to display, with hex color values , ie ''#ff00ff''. If you'd like to use a background color, put it after a comma , - ''#,ff99ff''. You can use the ''#r'' tag to reset to the default color.
-- clear the window
+
:
clearUserWindow("sys")
 
  
moveCursorEnd("sys")
+
;Example
setFgColor("sys", 10,10,0)
+
<syntaxhighlight lang="lua">hreplaceLine("#ff00ff[ALERT!]: #r"..line)
setBgColor("sys", 0,0,255)
+
</syntaxhighlight>
echo("sys", "test1---line1\n<this line is to be deleted>\n<this line is to be deleted also>\n")
 
echo("sys", "test1---line2\n")
 
echo("sys", "test1---line3\n")
 
setTextFormat("sys",158,0,255,255,0,255,0,0,0);
 
--setFgColor("sys",255,0,0);
 
echo("sys", "test1---line4\n")
 
echo("sys", "test1---line5\n")
 
moveCursor("sys", 1,1)
 
  
-- deleting lines 2+3
+
==hreplace==
deleteLine("sys")
+
;hreplace([window, ]text)
deleteLine("sys")
+
: Replaces the output line from the game with a colour-tagged string.
 +
See Also: [[Manual:Lua_Functions#hecho|hecho()]], [[Manual:Lua_Functions#hinsertText|hinsertText()]]
 +
;Parameters
 +
* ''window:''
 +
*: The window to replace the selection in. Optional, defaults to the main window if not provided.
 +
* ''text:''
 +
*: The text to display, as with [[Manual:Lua_Functions#hecho|hecho()]]
 +
:
  
-- inserting a line at pos 5,2
+
;Example
moveCursor("sys", 5,2)
+
<syntaxhighlight lang="lua">
setFgColor("sys", 100,100,0)
+
    selectCaptureGroup(1)
setBgColor("sys", 255,100,0)
+
    hreplace("#EE00EE[ALERT!]: #r"..matches[2])
insertText("sys","############## line inserted at pos 5/2 ##############")
+
</syntaxhighlight>
  
-- inserting a line at pos 0,0
+
{{MudletVersion|4.5}}
moveCursor("sys", 0,0)
 
selectCurrentLine("sys")
 
setFgColor("sys", 255,155,255)
 
setBold( "sys", true );
 
setUnderline( "sys", true )
 
setItalics( "sys", true )
 
insertText("sys", "------- line inserted at: 0/0 -----\n")
 
  
setBold( "sys", true )
+
==hideToolBar==
setUnderline( "sys", false )
+
;hideToolBar(name)
setItalics( "sys", false )
+
: Hides the toolbar with the given name name and makes it disappear. If all toolbars of a tool bar area (top, left, right) are hidden, the entire tool bar area disappears automatically.
setFgColor("sys", 255,100,0)
 
setBgColor("sys", 155,155,0)
 
echo("sys", "*** This is the end. ***\n")
 
</syntaxhighlight>
 
 
 
==moveCursorDown==
 
;moveCursorDown([windowName,] [lines,] [keepHorizontal])
 
: Moves the cursor in the given window down a specified number of lines.
 
: See also: [[#moveCursor|moveCursor()]], [[#moveCursorUp|moveCursorUp()]], [[#moveCursorEnd|moveCursorEnd()]]
 
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''name:''
: (optional) name of the miniconsole/userwindow, or "main" for the main window.
+
: name of the button group to hide
  
* ''lines:''
+
;Example
: (optional) number of lines to move cursor down by, or 1 by default.
+
<syntaxhighlight lang="lua">
 +
hideToolBar("my offensive buttons")
 +
</syntaxhighlight>
  
* ''keepHorizontal:''
+
==hideWindow==
: (optional) true/false to specify if horizontal position should be retained, or reset to the start of the line otherwise.
+
;hideWindow(name)
 +
: This function hides a '''mini console''', a '''user window''' or a '''label''' with the given name. To show it again, use [[Manual:Lua_Functions#showWindow|showWindow()]].
  
{{MudletVersion|3.17}}
+
: See also: [[#createMiniConsole|createMiniConsole()]], [[#createLabel|createLabel()]], [[#deleteLabel|deleteLabel()]]
 +
 
 +
;Parameters
 +
* ''name''
 +
: specifies the label or console you want to hide.
  
 
;Example
 
;Example
'' Need example''
+
<syntaxhighlight lang="lua">
 +
function miniconsoleTest()
 +
  local windowWidth, windowHeight = getMainWindowSize()
  
==moveCursorUp==
+
  -- create the miniconsole
;moveCursorUp([windowName,] [lines,] [keepHorizontal])
+
  createMiniConsole("sys", windowWidth-650,0,650,300)
: Moves the cursor in the given window up a specified number of lines.
+
  setBackgroundColor("sys",255,69,0,255)
: See also: [[#moveCursor|moveCursor()]], [[#moveCursorDown|moveCursorDown()]], [[#moveCursorEnd|moveCursorEnd()]]
+
  setMiniConsoleFontSize("sys", 8)
 +
  -- wrap lines in window "sys" at 40 characters per line - somewhere halfway, as an example
 +
  setWindowWrap("sys", 40)
  
;Parameters
+
  print("created red window top-right")
* ''windowName:''
 
: (optional) name of the miniconsole/userwindow, or "main" for the main window.
 
  
* ''lines:''
+
  tempTimer(1, function()
: (optional) number of lines to move cursor up by, or 1 by default.
+
    hideWindow("sys")
 +
    print("hid red window top-right")
 +
  end)
  
* ''keepHorizontal:''
+
  tempTimer(3, function()
: (optional) true/false to specify if horizontal position should be retained, or reset to the start of the line otherwise.
+
    showWindow("sys")
 +
    print("showed red window top-right")
 +
  end)
 +
end
  
{{MudletVersion|3.17}}
+
miniconsoleTest()
 +
</syntaxhighlight>
  
;Example
+
==insertLink==
'' Need example''
+
;insertLink([windowName], text, command, hint, [useCurrentLinkFormat])
 +
: Inserts a piece of text as a clickable link at the current cursor position - similar to [[Manual:Lua_Functions#insertText|insertText()]].
  
==moveCursorEnd==
+
: See also: [[#echoLink|echoLink()]], [[#insertText|insertText()]], [[#cinsertLink|cinsertLink()]], [[#dinsertLink|dinsertLink()]], [[#hinsertLink|hinsertLink()]]
;moveCursorEnd([windowName])
 
: Moves the cursor to the end of the buffer. "main" is the name of the main window, otherwise use the name of your user window.
 
: See Also: [[Manual:Lua_Functions#moveCursor|moveCursor()]]
 
 
 
: Returns true or false
 
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: (optional) name of the miniconsole/userwindow, or "main" for the main window.
+
: (optional) the window to insert the link in - use either "main" or omit for the main window.
 +
* ''text:''
 +
: text to display in the window. Same as a normal [[Manual:Lua_Functions#echo|echo()]].
 +
* ''command:''
 +
: Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
 +
* ''hint:''
 +
: text for the tooltip to be displayed when the mouse is over the link.
 +
* ''useCurrentLinkFormat:''
 +
: (optional) true or false. If true, then the link will use the current selection style (colors, underline, etc). If missing or false, it will use the default link style - blue on black underlined text.
  
 
;Example
 
;Example
'' Need example''
+
<syntaxhighlight lang="lua">
 +
-- link with the default blue on white colors
 +
insertLink("hey, click me!", function() echo("you clicked me!\n") end, "Click me popup")
  
==moveGauge==
+
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
;moveGauge(gaugeName, newX, newY)
+
insertLink("hey, click me!", [[echo("you clicked me!\n")]], "Click me popup")
:Moves a gauge created with createGauge to the new x,y coordinates. Remember the coordinates are relative to the top-left corner of the output window.
 
  
;Parameters
+
-- use current cursor colors by adding true at the end
* ''gaugeName:''
+
fg("red")
: The name of your gauge
+
insertLink("hey, click me!", function() echo("you clicked me!\n") end, "Click me popup", true)
* ''newX:''
+
resetFormat()
: The horizontal pixel location
 
* ''newY:''
 
: The vertical pixel location
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- This would move the health bar gauge to the location 1200, 400
 
moveGauge("healthBar", 1200, 400)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==moveWindow==
+
{{note}} The ''hint'' can contain the same sort of "rich-text" as can be used for "labels" - and if the ''command'' is set to be the empty string ''""'' then this can be a means to show extra information for the text when the mouse is hovered over it but without a command being run should it be clicked upon, e.g.:
;moveWindow(name, x, y)
 
:This function moves window name to the given x/y coordinate. The main screen cannot be moved. Instead you’ll have to set appropriate border values → preferences to move the main screen e.g. to make room for chat or information mini consoles, or other GUI elements. In the future moveWindow() will set the border values automatically if the name parameter is omitted.
 
  
:See Also: [[#createMiniConsole | createMiniConsole()]], [[#createLabel | createLabel()]], [[#handleWindowResizeEvent | handleWindowResizeEvent()]], [[#resizeWindow | resizeWindow()]], [[#setBorderSizes | setBorderSizes()]], [[#openUserWindow | openUserWindow()]]
+
[[File:Screenshot showing example of fancy visual link.png|center|frame|link=|Screenshot showing example of fancy visual link]]
  
;Parameters
+
==insertPopup==
* ''name:''
+
;insertPopup([windowName,] text, {commands}, {hints}[, useCurrentLinkFormat])
: The name of your window
+
: Creates text with a left-clickable link, and a right-click menu for more options exactly where the cursor position is, similar to [[Manual:Lua_Functions#insertText|insertText()]]. The inserted text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
* ''newX:''
 
: The horizontal pixel location
 
* ''newY:''
 
: The vertical pixel location
 
  
{{note}}
+
; Parameters
Since Mudlet 3.7 this method can also be used on UserWindow consoles.
+
* ''windowName:''
 +
: (optional) name of the window to echo to - use either ''main'' or omit for the main window, or the miniconsoles name otherwise.
 +
* ''text:''
 +
: the text inserted for the popup to be applied to.
 +
* ''{commands}:''
 +
: a table of lua code commands to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>.
 +
* ''{hints}:''
 +
: a table of strings which will be shown when the pointer hovers over the popup's text and on the right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>.
 +
* ''useCurrentLinkFormat:''
 +
: (optional) boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
  
==openUserWindow==
+
;Example
;openUserWindow(windowName, [restoreLayout], [autoDock], [dockingArea])
+
<syntaxhighlight lang="lua">
: Opens a user dockable console window for user output e.g. statistics, chat etc. If a window of such a name already exists, nothing happens. You can move these windows (even to a different screen on a system with a multi-screen display), dock them on any of the four sides of the main application window, make them into notebook tabs or float them.
+
-- Create some text as a clickable with a popup menu:
 +
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
  
: See also: [[#resetUserWindowTitle|resetUserWindowTitle()]], [[#setUserWindowTitle|setUserWindowTitle()]], [[#saveWindowLayout|saveWindowLayout()]], [[#loadWindowLayout|loadWindowLayout()]]
+
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 +
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
 +
</syntaxhighlight>
  
;Parameters
+
==insertText==
* ''windowName:''
+
;insertText([windowName], text)
: name of your window, it must be unique across ALL profiles if more than one is open (for multi-playing).
+
: Inserts text at cursor postion in window - unlike [[Manual:Lua_Functions#echo|echo()]], which inserts the text at the end of the last line in the buffer (typically the one being processed by the triggers). You can use [[Manual:Lua_Functions#moveCursor|moveCursor()]] to move the cursor into position first.
* ''restoreLayout:'' (available in Mudlet 3.2+)
 
: (optional) - only relevant, if ''false'' is provided. Then the window won't be restored to its last known position.
 
* ''autoDock:'' (available in Mudlet 4.7+)
 
: (optional) - only relevant, if ''false'' is provided. Then the window won't dock automatically at the corners.
 
* ''dockingArea:'' (available in Mudlet 4.7+)
 
: (optional) - the area your UserWindow will be docked at. possible docking areas your UserWindow will be created in (f" floating "t" top "b" bottom "r" right and "l" left). Docking area is "right" if not given any value.
 
  
{{note}}
+
: insertHTML() also does the same thing as insertText, if you ever come across it.
Since Mudlet version 3.2, Mudlet will automatically remember the window's last position.
 
  
;Examples
+
: See also: [[Manual:Lua_Functions#cinsertText|cinsertText()]]
<syntaxhighlight lang="lua">
 
openUserWindow("My floating window")
 
cecho("My floating window", "<red>hello <blue>bob!")
 
  
-- if you don't want Mudlet to remember its last position:
+
; Parameters
openUserWindow("My floating window", false)
 
</syntaxhighlight>
 
 
 
==paste==
 
;paste(windowName)
 
: Pastes the previously copied text including all format codes like color, font etc. at the current user cursor position. The [[#copy | copy()]] and [[#paste | paste()]] functions can be used to copy formated text from the main window to a user window without losing colors e. g. for chat windows, map windows etc.
 
 
 
;Parameters
 
 
* ''windowName:''
 
* ''windowName:''
: The name of your window
+
: (optional) The window to insert the text to.
 +
* ''text:''
 +
: The text you will insert into the current cursor position.
  
==pauseMovie==
+
;Example
;pauseMovie(label name)
+
<syntaxhighlight lang="lua">
 +
-- move the cursor to the end of the previous line and insert some text
  
: Pauses the gif animation on the label
+
-- move to the previous line
: Returns true
+
moveCursor(0, getLineNumber()-1)
 +
-- move the end the of the previous line
 +
moveCursor(#getCurrentLine(), getLineNumber())
  
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
+
fg("dark_slate_gray")
 +
insertText(' <- that looks nice.')
  
{{MudletVersion|4.15}}
+
deselect()
 +
resetFormat()
 +
moveCursorEnd()
 +
</syntaxhighlight>
  
;Parameters
+
==ioprint==
* ''label name:''  
+
;ioprint(text, some more text, ...)
: name of the gif label
+
:Prints text to the to the stdout. This is only available if you [http://www.wikihow.com/Run-a-Program-on-Command-Prompt launched Mudlet from cmd.exe] on Windows, [http://www.wikihow.com/Open-Applications-Using-Terminal-on-Mac from the terminal] on Mac, or from the terminal on a Linux OS (launch the terminal program, type ''mudlet'' and press enter).
  
;Example
+
Similar to [[Manual:Lua_Functions#echo|echo()]], but does not require a "\n" at the end for a newline and can print several items given to it. It cannot print whole tables. This function works similarly to the print() you will see in guides for Lua.
<syntaxhighlight lang="lua">
 
-- create a label with the name myMovie
 
createLabel("myMovie",0,0,200,200,0)
 
  
-- puts the gif on the label and animates it
+
This function is useful in working out potential crashing problems with Mudlet due to your scripts - as you will still see whatever it printed when Mudlet crashes.
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
 
--stops the animation
 
pauseMovie("myMovie")
 
 
 
</syntaxhighlight>
 
 
 
==prefix==
 
;prefix(text, [writingFunction], [foregroundColor], [backgroundColor], [windowName])
 
:Prefixes text at the beginning of the current line when used in a trigger.
 
  
 
;Parameters
 
;Parameters
 
* ''text:''
 
* ''text:''
: the information you want to prefix
+
: The information you want to display.
* "writingFunction:"
 
: optional parameter, allows the selection of different functions to be used to write the text, valid options are: echo, cecho, decho, and hecho.
 
* "foregroundColor:"
 
: optional parameter, allows a foreground color to be specified if using the echo function using a color name, as with the fg() function
 
* "backgroundColor:"
 
: optional parameter, allows a background color to be specified if using the echo function using a color name, as with the bg() function
 
* "windowName:"
 
: optional parameter, allows the selection a miniconsole or the main window for the line that will be prefixed
 
 
;Example:
 
;Example:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Prefix the hours, minutes and seconds onto our prompt even though Mudlet has a button for that
+
ioprint("hi!")
prefix(os.date("%H:%M:%S "))
+
ioprint(1,2,3)
-- Prefix the time in red into a miniconsole named "my_console"
+
ioprint(myvariable, someothervariable, yetanothervariable)
prefix(os.date("<red>%H:%M:%S<reset>", cecho, nil, nil, "my_console"))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: See also: [[#suffix | suffix()]]
+
==isAnsiBgColor==
 
+
; isAnsiBgColor(bgColorCode)
==print==
+
: This function tests if the first character of '''the current selection''' in the main console has the background color specified by bgColorCode.
;print(text, some more text, ...)
 
:Prints text to the main window. Similar to [[Manual:Lua_Functions#echo|echo()]], but does not require a "\n" at the end for a newline and can print several items given to it. It cannot print whole tables - use [[Manual:Lua_Functions#display|display()]] for those. This function works similarly to the print() you will see in guides for Lua.
 
  
 
;Parameters
 
;Parameters
* ''text:''
+
* ''bgColorCode:''
: The information you want to display.
+
: A color code to test for, possible codes are:
;Example:
+
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
print("hi!")
+
0 = default text color
print(1,2,3)
+
1 = light black
print(myvariable, someothervariable, yetanothervariable)
+
2 = dark black
 +
3 = light red
 +
4 = dark red
 +
5 = light green
 +
6 = dark green
 +
7 = light yellow
 +
8 = dark yellow
 +
9 = light blue
 +
10 = dark blue
 +
11 = light magenta
 +
12 = dark magenta
 +
13 = light cyan
 +
14 = dark cyan
 +
15 = light white
 +
16 = dark white
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==raiseWindow==
+
;Example
;raiseWindow(labelName)
+
<syntaxhighlight lang="lua">
:Raises the referenced label/console above all over labels/consoles. For the opposite effect, see: [[#lowerWindow | lowerWindow()]].
+
selectString( matches[1], 1 )
 +
if isAnsiBgColor( 5 ) then
 +
    bg( "red" );
 +
    resetFormat();
 +
    echo( "yes, the background of the text is light green" )
 +
else
 +
    echo( "no sorry, some other background color" )
 +
end
 +
</syntaxhighlight>
  
;Parameters
+
{{note}}
* ''labelName:''
+
The variable named matches[1] holds the matched trigger pattern - even in substring, exact match, begin of line substring trigger patterns or even color triggers that do not know about the concept of capture groups. Consequently, you can always test if the text that has fired the trigger has a certain color and react accordingly. This function is faster than using getBgColor() and then handling the color comparison in Lua.
: the name of the label/console you wish to bring to the top of the rest.
 
  
{{MudletVersion|3.1}}
+
''Also note that the color code numbers are Mudlet specific, though they do represent the colors in the 16 ANSI color-set for the main console they are not in the same order and they additionally have the default background color in the zeroth position.''
  
; Example:
+
==isAnsiFgColor==
<syntaxhighlight lang="lua">
+
; isAnsiFgColor(fgColorCode)
createLabel("blueLabel", 300, 300, 100, 100, 1)   --creates a blue label
+
: This function tests if the first character of '''the current selection''' in the main console has the foreground color specified by fgColorCode.
setBackgroundColor("blueLabel", 50, 50, 250, 255)
 
  
createLabel("redLabel", 350, 350, 100, 100, 1)    --creates a red label which is placed on TOP of the bluewindow, as the last made label will sit at the top of the rest
+
;Parameters
setBackgroundColor("redLabel", 250, 50, 50, 255)
+
* ''fgColorCode:''
 +
: A color code to test for, possible codes are:
  
raiseWindow("blueLabel")                          --raises blueLabel back at the top, above redLabel
+
<syntaxhighlight lang="lua">
 +
0 = default text color
 +
1 = light black
 +
2 = dark black
 +
3 = light red
 +
4 = dark red
 +
5 = light green
 +
6 = dark green
 +
7 = light yellow
 +
8 = dark yellow
 +
9 = light blue
 +
10 = dark blue
 +
11 = light magenta
 +
12 = dark magenta
 +
13 = light cyan
 +
14 = dark cyan
 +
15 = light white
 +
16 = dark white
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==removeCommandLineMenuEvent==
+
;Example
;removeCommandLineMenuEvent([window,] label)
+
<syntaxhighlight lang="lua">
 
+
selectString( matches[1], 1 )
:Removes an existing command line menu event.
+
if isAnsiFgColor( 5 ) then
 
+
    bg( "red" );
;Parameters
+
    resetFormat();
* ''window:''
+
    echo( "yes, the text is light green" )
: Window that item is associated with. Optional, defaults to "main" (main window console).
+
else
* ''label:''
+
    echo( "no sorry, some other foreground color" )
: Label under which element is registered
+
end
 +
</syntaxhighlight>
  
;Returns
+
{{note}}
* Returns ''True'' If the mouse event was removed successfully.
+
The variable named matches[1] holds the matched trigger pattern - even in substring, exact match, begin of line substring trigger patterns or even color triggers that do not know about the concept of capture groups. Consequently, you can always test if the text that has fired the trigger has a certain color and react accordingly. This function is faster than using getFgColor() and then handling the color comparison in Lua.
  
==removeMouseEvent==
+
''Also note that the color code numbers are Mudlet specific, though they do represent the colors in the 16 ANSI color-set for the main console they are not in the same order and they additionally have the default foreground color in the zeroth position.''
; removeMouseEvent(uniqueName)
 
  
:Removes an existing mouse event. Returns ''True'' If the event exists and was removed successfully, throws a warning if the event doesn't exist.
+
==loadWindowLayout==
 +
;loadWindowLayout()
 +
:Resets the layout of userwindows (floating miniconsoles) to the last saved state.
  
{{MudletVersion|4.13}}
+
:See also: [[#saveWindowLayout|saveWindowLayout()]], [[#openUserWindow|openUserWindow()]]
  
;See also: [[Manual:Lua_Functions#getMouseEvents|getMouseEvents()]], [[Manual:Lua_Functions#addMouseEvent|addMouseEvent()]]
+
{{MudletVersion|3.2}}
  
;Parameters
+
;Example
* ''uniqueName:''
+
<syntaxhighlight lang="lua">
: A unique identifier that the mouse event was registered under.
+
loadWindowLayout()
 +
</syntaxhighlight>
  
;Returns
+
==lowerWindow==
* Returns ''True'' If the mouse event was removed successfully.
+
;lowerWindow(labelName)
 +
:Moves the referenced label/console below all other labels/consoles. For the opposite effect, see: [[#raiseWindow | raiseWindow()]].
  
==replace==
+
;Parameters
;replace([windowName], with, [keepcolor])
+
* ''labelName:''
:Replaces the currently selected text with the new text. To select text, use [[#selectString | selectString()]], [[#selectSection | selectSection()]] or a similar function.
+
: the name of the label/console you wish to move below the rest.
  
{{note}}
+
{{MudletVersion|3.1}}
If you’d like to delete/gag the whole line, use [[#deleteLine | deleteLine()]] instead.
 
 
 
{{note}}
 
when used outside of a trigger context (for example, in a timer instead of a trigger), replace() won't trigger the screen to refresh. Instead, use ''replace("")'' and ''insertText("new text")'' as [[#insertText | insertText()]] does.
 
 
 
See also: [[#creplace|creplace]]
 
 
 
;Parameters
 
* ''windowName:''
 
: (optional) name of window (a miniconsole)
 
* ''with:''
 
: the new text to display.
 
* ''keepcolor:''
 
: (optional) argument, setting this to ''true'' will keep the existing colors (since Mudlet 3.0+)
 
  
 
; Example:
 
; Example:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- replace word "troll" with "cute trolly"
+
createLabel("blueLabel", 300, 300, 100, 100, 1)  --creates a blue label
selectString("troll",1)
+
setBackgroundColor("blueLabel", 50, 50, 250, 255)
replace("cute trolly")
+
 
 +
createLabel("redLabel", 350, 350, 100, 100, 1)   --creates a red label which is placed on TOP of the blue label, as the last made label will sit at the top of the rest
 +
setBackgroundColor("redLabel", 250, 50, 50, 255)
  
-- replace the whole line
+
lowerWindow("redLabel")                         --lowers redLabel, causing blueLabel to be back on top
selectCurrentLine()
 
replace("Out with the old, in with the new!")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==replaceAll==
+
==moveCursor==
;replaceAll(what, with, [keepcolor])
+
;moveCursor([windowName], x, y)
: Replaces all occurrences of ''what'' in the current line with ''with''.
+
: Moves the user cursor of the window windowName, or the main window, to the absolute point (x,y). This function returns false if such a move is impossible e.g. the coordinates don’t exist. To determine the correct coordinates use [[Manual:Lua_Functions#getLineNumber|getLineNumber()]], [[Manual:Lua_Functions#getColumnNumber|getColumnNumber()]] and [[Manual:Lua_Functions#getLastLineNumber|getLastLineNumber()]]. The trigger engine will always place the user cursor at the beginning of the current line before the script is run. If you omit the windowName argument, the main screen will be used.
 +
 
 +
: Returns ''true'' or ''false'' depending on if the cursor was moved to a valid position. Check this before doing further cursor operations - because things like deleteLine() might invalidate this.
  
 
;Parameters
 
;Parameters
* ''what:''
+
* ''windowName:''
: the text to replace
+
: (optional) The window you are going to move the cursor in.
{{note}}
+
* ''x:''
This accepts [https://www.lua.org/pil/20.2.html Lua patterns]
+
: The horizontal axis in the window - that is, the letter position within the line.
* ''with:''
+
* ''y:''
: the new text to have in place
+
: The vertical axis in the window - that is, the line number.
* ''keepcolor:''
+
 
: setting this to true will keep the existing colors.
+
;Example
{{note}} keepcolor is available in Mudlet 4.10+
+
<syntaxhighlight lang="lua">
 +
-- move cursor to the start of the previous line and insert -<(
 +
-- the first 0 means we want the cursor right at the start of the line,
 +
-- and getLineNumber()-1 means we want the cursor on the current line# - 1 which
 +
-- equals to the previous line
 +
moveCursor(0, getLineNumber()-1)
 +
insertText("-<(")
 +
 
 +
-- now we move the cursor at the end of the previous line. Because the
 +
-- cursor is on the previous line already, we can use #getCurrentLine()
 +
-- to see how long it is. We also just do getLineNumber() because getLineNumber()
 +
-- returns the current line # the cursor is on
 +
moveCursor(#getCurrentLine(), getLineNumber())
 +
insertText(")>-")
  
;Examples:
+
-- finally, reset it to the end where it was after our shenaningans - other scripts
<syntaxhighlight lang="lua">
+
-- could expect the cursor to be at the end
-- replace all occurrences of the word "south" in the line with "north"
+
moveCursorEnd()
replaceAll("south", "north")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- replace all occurrences of the text that the variable "target" has
+
-- a more complicated example showing how to work with Mudlet functions
replaceAll(target, "The Bad Guy")
 
</syntaxhighlight>
 
  
==replaceLine==
+
-- set up the small system message window in the top right corner
;replaceLine ([window], text)
+
-- determine the size of your screen
: Replaces the output line from the game with your own text.
+
local WindowWidth, WindowHeight = getMainWindowSize()
See Also: [[Manual:Lua_Functions#echo|echo()]], [[Manual:Lua_Functions#insertText|insertText()]]
 
  
;Parameters
+
-- define a mini console named "sys" and set its background color
* ''window'' (optional):
+
createMiniConsole("sys",WindowWidth-650,0,650,300)
:  the window to copy the text from. Defaults to "main".
+
setBackgroundColor("sys",85,55,0,255)
* ''text:''
 
*: The text to display
 
  
;Example
+
-- you *must* set the font size, otherwise mini windows will not work properly
<syntaxhighlight lang="lua">replaceLine("[ALERT!]: "..line)
+
setMiniConsoleFontSize("sys", 12)
</syntaxhighlight>
+
-- wrap lines in window "sys" at 65 characters per line
 +
setWindowWrap("sys", 60)
 +
-- set default font colors and font style for window "sys"
 +
setTextFormat("sys",0,35,255,50,50,50,0,0,0)
 +
-- clear the window
 +
clearUserWindow("sys")
  
==replaceWildcard==
+
moveCursorEnd("sys")
;replaceWildcard(which, replacement, [keepcolor])
+
setFgColor("sys", 10,10,0)
: Replaces the given wildcard (as a number) with the given text. Equivalent to doing:
+
setBgColor("sys", 0,0,255)
 +
echo("sys", "test1---line1\n<this line is to be deleted>\n<this line is to be deleted also>\n")
 +
echo("sys", "test1---line2\n")
 +
echo("sys", "test1---line3\n")
 +
setTextFormat("sys",158,0,255,255,0,255,0,0,0);
 +
--setFgColor("sys",255,0,0);
 +
echo("sys", "test1---line4\n")
 +
echo("sys", "test1---line5\n")
 +
moveCursor("sys", 1,1)
  
<syntaxhighlight lang="lua">
+
-- deleting lines 2+3
selectString(matches[2], 1)
+
deleteLine("sys")
replace("text")
+
deleteLine("sys")
</syntaxhighlight>
 
  
;Parameters
+
-- inserting a line at pos 5,2
* ''which:''
+
moveCursor("sys", 5,2)
: Wildcard to replace.
+
setFgColor("sys", 100,100,0)
* ''replacement:''
+
setBgColor("sys", 255,100,0)
: Text to replace the wildcard with.
+
insertText("sys","############## line inserted at pos 5/2 ##############")
* ''keepcolor:''
 
: setting this to true will keep the existing colors
 
{{note}} keepcolor available in Mudlet 4.10+
 
  
;Example
+
-- inserting a line at pos 0,0
<syntaxhighlight lang="lua">
+
moveCursor("sys", 0,0)
replaceWildcard(2, "hello") -- on a perl regex trigger of ^You wave (goodbye)\.$, it will make it seem like you waved hello
+
selectCurrentLine("sys")
 +
setFgColor("sys", 255,155,255)
 +
setBold( "sys", true );
 +
setUnderline( "sys", true )
 +
setItalics( "sys", true )
 +
insertText("sys", "------- line inserted at: 0/0 -----\n")
 +
 
 +
setBold( "sys", true )
 +
setUnderline( "sys", false )
 +
setItalics( "sys", false )
 +
setFgColor("sys", 255,100,0)
 +
setBgColor("sys", 155,155,0)
 +
echo("sys", "*** This is the end. ***\n")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==resetCmdLineAction==
+
==moveCursorDown==
;resetCmdLineAction(commandLineName)
+
;moveCursorDown([windowName,] [lines,] [keepHorizontal])
: Resets the action on the command line so the it behaves like the main command line again.
+
: Moves the cursor in the given window down a specified number of lines.
 +
: See also: [[#moveCursor|moveCursor()]], [[#moveCursorUp|moveCursorUp()]], [[#moveCursorEnd|moveCursorEnd()]]
 +
 
 
;Parameters
 
;Parameters
 +
* ''windowName:''
 +
: (optional) name of the miniconsole/userwindow, or "main" for the main window.
  
* ''commandLineName''
+
* ''lines:''
: The name of the command line the action will be resetet.
+
: (optional) number of lines to move cursor down by, or 1 by default.
: See also: [[#setCmdLineAction | setCmdLineAction()]]
 
{{MudletVersion|4.10}}
 
  
==resetBackgroundImage==
+
* ''keepHorizontal:''
;resetBackgroundImage([windowName])
+
: (optional) true/false to specify if horizontal position should be retained, or reset to the start of the line otherwise.
: Resets the console background-image
 
;Parameters
 
  
* ''windowName''
+
{{MudletVersion|3.17}}
: (optional) name of the console the image will be reset
 
: See also: [[#setBackgroundImage | setBackgroundImage()]]
 
{{MudletVersion|4.10}}
 
 
 
==resetFormat==
 
;resetFormat([windowName])
 
: Resets the colour/bold/italics formatting. Always use this function when done adjusting formatting, so make sure what you've set doesn't 'bleed' onto other triggers/aliases.
 
 
 
; Parameters
 
* ''windowName''
 
: (optional) name of the console to reset formatting. Defaults to "main" if missing.
 
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">
+
'' Need example''
-- select and set the 'Tommy' to red in the line
 
if selectString("Tommy", 1) ~= -1 then fg("red") end
 
  
-- now reset the formatting, so our echo isn't red
+
==moveCursorUp==
resetFormat()
+
;moveCursorUp([windowName,] [lines,] [keepHorizontal])
echo(" Hi Tommy!")
+
: Moves the cursor in the given window up a specified number of lines.
 +
: See also: [[#moveCursor|moveCursor()]], [[#moveCursorDown|moveCursorDown()]], [[#moveCursorEnd|moveCursorEnd()]]
  
-- another example: just highlighting some words
+
;Parameters
for _, word in ipairs{"he", "she", "her", "their"} do
+
* ''windowName:''
  if selectString(word, 1) ~= -1 then
+
: (optional) name of the miniconsole/userwindow, or "main" for the main window.
    bg("blue")
 
  end
 
end
 
resetFormat()
 
</syntaxhighlight>
 
  
==resetLabelCursor==
+
* ''lines:''
;resetLabelCursor(labelName)
+
: (optional) number of lines to move cursor up by, or 1 by default.
: Resets your mouse cursor to the default one.
 
  
: See also: [[#setLabelCursor|setLabelCursor()]], [[#setLabelCustomCursor|setLabelCustomCursor()]]
+
* ''keepHorizontal:''
 +
: (optional) true/false to specify if horizontal position should be retained, or reset to the start of the line otherwise.
  
{{MudletVersion|4.8}}
+
{{MudletVersion|3.17}}
  
;Parameters
+
;Example
* ''labelName'': label for which to reset the cursor for.
+
'' Need example''
  
;Example
+
==moveCursorEnd==
<syntaxhighlight lang="lua">
+
;moveCursorEnd([windowName])
resetLabelCursor("myLabel")
+
: Moves the cursor to the end of the buffer. "main" is the name of the main window, otherwise use the name of your user window.
-- This will reset the mouse cursor over myLabel to the default one
+
: See Also: [[Manual:Lua_Functions#moveCursor|moveCursor()]]
</syntaxhighlight>
 
  
==resetLabelToolTip==
+
: Returns true or false
;resetLabelToolTip(labelName)
 
: Resets the tooltip on the given label.
 
{{MudletVersion|4.6.1}}
 
;Parameters
 
 
 
* ''labelName:''
 
: The name of the label the tooltip will be reseted.
 
: See also: [[#setLabelToolTip | setLabelToolTip()]]
 
 
 
==resetMapWindowTitle==
 
;resetMapWindowTitle()
 
: resets the title of the popped out map window to default.
 
 
 
{{MudletVersion|4.8}}
 
 
 
: See also: [[#setMapWindowTitle|setMapWindowTitle()]]
 
 
 
==resetUserWindowTitle==
 
;resetUserWindowTitle(windowName)
 
: resets the title of the UserWindow windowName
 
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: Name of the userwindow for which the title will be resetet
+
: (optional) name of the miniconsole/userwindow, or "main" for the main window.
  
{{MudletVersion|4.8}}
+
;Example
 +
'' Need example''
  
: See also: [[#setUserWindowTitle|setUserWindowTitle()]], [[#openUserWindow|openUserWindow()]]
+
==moveGauge==
 
+
;moveGauge(gaugeName, newX, newY)
==resizeWindow==
+
:Moves a gauge created with createGauge to the new x,y coordinates. Remember the coordinates are relative to the top-left corner of the output window.
;resizeWindow(windowName, width, height)
 
: Resizes a mini console, label, or floating User Windows.
 
:See also: [[#createMiniConsole | createMiniConsole()]], [[#createLabel | createLabel()]], [[#handleWindowResizeEvent | handleWindowResizeEvent()]], [[#resizeWindow | resizeWindow()]], [[#setBorderSizes | setBorderSizes()]], [[#openUserWindow | openUserWindow()]]
 
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''gaugeName:''
: The name of your window
+
: The name of your gauge
* ''width:''
+
* ''newX:''
: The new width you want
+
: The horizontal pixel location
* ''height:''
+
* ''newY:''
: The new height you want
+
: The vertical pixel location
 
 
{{note}}
 
Since Mudlet 3.7 this method can also be used on User Window consoles if they are floating.
 
 
 
==saveWindowLayout==
 
;saveWindowLayout()
 
:Saves the layout of userwindows (floating miniconsoles), in case you'd like to load them again later.
 
 
 
:See also: [[#loadWindowLayout|loadWindowLayout()]], [[#openUserWindow|openUserWindow()]]
 
 
 
{{MudletVersion|3.2}}
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
saveWindowLayout()
+
-- This would move the health bar gauge to the location 1200, 400
 +
moveGauge("healthBar", 1200, 400)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==scaleMovie==
+
==moveWindow==
;scaleMovie(label name, [autoscale])
+
;moveWindow(name, x, y)
:Resizes the gif to fill the full size of its label
+
:This function moves window name to the given x/y coordinate. The main screen cannot be moved. Instead you’ll have to set appropriate border values → preferences to move the main screen e.g. to make room for chat or information mini consoles, or other GUI elements. In the future moveWindow() will set the border values automatically if the name parameter is omitted.
  
:See also: [[#setMovie|setMovie()]], [[#startMovie|startMovie()]]
+
:See Also: [[#createMiniConsole | createMiniConsole()]], [[#createLabel | createLabel()]], [[#handleWindowResizeEvent | handleWindowResizeEvent()]], [[#resizeWindow | resizeWindow()]], [[#setBorderSizes | setBorderSizes()]], [[#openUserWindow | openUserWindow()]]
  
 
;Parameters
 
;Parameters
* ''label name:''  
+
* ''name:''
: name of the label the gif will be scaled upon
+
: The name of your window
* ''autoscale:''
+
* ''newX:''
: (optional) if false the gif will only be scaled once, resizing the label won't rescale the image
+
: The horizontal pixel location
 +
* ''newY:''
 +
: The vertical pixel location
  
{{MudletVersion|4.15}}
+
{{note}}
 +
Since Mudlet 3.7 this method can also be used on UserWindow consoles.
  
==selectCaptureGroup==
+
==openUserWindow==
;selectCaptureGroup(groupNumber)
+
;openUserWindow(windowName, [restoreLayout], [autoDock], [dockingArea])
: Selects the content of the capture group number in your Perl regular expression (from matches[]). Also works with named capture group. It does not work with multimatches.
+
: Opens a user dockable console window for user output e.g. statistics, chat etc. If a window of such a name already exists, nothing happens. You can move these windows (even to a different screen on a system with a multi-screen display), dock them on any of the four sides of the main application window, make them into notebook tabs or float them.
  
:See also: [[#selectCurrentLine| selectCurrentLine()]]
+
: See also: [[#resetUserWindowTitle|resetUserWindowTitle()]], [[#setUserWindowTitle|setUserWindowTitle()]], [[#saveWindowLayout|saveWindowLayout()]], [[#loadWindowLayout|loadWindowLayout()]]
  
 
;Parameters
 
;Parameters
* ''groupNumberOrName:''
+
* ''windowName:''
: number of the capture group you want to select, or the name of the capture group as a string
+
: name of your window, it must be unique across ALL profiles if more than one is open (for multi-playing).
 +
* ''restoreLayout:'' (available in Mudlet 3.2+)
 +
: (optional) - only relevant, if ''false'' is provided. Then the window won't be restored to its last known position.
 +
* ''autoDock:'' (available in Mudlet 4.7+)
 +
: (optional) - only relevant, if ''false'' is provided. Then the window won't dock automatically at the corners.
 +
* ''dockingArea:'' (available in Mudlet 4.7+)
 +
: (optional) - the area your UserWindow will be docked at. possible docking areas your UserWindow will be created in (f" floating "t" top "b" bottom "r" right and "l" left). Docking area is "right" if not given any value.
 +
 
 +
{{note}}
 +
Since Mudlet version 3.2, Mudlet will automatically remember the window's last position.
  
;Example
+
;Examples
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--First, set a Perl Reqular expression e.g. "you have (\d+) Euro".
+
openUserWindow("My floating window")
--If you want to color the amount of money you have green you do:
+
cecho("My floating window", "<red>hello <blue>bob!")
  
selectCaptureGroup(1)
+
-- if you don't want Mudlet to remember its last position:
setFgColor(0,255,0)
+
openUserWindow("My floating window", false)
 
 
-- Or perhaps instead if you were to use "you have (?<euro>\d+) Euro"
 
selectCaptureGroup("euro")
 
fg("green")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==selectCmdLineText==
+
==paste==
;selectCmdLineText([commandLine])
+
;paste(windowName)
: Selects the text in your command line. You can specify which one, if you got many.
+
: Pastes the previously copied text including all format codes like color, font etc. at the current user cursor position. The [[#copy | copy()]] and [[#paste | paste()]] functions can be used to copy formated text from the main window to a user window without losing colors e. g. for chat windows, map windows etc.
  
:See also: [[#createCommandLine| createCommandLine()]]
+
;Parameters
 +
* ''windowName:''
 +
: The name of your window
 +
 
 +
==pauseMovie==
 +
;pauseMovie(label name)
 +
 
 +
: Pauses the gif animation on the label
 +
: Returns true
 +
 
 +
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
  
{{MudletVersion|4.13}}
+
{{MudletVersion|4.15}}
  
 
;Parameters
 
;Parameters
* ''commandLine:''
+
* ''label name:''  
: (optional) name of the command line you want to have selected
+
: name of the gif label
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- First, create an extra commandline with the following lua script:
+
-- create a label with the name myMovie
inputContainer = inputContainer or Adjustable.Container:new({
+
createLabel("myMovie",0,0,200,200,0)
  x = 0, y = "-4c",
 
  name = "InputContainer", padding = 2,
 
  width = "100%", height = "4c",
 
  autoLoad = false
 
})
 
extraCmdLine = extraCmdLine or Geyser.CommandLine:new({
 
  name = "extraCmdLine",
 
  x = 0, y = 0, width = "100%", height = "100%"
 
}, inputContainer)
 
inputContainer:attachToBorder("bottom")
 
  
-- Now you can send the following lua code with your main command line.
+
-- puts the gif on the label and animates it
-- It will give 2 seconds time to click around, unselect its text, etc. before selecting its text for you:
+
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
lua tempTimer(2, function() selectCmdLineText() end)
+
--stops the animation
 
+
pauseMovie("myMovie")
-- This will instead select the text in the command line named extraCmdLine:
 
lua selectCmdLineText('extraCmdLine')
 
  
-- Same as before, but using the Geyser.CommandLine function instead:
 
lua extraCmdLine:selectText()
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==selectCurrentLine==
+
==prefix==
; selectCurrentLine([windowName])
+
;prefix(text, [writingFunction], [foregroundColor], [backgroundColor], [windowName])
: Selects the content of the current line that the cursor at. By default, the cursor is at the start of the current line that the triggers are processing, but you can move it with the moveCursor() function.
+
:Prefixes text at the beginning of the current line when used in a trigger.
  
{{note}}
+
;Parameters
This selects the whole line, including the linebreak - so it has a subtle difference from the slightly slower ''selectString(line, 1)'' selection method.
+
* ''text:''
: See also: [[Manual:Lua_Functions#selectString|selectString()]], [[#selectCurrentLine| selectCurrentLine()]], [[#getSelection| getSelection()]], [[Manual:Lua_Functions#getCurrentLine|getCurrentLine()]], [[#deselect|deselect()]]
+
: the information you want to prefix
 
+
* "writingFunction:"
; Parameters
+
: optional parameter, allows the selection of different functions to be used to write the text, valid options are: echo, cecho, decho, and hecho.
* ''windowName:''
+
* "foregroundColor:"
: (optional) name of the window in which to select text.
+
: optional parameter, allows a foreground color to be specified if using the echo function using a color name, as with the fg() function
 
+
* "backgroundColor:"
;Example
+
: optional parameter, allows a background color to be specified if using the echo function using a color name, as with the bg() function
 +
* "windowName:"
 +
: optional parameter, allows the selection a miniconsole or the main window for the line that will be prefixed
 +
;Example:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- color the whole line green!
+
-- Prefix the hours, minutes and seconds onto our prompt even though Mudlet has a button for that
selectCurrentLine()
+
prefix(os.date("%H:%M:%S "))
fg("green")
+
-- Prefix the time in red into a miniconsole named "my_console"
deselect()
+
prefix(os.date("<red>%H:%M:%S<reset>"), cecho, nil, nil, "my_console")
resetFormat()
+
</syntaxhighlight>
  
-- to select the previous line, you can do this:
+
: See also: [[#suffix | suffix()]]
moveCursor(0, getLineNumber()-1)
 
selectCurrentLine()
 
  
-- to select two lines back, this:
+
==print==
moveCursor(0, getLineNumber()-2)
+
;print(text, some more text, ...)
selectCurrentLine()
+
:Prints text to the main window. Similar to [[Manual:Lua_Functions#echo|echo()]], but does not require a "\n" at the end for a newline and can print several items given to it. It cannot print whole tables - use [[Manual:Lua_Functions#display|display()]] for those. This function works similarly to the print() you will see in guides for Lua.
  
</syntaxhighlight>
+
;Parameters
 +
* ''text:''
 +
: The information you want to display.
 +
;Example:
 +
<syntaxhighlight lang="lua">
 +
print("hi!")
 +
print(1,2,3)
 +
print(myvariable, someothervariable, yetanothervariable)
 +
</syntaxhighlight>
  
==selectSection==
+
==raiseWindow==
;selectSection( [windowName], fromPosition, length )
+
;raiseWindow(labelName)
: Selects the specified parts of the line starting ''from'' the left and extending to the right for however ''how long''. The line starts from 0.
+
:Raises the referenced label/console above all over labels/consoles. For the opposite effect, see: [[#lowerWindow | lowerWindow()]].
: Returns true if the selection was successful, and false if the line wasn't actually long enough or the selection couldn't be done in general.
 
  
:See also:[[#selectString| selectString()]], [[#selectCurrentLine| selectCurrentLine()]], [[#getSelection| getSelection()]]
+
;Parameters
 +
* ''labelName:''
 +
: the name of the label/console you wish to bring to the top of the rest.
  
;Parameters
+
{{MudletVersion|3.1}}
* "windowName:"
 
: (optional) name of the window in which to select text. By default the main window, if no windowName is given.
 
: Will not work if "main" is given as the windowName to try to select from the main window.
 
* ''fromPosition:''
 
: number to specify at which position in the line to begin selecting
 
* ''length:''
 
: number to specify the amount of characters you want to select
 
  
;Example
+
; Example:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- select and colour the first character in the line red
+
createLabel("blueLabel", 300, 300, 100, 100, 1)   --creates a blue label
if selectSection(0,1) then fg("red") end
+
setBackgroundColor("blueLabel", 50, 50, 250, 255)
  
-- select and colour the second character green (start selecting from the first character, and select 1 character)
+
createLabel("redLabel", 350, 350, 100, 100, 1)    --creates a red label which is placed on TOP of the bluewindow, as the last made label will sit at the top of the rest
if selectSection(1,1) then fg("green") end
+
setBackgroundColor("redLabel", 250, 50, 50, 255)
  
-- select and colour three character after the first two grey (start selecting from the 2nd character for 3 characters long)
+
raiseWindow("blueLabel")                          --raises blueLabel back at the top, above redLabel
if selectSection(2,3) then fg("grey") end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==selectString==
+
==removeCommandLineMenuEvent==
;selectString([windowName], text, number_of_match)
+
;removeCommandLineMenuEvent([window,] label)
: Selects a substring from the line where the user cursor is currently positioned - allowing you to edit selected text (apply colour, make it be a link, copy to other windows or other things).
 
  
{{note}}
+
:Removes an existing command line menu event.
You can move the user cursor with [[#moveCursor | moveCursor()]]. When a new line arrives from the game, the user cursor is positioned at the beginning of the line. However, if one of your trigger scripts moves the cursor around you need to take care of the cursor position yourself and make sure that the cursor is in the correct line if you want to call one of the select functions. To deselect text, see [[#deselect | deselect()]].
 
 
 
: See also: [[#deselect|deselect()]]
 
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''window:''
: (optional) name of the window in which to select text. By default the main window, if no windowName or an empty string is given.
+
: Window that item is associated with. Optional, defaults to "main" (main window console).
* ''text:''
+
* ''label:''
: The text to select. It is matched as a substring match (so the text anywhere within the line will get selected).
+
: Label under which element is registered
* ''number_of_match:''
 
: The occurrence of text on the line that you'd like to select. For example, if the line was "Bob and Bob", 1 would select the first Bob, and 2 would select the second Bob.
 
  
Returns position in line or -1 on error (text not found in line)
+
;Returns  
 +
* Returns ''True'' If the mouse event was removed successfully.
  
{{note}}
+
==removeMouseEvent==
To prevent working on random text if your selection didn't actually select anything, check the -1 return code before doing changes:
+
; removeMouseEvent(uniqueName)
  
;Example
+
:Removes an existing mouse event. Returns ''True'' If the event exists and was removed successfully, throws a warning if the event doesn't exist.
<syntaxhighlight lang="lua">
 
if selectString("big monster", 1) > -1 then fg("red") end
 
</syntaxhighlight>
 
  
==setAppStyleSheet==
+
{{MudletVersion|4.13}}
;setAppStyleSheet(stylesheet [, tag])
 
: Sets a stylesheet for the entire Mudlet application and every open profile. Because it affects other profiles that might not be related to yours, it's better to use [[#setProfileStyleSheet|setProfileStyleSheet()]] instead of this function.
 
  
: Raises the sysAppStyleSheetChange event which comes with two arguments in addition to the event name. The first is the optional tag which was passed into the function, or "" if nothing was given. The second is the profile which made the stylesheet changes.
+
;See also: [[Manual:Lua_Functions#getMouseEvents|getMouseEvents()]], [[Manual:Lua_Functions#addMouseEvent|addMouseEvent()]]
 
 
: See also: [[#setProfileStyleSheet|setProfileStyleSheet()]]
 
  
 
;Parameters
 
;Parameters
 +
* ''uniqueName:''
 +
: A unique identifier that the mouse event was registered under.
  
* ''stylesheet:''
+
;Returns
: The entire stylesheet you'd like to use.
+
* Returns ''True'' If the mouse event was removed successfully.
  
* ''tag:'' (available in Mudlet 3.19+)
+
==replace==
: (optional) string tag or identifier that will be passed as a second argument in the ''sysAppStyleSheetChange'' event
+
;replace([windowName], with, [keepcolor])
 +
:Replaces the currently selected text with the new text. To select text, use [[#selectString | selectString()]], [[#selectSection | selectSection()]] or a similar function.
  
;References
+
{{note}}
: See [http://qt-project.org/doc/qt-5/stylesheet-reference.html Qt Style Sheets Reference] for the list of widgets you can style and CSS properties you can apply on them.
+
If you’d like to delete/gag the whole line, use [[#deleteLine | deleteLine()]] instead.
: See also [https://github.com/vadi2/QDarkStyleSheet/blob/master/qdarkstyle/style.qss QDarkStyleSheet], a rather extensive stylesheet that shows you all the different configuration options you could apply, available as an [http://forums.mudlet.org/viewtopic.php?f=6&t=17624 mpackage here].
 
  
;Example
+
{{note}}
<syntaxhighlight lang="lua">
+
when used outside of a trigger context (for example, in a timer instead of a trigger), replace() won't trigger the screen to refresh. Instead, use ''replace("")'' and ''insertText("new text")'' as [[#insertText | insertText()]] does.
-- credit to Akaya @ http://forums.mudlet.org/viewtopic.php?f=5&t=4610&start=10#p21770
 
local background_color = "#26192f"
 
local border_color = "#b8731b"
 
  
setAppStyleSheet([[
+
See also: [[#creplace|creplace]]
  QMainWindow {
 
    background: ]]..background_color..[[;
 
  }
 
  QToolBar {
 
    background: ]]..background_color..[[;
 
  }
 
  QToolButton {
 
    background: ]]..background_color..[[;
 
    border-style: solid;
 
    border-width: 2px;
 
    border-color: ]]..border_color..[[;
 
    border-radius: 5px;
 
    font-family: BigNoodleTitling;
 
    color: white;
 
    margin: 2px;
 
    font-size: 12pt;
 
  }
 
  QToolButton:hover { background-color: grey;}
 
  QToolButton:focus { background-color: grey;}
 
]])
 
</syntaxhighlight>
 
 
 
{{MudletVersion|3.0}}
 
 
 
{{note}} Enhanced in Mudlet version 3.19.0 to generate an event that profiles/packages can utilise to redraw any parts of the UI that they themselves had previously styled so their effects can be re-applied to the new application style.
 
 
 
It is anticipated that the Mudlet application itself will make further use of application styling effects and two strings are provisionally planned for the second parameter in the ''sysAppStyleSheetChange'' event: "''mudlet-theme-dark''" and "''mudlet-theme-light''"; it will also set the third parameter to "''system''".
 
 
 
==setBackgroundColor==
 
;setBackgroundColor([windowName], r, g, b, [transparency])
 
: Sets the background for the given label, miniconsole, or userwindow. Colors are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
 
  
 
;Parameters
 
;Parameters
 
 
* ''windowName:''
 
* ''windowName:''
: (optional) name of the label/miniconsole/userwindow to change the background color on, or "main" for the main window.
+
: (optional) name of window (a miniconsole)
* ''r:''
+
* ''with:''
: Amount of red to use, from 0 (none) to 255 (full).
+
: the new text to display.
* ''g:''
+
* ''keepcolor:''
: Amount of green to use, from 0 (none) to 255 (full).
+
: (optional) argument, setting this to ''true'' will keep the existing colors (since Mudlet 3.0+)
* ''b:''
 
: Amount of red to use, from 0 (none) to 255 (full).
 
* ''transparency:''
 
: (optional) amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Defaults to 255 if omitted.
 
  
{{note}}
+
; Example:
Transparency also available for main/miniconsoles in Mudlet 4.10+
+
<syntaxhighlight lang="lua">
 +
-- replace word "troll" with "cute trolly"
 +
selectString("troll",1)
 +
replace("cute trolly")
  
;Example
+
-- replace the whole line
<syntaxhighlight lang="lua">
+
selectCurrentLine()
-- make a red label that's somewhat transparent
+
replace("Out with the old, in with the new!")
setBackgroundColor("some label",255,0,0,200)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setBackgroundImage==
+
==replaceAll==
;setBackgroundImage(labelName, imageLocation)
+
;replaceAll(what, with, [keepcolor])
;setBackgroundImage([windowname], imageLocation, [mode])
+
: Replaces all occurrences of ''what'' in the current line with ''with''.
: Loads an image file (png) as a background image for a label or console. This can be used to display clickable buttons in combination with [[Manual:Lua_Functions#setLabelClickCallback|setLabelClickCallback()]] and such.
 
  
 +
;Parameters
 +
* ''what:''
 +
: the text to replace
 
{{note}}
 
{{note}}
You can also load images on labels via [[Manual:Lua_Functions#setLabelStyleSheet|setLabelStyleSheet()]].
+
This accepts [https://www.lua.org/pil/20.2.html Lua patterns]
 +
* ''with:''
 +
: the new text to have in place
 +
* ''keepcolor:''
 +
: setting this to true will keep the existing colors.
 +
{{note}} keepcolor is available in Mudlet 4.10+
  
;Parameters (label)
+
;Examples:
 +
<syntaxhighlight lang="lua">
 +
-- replace all occurrences of the word "south" in the line with "north"
 +
replaceAll("south", "north")
 +
</syntaxhighlight>
  
* ''labelName:''
+
<syntaxhighlight lang="lua">
: The name of the label to change it's background color.
+
-- replace all occurrences of the text that the variable "target" has
* ''imageLocation:''
+
replaceAll(target, "The Bad Guy")
: The full path to the image location. It's best to use [[ ]] instead of "" for it - because for Windows paths, backslashes need to be escaped.
+
</syntaxhighlight>
  
;Parameters (consoles)
+
==replaceLine==
 +
;replaceLine ([window], text)
 +
: Replaces the output line from the game with your own text.
 +
See Also: [[Manual:Lua_Functions#echo|echo()]], [[Manual:Lua_Functions#insertText|insertText()]]
  
* ''windowName:''
+
;Parameters
: (optional) name of the miniconsole/userwindow to change the background image on, or "main" for the main window.
+
* ''window'' (optional):
* ''imageLocation:''
+
: the window to copy the text from. Defaults to "main".
: The full path to the image location. It's best to use [[ ]] instead of "" for it - because for Windows paths, backslashes need to be escaped.
+
* ''text:''
* ''mode:''
+
*: The text to display
: (optional) allows different modes for drawing the background image. Possible modes areː
 
  
** border - the background image is stretched (1)
+
;Example
** center - the background image is in the center (2),
+
<syntaxhighlight lang="lua">replaceLine("[ALERT!]: "..line)
** tile - the background image is 'tiled' (3)
+
</syntaxhighlight>
** style - choose your own background image stylesheet, see example below (4)
 
  
: See also: [[#resetBackgroundImage | resetBackgroundImage()]]
+
==replaceWildcard==
 +
;replaceWildcard(which, replacement, [keepcolor])
 +
: Replaces the given wildcard (as a number) with the given text. Equivalent to doing:
  
;Example (label)
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- give the top border a nice look
+
selectString(matches[2], 1)
setBackgroundImage("top bar", [[/home/vadi/Games/Mudlet/games/top_bar.png]])
+
replace("text")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
;Example (main/miniconsole)
+
;Parameters
 +
* ''which:''
 +
: Wildcard to replace.
 +
* ''replacement:''
 +
: Text to replace the wildcard with.
 +
* ''keepcolor:''
 +
: setting this to true will keep the existing colors
 +
{{note}} keepcolor available in Mudlet 4.10+
 +
 
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- give the main window a background image
+
replaceWildcard(2, "hello") -- on a perl regex trigger of ^You wave (goodbye)\.$, it will make it seem like you waved hello
setBackgroundImage("main", [[:/Mudlet_splashscreen_development.png]], "center")
 
 
 
-- or use your own for the main window:
 
setBackgroundImage("main", [[C:\Documents and Settings\bub\Desktop\mypicture.png]], "center")
 
 
 
-- give my_miniconsole a nice background image and put it in the center
 
setBackgroundImage("my_miniconsole", [[:/Mudlet_splashscreen_development.png]], "center")
 
 
 
-- give my_miniconsole a nice background image with own stylesheet option
 
setBackgroundImage("my_miniconsole", [[background-image: url(:/Mudlet_splashscreen_development.png); background-repeat: no-repeat; background-position: right;]], "style")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
{{note}} setBackgroundImage for main/miniconsoles and userwindows available in Mudlet 4.10+
 
  
==setBgColor==
+
==resetCmdLineAction==
;setBgColor([windowName], r, g, b, [transparency])
+
;resetCmdLineAction(commandLineName)
:Sets the current text background color in the main window unless windowName parameter given. If you have selected text prior to this call, the selection will be highlighted otherwise the current text background color will be changed. If you set a foreground or background color, the color will be used until you call resetFormat() on all further print commands.
+
: Resets the action on the command line so the it behaves like the main command line again.
 +
;Parameters
  
:If you'd like to change the background color of a window, see [[#setBackgroundColor|setBackgroundColor()]].
+
* ''commandLineName''
 +
: The name of the command line the action will be resetet.
 +
: See also: [[#setCmdLineAction | setCmdLineAction()]]
 +
{{MudletVersion|4.10}}
  
: ''See also:'' [[#cecho|cecho()]], [[#setBackgroundColor|setBackgroundColor()]]
+
==resetBackgroundImage==
 +
;resetBackgroundImage([windowName])
 +
: Resets the console background-image
 +
;Parameters
  
;Parameters
+
* ''windowName''
* ''windowName:''
+
: (optional) name of the console the image will be reset
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
+
: See also: [[#setBackgroundImage | setBackgroundImage()]]
* ''r:''
+
{{MudletVersion|4.10}}
: The red component of the gauge color. Passed as an integer number from 0 to 255
 
* ''g:''
 
: The green component of the gauge color. Passed as an integer number from 0 to 255
 
* ''b:''
 
: The blue component of the gauge color. Passed as an integer number from 0 to 255
 
* ''transparency:''
 
: Amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Optional, if not used color is fully opaque
 
  
 +
==resetFormat==
 +
;resetFormat([windowName])
 +
: Resets the colour/bold/italics formatting. Always use this function when done adjusting formatting, so make sure what you've set doesn't 'bleed' onto other triggers/aliases.
  
 +
; Parameters
 +
* ''windowName''
 +
: (optional) name of the console to reset formatting. Defaults to "main" if missing.
  
{{note}}
+
;Example
Transparency parameter available in Mudlet 4.10+
+
<syntaxhighlight lang="lua">
 +
-- select and set the 'Tommy' to red in the line
 +
if selectString("Tommy", 1) ~= -1 then fg("red") end
  
;Example
+
-- now reset the formatting, so our echo isn't red
 +
resetFormat()
 +
echo(" Hi Tommy!")
  
<syntaxhighlight lang="lua">
+
-- another example: just highlighting some words
--highlights the first occurrence of the string "Tom" in the current line with a red background color.
+
for _, word in ipairs{"he", "she", "her", "their"} do
selectString( "Tom", 1 )
+
  if selectString(word, 1) ~= -1 then
setBgColor( 255,0,0 )
+
    bg("blue")
</syntaxhighlight>
+
  end
<syntaxhighlight lang="lua">
+
end
--prints "Hello" on red background and "You" on blue.
 
setBgColor(255,0,0)
 
echo("Hello")
 
setBgColor(0,0,255)
 
echo(" You!")
 
 
resetFormat()
 
resetFormat()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setBold==
+
==resetLabelCursor==
;setBold(windowName, boolean)
+
;resetLabelCursor(labelName)
: Sets the current text font to bold (true) or non-bold (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be bolded. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will be bolded until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
+
: Resets your mouse cursor to the default one.
 +
 
 +
: See also: [[#setLabelCursor|setLabelCursor()]], [[#setLabelCustomCursor|setLabelCustomCursor()]]
  
* ''windowName:''
+
{{MudletVersion|4.8}}
: Optional parameter set the current text background color in windowname given.
 
  
* ''boolean:''
+
;Parameters
: A <code>true</code> or <code>false</code> that enables or disables bolding of text
+
* ''labelName'': label for which to reset the cursor for.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- enable bold formatting
+
resetLabelCursor("myLabel")
setBold(true)
+
-- This will reset the mouse cursor over myLabel to the default one
-- the following echo will be bolded
 
echo("hi")
 
-- turns off bolding, italics, underlines and colouring. It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
 
resetFormat()
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setBorderBottom==
+
==resetLabelToolTip==
;setBorderBottom(size)
+
;resetLabelToolTip(labelName)
: Sets the size of the bottom border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
+
: Resets the tooltip on the given label.
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderBottom|getBorderBottom()]]
+
{{MudletVersion|4.6.1}}
 
 
 
;Parameters
 
;Parameters
* ''size:''
 
: Height of the border in pixels - with 0 indicating no border.
 
  
;Example
+
* ''labelName:''
<syntaxhighlight lang="lua">
+
: The name of the label the tooltip will be reseted.
setBorderBottom(150)
+
: See also: [[#setLabelToolTip | setLabelToolTip()]]
</syntaxhighlight>
 
  
==setBorderColor==
+
==resetMapWindowTitle==
;setBorderColor(red, green, blue)
+
;resetMapWindowTitle()
: Sets the color of the main windows border that you can create either with lua commands, or via the main window settings.
+
: resets the title of the popped out map window to default.
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]]
 
  
;Parameters
+
{{MudletVersion|4.8}}
* ''red:''
 
: Amount of red color to use, from 0 to 255.
 
* ''green:''
 
: Amount of green color to use, from 0 to 255.
 
* ''blue:''
 
: Amount of blue color to use, from 0 to 255.
 
  
;Example
+
: See also: [[#setMapWindowTitle|setMapWindowTitle()]]
<syntaxhighlight lang="lua">
 
-- set the border to be completely blue
 
setBorderColor(0, 0, 255)
 
  
-- or red, using a name
+
==resetUserWindowTitle==
setBorderColor( unpack(color_table.red) )
+
;resetUserWindowTitle(windowName)
</syntaxhighlight>
+
: resets the title of the UserWindow windowName
 
 
==setBorderLeft==
 
;setBorderLeft(size)
 
: Sets the size of the left border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
 
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderLeft|getBorderLeft()]]
 
  
 
;Parameters
 
;Parameters
* ''size:''
+
* ''windowName:''
: Width of the border in pixels - with 0 indicating no border.
+
: Name of the userwindow for which the title will be resetet
  
;Example
+
{{MudletVersion|4.8}}
<syntaxhighlight lang="lua">
 
setBorderLeft(5)
 
</syntaxhighlight>
 
  
==setBorderRight==
+
: See also: [[#setUserWindowTitle|setUserWindowTitle()]], [[#openUserWindow|openUserWindow()]]
;setBorderRight(size)
 
: Sets the size of the right border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
 
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderRight|getBorderRight()]]
 
  
;Parameters
+
==resizeWindow==
* ''size:''
+
;resizeWindow(windowName, width, height)
: Width of the border in pixels - with 0 indicating no border.
+
: Resizes a mini console, label, or floating User Windows.
 +
:See also: [[#createMiniConsole | createMiniConsole()]], [[#createLabel | createLabel()]], [[#handleWindowResizeEvent | handleWindowResizeEvent()]], [[#resizeWindow | resizeWindow()]], [[#setBorderSizes | setBorderSizes()]], [[#openUserWindow | openUserWindow()]]
 +
 
 +
;Parameters
 +
* ''windowName:''
 +
: The name of your window
 +
* ''width:''
 +
: The new width you want
 +
* ''height:''
 +
: The new height you want
  
;Example
+
{{note}}
<syntaxhighlight lang="lua">
+
Since Mudlet 3.7 this method can also be used on User Window consoles if they are floating.
setBorderRight(50)
 
</syntaxhighlight>
 
  
==setBorderSizes==
+
==saveWindowLayout==
;setBorderSizes(top, right, bottom, left)
+
;saveWindowLayout()
: Sets the size of all borders of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
+
:Saves the layout of userwindows (floating miniconsoles), in case you'd like to load them again later.
: The exact result of this function depends on how many numbers you give to it as arguments.
 
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderTop|setBorderTop()]], [[Manual:Lua_Functions#setBorderRight|setBorderRight()]], [[Manual:Lua_Functions#setBorderBottom|setBorderBottom()]], [[Manual:Lua_Functions#setBorderLeft|setBorderLeft()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]]
 
  
: {{MudletVersion|4.0}}
+
:See also: [[#loadWindowLayout|loadWindowLayout()]], [[#openUserWindow|openUserWindow()]]
  
;Arguments
+
{{MudletVersion|3.2}}
* '''setBorderSizes(top, right, bottom, left)'''
 
: ''4 arguments:'' All borders will be set to their new given size.
 
* '''setBorderSizes(top, width, bottom)'''
 
: ''3 arguments:'' Top and bottom borders will be set to their new given size, and right and left will gain the same width.  
 
* '''setBorderSizes(height, width)'''
 
: ''2 arguments:'' Top and bottom borders will gain the same height, and right and left borders gain the same width.
 
* '''setBorderSizes(size)'''
 
: ''1 argument:'' All borders will be set to the same size.
 
* '''setBorderSizes()'''
 
: ''0 arguments:'' All borders will be hidden or set to size of 0 = no border.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setBorderSizes(100, 50, 150, 0)  
+
saveWindowLayout()
-- big border at the top, bigger at the bottom, small at the right, none at the left
+
</syntaxhighlight>
  
setBorderSizes(100, 50, 150)  
+
==scaleMovie==
-- big border at the top, bigger at the bottom, small at the right and the left
+
;scaleMovie(label name, [autoscale])
 +
:Resizes the gif to fill the full size of its label
 +
 
 +
:See also: [[#setMovie|setMovie()]], [[#startMovie|startMovie()]]
  
setBorderSizes(100, 50)  
+
;Parameters
-- big border at the top and the bottom, small at the right and the left
+
* ''label name:''
 +
: name of the label the gif will be scaled upon
 +
* ''autoscale:''
 +
: (optional) if false the gif will only be scaled once, resizing the label won't rescale the image
  
setBorderSizes(100)
+
{{MudletVersion|4.15}}
-- big borders at all four sides
 
  
setBorderSizes()  
+
==selectCaptureGroup==
-- no borders at all four sides
+
;selectCaptureGroup(groupNumber)
</syntaxhighlight>
+
: Selects the content of the capture group number in your Perl regular expression (from matches[]). Also works with named capture group. It does not work with multimatches.
  
==setBorderTop==
+
:See also: [[#selectCurrentLine| selectCurrentLine()]]
;setBorderTop(size)
 
: Sets the size of the top border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
 
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderTop|getBorderTop()]]
 
  
 
;Parameters
 
;Parameters
* ''size:''
+
* ''groupNumberOrName:''
: Height of the border in pixels - with 0 indicating no border.
+
: number of the capture group you want to select, or the name of the capture group as a string
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setBorderTop(100)
+
--First, set a Perl Reqular expression e.g. "you have (\d+) Euro".
 +
--If you want to color the amount of money you have green you do:
 +
 
 +
selectCaptureGroup(2)
 +
setFgColor(0,255,0)
 +
 
 +
-- Or perhaps instead if you were to use "you have (?<euro>\d+) Euro"
 +
selectCaptureGroup("euro")
 +
fg("green")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setFgColor==
+
==selectCmdLineText==
;setFgColor([windowName], red, green, blue)
+
;selectCmdLineText([commandLine])
:Sets the current text foreground color in the main window unless windowName parameter given.
+
: Selects the text in your command line. You can specify which one, if you got many.
  
* ''windowName:''
+
:See also: [[#createCommandLine| createCommandLine()]]
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
+
 
* ''red:''
+
{{MudletVersion|4.13}}
: The red component of the gauge color. Passed as an integer number from 0 to 255
 
* ''green:''
 
: The green component of the gauge color. Passed as an integer number from 0 to 255
 
* ''blue:''
 
: The blue component of the gauge color. Passed as an integer number from 0 to 255
 
  
: See also: [[#setBgColor | setBgColor()]], [[#setHexFgColor | setHexFgColor()]], [[#setHexBgColor | setHexBgColor()]], [[#resetFormat | resetFormat()]]
+
;Parameters
 +
* ''commandLine:''
 +
: (optional) name of the command line you want to have selected
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--highlights the first occurrence of the string "Tom" in the current line with a red foreground color.
+
-- First, create an extra commandline with the following lua script:
selectString( "Tom", 1 )
+
inputContainer = inputContainer or Adjustable.Container:new({
setFgColor( 255, 0, 0 )
+
  x = 0, y = "-4c",
</syntaxhighlight>
+
  name = "InputContainer", padding = 2,
 +
  width = "100%", height = "4c",
 +
  autoLoad = false
 +
})
 +
extraCmdLine = extraCmdLine or Geyser.CommandLine:new({
 +
  name = "extraCmdLine",
 +
  x = 0, y = 0, width = "100%", height = "100%"
 +
}, inputContainer)
 +
inputContainer:attachToBorder("bottom")
  
==setButtonStyleSheet==
+
-- Now you can send the following lua code with your main command line.
;setButtonStyleSheet(button, markup)
+
-- It will give 2 seconds time to click around, unselect its text, etc. before selecting its text for you:
: Applies Qt style formatting to a button via a special markup language.
+
lua tempTimer(2, function() selectCmdLineText() end)
  
; Parameters
+
-- This will instead select the text in the command line named extraCmdLine:
* ''button:''
+
lua selectCmdLineText('extraCmdLine')
: The name of the button to be formatted.
 
* ''markup:''
 
: The string instructions, as specified by the Qt Style Sheet reference.
 
: Note: You can instead use QWidget { markup }. QWidget will reference 'button', allowing the use of pseudostates like QWidget:hover and QWidget:selected
 
  
;References
+
-- Same as before, but using the Geyser.CommandLine function instead:
: https://doc.qt.io/qt-5/stylesheet-reference.html
+
lua extraCmdLine:selectText()
 +
</syntaxhighlight>
  
;Example
+
==selectCurrentLine==
<syntaxhighlight lang="lua">
+
; selectCurrentLine([windowName])
setButtonStyleSheet("my test button", [[
+
: Selects the content of the current line that the cursor at. By default, the cursor is at the start of the current line that the triggers are processing, but you can move it with the moveCursor() function.
  QWidget {
 
    background-color: #999999;
 
    border: 3px #777777;
 
  }
 
  QWidget:hover {
 
    background-color: #bbbbbb;
 
  }
 
  QWidget:checked {
 
    background-color: #77bb77;
 
    border: 3px #559955;
 
  }
 
  QWidget:hover:checked {
 
    background-color: #99dd99;
 
  } ]])</syntaxhighlight>
 
  
==setClipboardText==
+
{{note}}
;setClipboardText(textContent)
+
This selects the whole line, including the linebreak - so it has a subtle difference from the slightly slower ''selectString(line, 1)'' selection method.
: Sets the value of the computer's clipboard to the string data provided.
+
: See also: [[Manual:Lua_Functions#selectString|selectString()]],  [[#moveCursor|moveCursor()]],  [[#getSelection| getSelection()]], [[Manual:Lua_Functions#getCurrentLine|getCurrentLine()]], [[#deselect|deselect()]]
: See also: [[#getClipboardText | getClipboardText()]]
 
  
 
; Parameters
 
; Parameters
* ''textContent:''
+
* ''windowName:''
: The text to be put into the clipboard.
+
: (optional) name of the window in which to select text.
 
 
: {{note}} Note: Available in Mudlet 4.10+
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setClipboardText("New Clipboard Contents")
+
-- color the whole line green!
echo("Clipboard: " .. getClipboardText()) -- should echo "Clipboard: New Clipboard Contents"
+
selectCurrentLine()
</syntaxhighlight>
+
fg("green")
 +
deselect()
 +
resetFormat()
  
==setCmdLineAction==
+
-- to select the previous line, you can do this:
;setCmdLineAction(commandLineName, luaFunctionName, [any arguments])
+
moveCursor(0, getLineNumber()-1)
: Specifies a Lua function to be called if the user sends text to the command line. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the command line action. Additionally, this function passes the command line input text as the final argument.
+
selectCurrentLine()
{{note}} If no action is set the command line behaves like the main command line and sends commands directly to the game or alias engine.
 
  
The function specified in ''luaFunctionName'' is called like so:
+
-- to select two lines back, this:
 +
moveCursor(0, getLineNumber()-2)
 +
selectCurrentLine()
  
<syntaxhighlight lang="lua">
 
luaFuncName(optional number of arguments, text)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: See also: [[Manual:UI_Functions#resetCmdLineAction|resetCmdLineAction()]]
+
==selectSection==
 +
;selectSection( [windowName], fromPosition, length )
 +
: Selects the specified parts of the line starting ''from'' the left and extending to the right for however ''how long''. The line starts from 0.
 +
: Returns true if the selection was successful, and false if the line wasn't actually long enough or the selection couldn't be done in general.
 +
 
 +
:See also:[[#selectString| selectString()]], [[#selectCurrentLine| selectCurrentLine()]], [[#getSelection| getSelection()]]
  
 
;Parameters
 
;Parameters
 
+
* "windowName:"
* ''commandLineName:''
+
: (optional) name of the window in which to select text. By default the main window, if no windowName is given.
: The name of the command line to attach the action function to.
+
: Will not work if "main" is given as the windowName to try to select from the main window.
* ''luaFunctionName:''
+
* ''fromPosition:''
: The Lua function name to call, as a string.
+
: number to specify at which position in the line to begin selecting
* ''any arguments:''
+
* ''length:''
: (optional) Any amount of arguments you'd like to pass to the calling function.
+
: number to specify the amount of characters you want to select
 
 
{{note}} You can also pass a function directly instead of using a string
 
 
 
{{MudletVersion|4.10}}
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function sendTextToMiniConsole(miniConsoleName, cmdLineText)
+
-- select and colour the first character in the line red
  echo(miniConsoleName, cmdLineText.."\n")
+
if selectSection(0,1) then fg("red") end
end
 
  
setCmdLineAction("myCmdLine", "sendTextToMiniConsole", "myMiniConsole")
+
-- select and colour the second character green (start selecting from the first character, and select 1 character)
 +
if selectSection(1,1) then fg("green") end
  
 +
-- select and colour three character after the first two grey (start selecting from the 2nd character for 3 characters long)
 +
if selectSection(2,3) then fg("grey") end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setCmdLineStyleSheet==
+
==selectString==
;setCmdLineStyleSheet([commandLineName], markup)
+
;selectString([windowName], text, number_of_match)
: Applies Qt style formatting to a command line via a special markup language.
+
: Selects a substring from the line where the user cursor is currently positioned - allowing you to edit selected text (apply colour, make it be a link, copy to other windows or other things).
 +
 
 +
{{note}}
 +
You can move the user cursor with [[#moveCursor | moveCursor()]]. When a new line arrives from the game, the user cursor is positioned at the beginning of the line. However, if one of your trigger scripts moves the cursor around you need to take care of the cursor position yourself and make sure that the cursor is in the correct line if you want to call one of the select functions. To deselect text, see [[#deselect | deselect()]].
 +
 
 +
: See also: [[#deselect|deselect()]]
  
 
;Parameters
 
;Parameters
* ''commandLineName:''
+
* ''windowName:''
: (optional) Name of the command line (or miniconsole the command line is in). If not given the stylesheet will be applied to the main command line.
+
: (optional) name of the window in which to select text. By default the main window, if no windowName or an empty string is given.
* ''markup''
+
* ''text:''
: The string instructions, as specified by the Qt Style Sheet reference.
+
: The text to select. It is matched as a substring match (so the text anywhere within the line will get selected).
 +
* ''number_of_match:''
 +
: The occurrence of text on the line that you'd like to select. For example, if the line was "Bob and Bob", 1 would select the first Bob, and 2 would select the second Bob.
  
{{MudletVersion|4.10}}
+
Returns position in line or -1 on error (text not found in line)
  
: See also: [[Manual:UI_Functions#enableCommandLine|enableCommandLine()]], [[Manual:UI_Functions#createCommandLine|createCommandLine()]]
+
{{note}}
 +
To prevent working on random text if your selection didn't actually select anything, check the -1 return code before doing changes:
  
;Examples
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- move the main command line over to the right
+
if selectString("big monster", 1) > -1 then fg("red") end
setCmdLineStyleSheet("main", [[
+
</syntaxhighlight>
  QPlainTextEdit {
 
    padding-left: 100px; /* change 100 to your number */
 
    background-color: black; /* change it to your background color */
 
  }
 
]])
 
  
--only change font-size of your main command line
+
==setAppStyleSheet==
setCmdLineStyleSheet("main", [[
+
;setAppStyleSheet(stylesheet [, tag])
  QPlainTextEdit {
+
: Sets a stylesheet for the entire Mudlet application and every open profile. Because it affects other profiles that might not be related to yours, it's better to use [[#setProfileStyleSheet|setProfileStyleSheet()]] instead of this function.
    font-sizeː20pt;
 
  }
 
]])
 
  
--change bg/fg color of your miniconsole command line (name of the miniconsole is 'myMiniconsole'
+
: Raises the sysAppStyleSheetChange event which comes with two arguments in addition to the event name. The first is the optional tag which was passed into the function, or "" if nothing was given. The second is the profile which made the stylesheet changes.
--the command line in the miniconsole has to be enabled
 
setCmdLineStyleSheet("myMiniConsole", [[
 
  QPlainTextEdit {
 
    background: rgb(0,100,0);
 
    color: rgb(0,200,255);
 
    font-size: 10pt;
 
  }
 
]])
 
</syntaxhighlight>
 
  
==setFont==
+
: See also: [[#setProfileStyleSheet|setProfileStyleSheet()]]
;setFont(name, font)
 
: Sets the font on the given window or console name. Can be used to change font of the main console, miniconsoles, and userwindows. Prefer a monospaced font - those work best with text games. See here [https://doc.qt.io/qt-5/qfont.html#setFamily for more].
 
: See also: [[#getFont|getFont()]], [[#setFontSize|setFontSize()]], [[#getFontSize|getFontSize()]], [[#openUserWindow|openUserWindow()]], [[#getAvailableFonts|getAvailableFonts()]]
 
  
 
;Parameters
 
;Parameters
* ''name:''
 
: Optional - the window name to set font size of - can either be none or "main" for the main console, or a miniconsole / userwindow name.
 
* ''font:''
 
: The font to use.
 
  
{{MudletVersion|3.9}}
+
* ''stylesheet:''
 +
: The entire stylesheet you'd like to use.
 +
 
 +
* ''tag:'' (available in Mudlet 3.19+)
 +
: (optional) string tag or identifier that will be passed as a second argument in the ''sysAppStyleSheetChange'' event
 +
 
 +
;References
 +
: See [https://doc.qt.io/qt-6/stylesheet-reference.html Qt Style Sheets Reference] for the list of widgets you can style and CSS properties you can apply on them.
 +
: See also [https://github.com/vadi2/QDarkStyleSheet/blob/master/qdarkstyle/style.qss QDarkStyleSheet], a rather extensive stylesheet that shows you all the different configuration options you could apply, available as an [http://forums.mudlet.org/viewtopic.php?f=6&t=17624 mpackage here].
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- The following will set the "main" console window font to Ubuntu Mono, another font included in Mudlet.
+
-- credit to Akaya @ http://forums.mudlet.org/viewtopic.php?f=5&t=4610&start=10#p21770
setFont("Ubuntu Mono")
+
local background_color = "#26192f"
setFont("main", "Ubuntu Mono")
+
local border_color = "#b8731b"
  
-- This will set the font size of a miniconsole named "combat" to Ubuntu Mono.
+
setAppStyleSheet([[
setFont("combat", "Ubuntu Mono")
+
  QMainWindow {
</syntaxhighlight>
+
    background: ]]..background_color..[[;
 +
  }
 +
  QToolBar {
 +
    background: ]]..background_color..[[;
 +
  }
 +
  QToolButton {
 +
    background: ]]..background_color..[[;
 +
    border-style: solid;
 +
    border-width: 2px;
 +
    border-color: ]]..border_color..[[;
 +
    border-radius: 5px;
 +
    font-family: BigNoodleTitling;
 +
    color: white;
 +
    margin: 2px;
 +
    font-size: 12pt;
 +
  }
 +
  QToolButton:hover { background-color: grey;}
 +
  QToolButton:focus { background-color: grey;}
 +
]])
 +
</syntaxhighlight>
  
==setFontSize==
+
{{MudletVersion|3.0}}
;setFontSize(name, size)
 
: Sets a font size on the given window or console name. Can be used to change font size of the Main console as well as dockable UserWindows.
 
: See Also: [[#getFontSize|getFontSize()]], [[#openUserWindow|openUserWindow()]]
 
  
;Parameters
+
{{note}} Enhanced in Mudlet version 3.19.0 to generate an event that profiles/packages can utilise to redraw any parts of the UI that they themselves had previously styled so their effects can be re-applied to the new application style.
* ''name:''
 
: Optional - the window name to set font size of - can either be none or "main" for the main console, or a UserWindow name.
 
* ''size:''
 
: The font size to apply to the window.
 
  
{{MudletVersion|3.4}}
+
It is anticipated that the Mudlet application itself will make further use of application styling effects and two strings are provisionally planned for the second parameter in the ''sysAppStyleSheetChange'' event: "''mudlet-theme-dark''" and "''mudlet-theme-light''"; it will also set the third parameter to "''system''".
  
;Example
+
==setBackgroundColor==
<syntaxhighlight lang="lua">
+
;setBackgroundColor([windowName], r, g, b, [transparency])
-- The following will set the "main" console window font to 12-point font.
+
: Sets the background for the given label, miniconsole, or userwindow. Colors are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
setFontSize(12)
 
setFontSize("main", 12)
 
  
-- This will set the font size of a user window named "uw1" to 12-point font.
+
;Parameters
setFontSize("uw1", 12)
 
</syntaxhighlight>
 
  
==setGauge==
+
* ''windowName:''
;setGauge(gaugeName, currentValue, maxValue, gaugeText)
+
: (optional) name of the label/miniconsole/userwindow to change the background color on, or "main" for the main window.
: 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.
+
* ''r:''
 +
: Amount of red to use, from 0 (none) to 255 (full).
 +
* ''g:''
 +
: Amount of green to use, from 0 (none) to 255 (full).
 +
* ''b:''
 +
: Amount of red to use, from 0 (none) to 255 (full).
 +
* ''transparency:''
 +
: (optional) amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Defaults to 255 if omitted.
  
: See also: [[Manual:Lua_Functions#moveGauge|moveGauge()]], [[Manual:Lua_Functions#createGauge|createGauge()]], [[Manual:Lua_Functions#setGaugeText|setGaugeText()]]
+
{{note}}
 +
Transparency also available for main/miniconsoles in Mudlet 4.10+
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a gauge
+
-- make a red label that's somewhat transparent
createGauge("healthBar", 300, 20, 30, 300, nil, "green")
+
setBackgroundColor("some label",255,0,0,200)
 +
</syntaxhighlight>
  
--Change the looks of the gauge named healthBar and make it
+
==setBackgroundImage==
--fill to half of its capacity. The height is always remembered.
+
;setBackgroundImage(labelName, imageLocation)
setGauge("healthBar", 200, 400)
+
;setBackgroundImage([windowname], imageLocation, [mode])
</syntaxhighlight>
+
: Loads an image file (png) as a background image for a label or console. This can be used to display clickable buttons in combination with [[Manual:Lua_Functions#setLabelClickCallback|setLabelClickCallback()]] and such.
  
<syntaxhighlight lang="lua">
+
{{note}}
--If you wish to change the text on your gauge, you’d do the following:
+
You can also load images on labels via [[Manual:Lua_Functions#setLabelStyleSheet|setLabelStyleSheet()]].
setGauge("healthBar", 200, 400, "some text")
 
</syntaxhighlight>
 
  
==setGaugeStyleSheet==
+
;Parameters (label)
;setGaugeStyleSheet(gaugeName, css, cssback, csstext)
 
: Sets the CSS stylesheets on a gauge - one on the front (the part that resizes accoding to the values on the gauge) and one in the back. You can use [https://build-system.fman.io/qt-designer-download Qt Designer] to create stylesheets.
 
  
;Example
+
* ''labelName:''
<syntaxhighlight lang="lua">
+
: The name of the label to change it's background color.
setGaugeStyleSheet("hp_bar", [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f04141, stop: 0.1 #ef2929, stop: 0.49 #cc0000, stop: 0.5 #a40000, stop: 1 #cc0000);
+
* ''imageLocation:''
border-top: 1px black solid;
+
: The full path to the image location. It's best to use [[ ]] instead of "" for it - because for Windows paths, backslashes need to be escaped.
border-left: 1px black solid;
 
border-bottom: 1px black solid;
 
border-radius: 7;
 
padding: 3px;]],
 
[[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bd3333, stop: 0.1 #bd2020, stop: 0.49 #990000, stop: 0.5 #700000, stop: 1 #990000);
 
border-width: 1px;
 
border-color: black;
 
border-style: solid;
 
border-radius: 7;
 
padding: 3px;]])
 
</syntaxhighlight>
 
  
==setGaugeText==
+
;Parameters (consoles)
;setGaugeText(gaugename, css, ccstext )
 
: Set the formatting of the text used inside the inserted gaugename.
 
  
;Example:
+
* ''windowName:''
<syntaxhighlight lang="lua">
+
: (optional) name of the miniconsole/userwindow to change the background image on, or "main" for the main window.
setGaugeText("healthBar", [[<p style="font-weight:bold;color:#C9C9C9;letter-spacing:1pt;word-spacing:2pt;font-size:12px;text-align:center;font-family:arial black, sans-serif;">]]..MY_NUMERIC_VARIABLE_HERE..[[</p>]])</syntaxhighlight>
+
* ''imageLocation:''
 +
: The full path to the image location. It's best to use [[ ]] instead of "" for it - because for Windows paths, backslashes need to be escaped.
 +
* ''mode:''
 +
: (optional) allows different modes for drawing the background image. Possible modes areː
  
;Useful resources:
+
** border - the background image is stretched (1)
:http://csstxt.com - Generate the text exactly how you like it before pasting it into the css slot.
+
** center - the background image is in the center (2),
:https://www.w3schools.com/colors/colors_picker.asp - Can help you choose colors for your text!
+
** tile - the background image is 'tiled' (3)
 +
** style - choose your own background image stylesheet, see example below (4)
  
==setHexBgColor==
+
: See also: [[#resetBackgroundImage | resetBackgroundImage()]]
;setHexBgColor([windowName], hexColorString)
 
:Sets the current text background color in the main window unless windowName parameter given. This function allows to specify the color as a 6 character hexadecimal string.
 
  
* ''windowName:''
+
;Example (label)
: Optional parameter set the current text background color in windowname given.
+
<syntaxhighlight lang="lua">
* ''hexColorString''
+
-- give the top border a nice look
: 6 character long hexadecimal string to set the color to. The first two characters 00-FF represent the red part of the color, the next two the green and the last two characters stand for the blue part of the color
+
setBackgroundImage("top bar", [[/home/vadi/Games/Mudlet/games/top_bar.png]])
 +
</syntaxhighlight>
  
: See also: [[#setBgColor | setBgColor()]], [[#setHexFgColor | setHexFgColor()]]
+
;Example (main/miniconsole)
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--highlights the first occurrence of the string "Tom" in the current line with a red Background color.
+
-- give the main window a background image
selectString( "Tom", 1 )
+
setBackgroundImage("main", [[:/Mudlet_splashscreen_development.png]], "center")
setHexBgColor( "FF0000" )
+
 
 +
-- or use your own for the main window:
 +
setBackgroundImage("main", [[C:\Documents and Settings\bub\Desktop\mypicture.png]], "center")
 +
 
 +
-- give my_miniconsole a nice background image and put it in the center
 +
setBackgroundImage("my_miniconsole", [[:/Mudlet_splashscreen_development.png]], "center")
 +
 
 +
-- give my_miniconsole a nice background image with own stylesheet option
 +
setBackgroundImage("my_miniconsole", [[background-image: url(:/Mudlet_splashscreen_development.png); background-repeat: no-repeat; background-position: right;]], "style")
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
{{note}} setBackgroundImage for main/miniconsoles and userwindows available in Mudlet 4.10+
  
==setHexFgColor==
+
==setBgColor==
;setHexFgColor([windowName], hexColorString)
+
;setBgColor([windowName], r, g, b, [transparency])
:Sets the current text foreground color in the main window unless windowName parameter given. This function allows to specify the color as a 6 character hexadecimal string.
+
:Sets the current text background color in the main window unless windowName parameter given. If you have selected text prior to this call, the selection will be highlighted otherwise the current text background color will be changed. If you set a foreground or background color, the color will be used until you call resetFormat() on all further print commands.
 +
 
 +
:If you'd like to change the background color of a window, see [[#setBackgroundColor|setBackgroundColor()]].
 +
 
 +
: ''See also:'' [[#cecho|cecho()]], [[#setBackgroundColor|setBackgroundColor()]]
  
 +
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: Optional parameter set the current text foreground color in windowname given.
+
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
* ''hexColorString''
+
* ''r:''
: 6 character long hexadecimal string to set the color to. The first two characters 00-FF represent the red part of the color, the next two the green and the last two characters stand for the blue part of the color
+
: The red component of the gauge color. Passed as an integer number from 0 to 255
 +
* ''g:''
 +
: The green component of the gauge color. Passed as an integer number from 0 to 255
 +
* ''b:''
 +
: The blue component of the gauge color. Passed as an integer number from 0 to 255
 +
* ''transparency:''
 +
: Amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Optional, if not used color is fully opaque
 +
 
 +
 
  
: See also: [[#setFgColor | setFgColor()]], [[#setHexBgColor | setHexBgColor()]]
+
{{note}}
 +
Transparency parameter available in Mudlet 4.10+
  
 
;Example
 
;Example
 +
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--highlights the first occurrence of the string "Tom" in the current line with a red foreground color.
+
--highlights the first occurrence of the string "Tom" in the current line with a red background color.
 
selectString( "Tom", 1 )
 
selectString( "Tom", 1 )
setHexFgColor( "FF0000" )
+
setBgColor( 255,0,0 )
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="lua">
 +
--prints "Hello" on red background and "You" on blue.
 +
setBgColor(255,0,0)
 +
echo("Hello")
 +
setBgColor(0,0,255)
 +
echo(" You!")
 +
resetFormat()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setItalics==
+
==setBold==
;setItalics(windowName, bool)
+
;setBold(windowName, boolean)
: Sets the current text font to italics/non-italics mode. If the windowName parameters omitted, the main screen will be used.
+
: Sets the current text font to bold (true) or non-bold (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be bolded. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will be bolded until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
  
==setLabelToolTip==
+
* ''windowName:''
;setLabelToolTip(labelName, text, [duration])
+
: Optional parameter set the current text background color in windowname given.
: Sets a tooltip on the given label.
 
{{MudletVersion|4.6.1}}
 
;Parameters
 
  
* ''labelName:''
+
* ''boolean:''
: The name of the label to set the tooltip to.
+
: A <code>true</code> or <code>false</code> that enables or disables bolding of text
* ''text:''
 
: The text to be shown. Can contain Qt rich text formats.
 
* ''duration:''
 
: Duration of the tooltip timeout in seconds. Optional, if not set the default duration will be set.
 
 
 
: See also: [[Manual:UI_Functions#resetLabelToolTip|resetLabelToolTip()]]
 
 
 
==setLabelClickCallback==
 
;setLabelClickCallback(labelName, luaFunctionName, [any arguments])
 
: Specifies a Lua function to be called if the user clicks on the label/image. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument. This table contains information about the mouse button clicked, other buttons that were pressed at the time, and the mouse cursor's local (relative to the label) and global (relative to the Mudlet window) position. The function specified in ''luaFunctionName'' is called like so:
 
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
luaFuncName(optional number of arguments, event)
+
-- enable bold formatting
 +
setBold(true)
 +
-- the following echo will be bolded
 +
echo("hi")
 +
-- turns off bolding, italics, underlines and colouring. It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
 +
resetFormat()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
where '''event''' has the following structure:
+
==setBorderBottom==
 +
;setBorderBottom(size)
 +
: Sets the size of the bottom border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
 +
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderBottom|getBorderBottom()]]
 +
 
 +
;Parameters
 +
* ''size:''
 +
: Height of the border in pixels - with 0 indicating no border.
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
event = {
+
setBorderBottom(150)
  x = 100,
 
  y = 200,
 
  globalX = 300,
 
  globalY = 320,
 
  button = "LeftButton",
 
  buttons = {"RightButton", "MidButton"},
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: See also: [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]],[[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
+
==setBorderColor==
 +
;setBorderColor(red, green, blue)
 +
: Sets the color of the main windows border that you can create either with lua commands, or via the main window settings.
 +
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]]
  
 
;Parameters
 
;Parameters
 +
* ''red:''
 +
: Amount of red color to use, from 0 to 255.
 +
* ''green:''
 +
: Amount of green color to use, from 0 to 255.
 +
* ''blue:''
 +
: Amount of blue color to use, from 0 to 255.
  
* ''labelName:''
+
;Example
: The name of the label to attach a callback function to.
+
<syntaxhighlight lang="lua">
* ''luaFunctionName:''
+
-- set the border to be completely blue
: Lua function to call, or the function name, as a string.
+
setBorderColor(0, 0, 255)
* ''any arguments:''
 
: (optional) Any amount of arguments you'd like to pass to the calling function.
 
  
{{note}} Event argument is available in 3.6+, and in 4.8+ you can pass a function directly instead of a string.
+
-- or red, using a name
 +
setBorderColor( unpack(color_table.red) )
 +
</syntaxhighlight>
 +
 
 +
==setBorderLeft==
 +
;setBorderLeft(size)
 +
: Sets the size of the left border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
 +
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderLeft|getBorderLeft()]]
 +
 
 +
;Parameters
 +
* ''size:''
 +
: Width of the border in pixels - with 0 indicating no border.
  
{{note}}
 
While '''event.button''' may contain a single string of any listed below, '''event.buttons''' will only ever contain some combination of "LeftButton", "MidButton", and "RightButton"
 
:The following mouse button strings are defined:
 
<pre>
 
"LeftButton"        "RightButton"        "MidButton"
 
"BackButton"        "ForwardButton"      "TaskButton"
 
"ExtraButton4"      "ExtraButton5"      "ExtraButton6"
 
"ExtraButton7"      "ExtraButton8"      "ExtraButton9"
 
"ExtraButton10"    "ExtraButton11"      "ExtraButton12"
 
"ExtraButton13"    "ExtraButton14"      "ExtraButton15"
 
"ExtraButton16"    "ExtraButton17"      "ExtraButton18"
 
"ExtraButton19"    "ExtraButton20"      "ExtraButton21"
 
"ExtraButton22"    "ExtraButton23"      "ExtraButton24"
 
</pre>
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
createLabel("testLabel", 50, 50, 100, 100, 0)
+
setBorderLeft(5)
 +
</syntaxhighlight>
  
function onClickGoNorth(event)
+
==setBorderRight==
  if event.button == "LeftButton" then
+
;setBorderRight(size)
    send("walk north")
+
: Sets the size of the right border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
  elseif event.button == "RightButton" then
+
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderRight|getBorderRight()]]
    send("swim north")
 
  elseif event.button == "MidButton" then
 
    send("gallop north")
 
  end
 
end
 
  
setLabelClickCallback("testLabel", "onClickGoNorth")
+
;Parameters
 +
* ''size:''
 +
: Width of the border in pixels - with 0 indicating no border.
  
-- you can also use them within tables:
+
;Example
mynamespace =
+
<syntaxhighlight lang="lua">
  {
+
setBorderRight(50)
    onClickGoNorth =
 
      function()
 
        echo("the north button was clicked!")
 
      end,
 
  }
 
setLabelClickCallback("testLabel", "mynamespace.onClickGoNorth")
 
 
 
-- or by passing the function directly:
 
setLabelClickCallback("testLabel", onClickGoNorth)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLabelDoubleClickCallback==
+
==setBorderSizes==
;setLabelDoubleClickCallback(labelName, luaFunctionName, [any arguments])
+
;setBorderSizes(top, right, bottom, left)
: Specifies a Lua function to be called if the user double clicks on the label/image. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]]
+
: Sets the size of all borders of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
 +
: The exact result of this function depends on how many numbers you give to it as arguments.
 +
: See also: [[Manual:Lua_Functions#getBorderSizes|getBorderSizes()]], [[Manual:Lua_Functions#setBorderTop|setBorderTop()]], [[Manual:Lua_Functions#setBorderRight|setBorderRight()]], [[Manual:Lua_Functions#setBorderBottom|setBorderBottom()]], [[Manual:Lua_Functions#setBorderLeft|setBorderLeft()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]]
  
{{MudletVersion|3.6}}
+
: {{MudletVersion|4.0}}
  
: See also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
+
;Arguments
 +
* '''setBorderSizes(top, right, bottom, left)'''
 +
: ''4 arguments:'' All borders will be set to their new given size.
 +
* '''setBorderSizes(top, width, bottom)'''
 +
: ''3 arguments:'' Top and bottom borders will be set to their new given size, and right and left will gain the same width.
 +
* '''setBorderSizes(height, width)'''
 +
: ''2 arguments:'' Top and bottom borders will gain the same height, and right and left borders gain the same width.
 +
* '''setBorderSizes(size)'''
 +
: ''1 argument:'' All borders will be set to the same size.
 +
* '''setBorderSizes()'''
 +
: ''0 arguments:'' All borders will be hidden or set to size of 0 = no border.
  
;Parameters
+
;Example
 +
<syntaxhighlight lang="lua">
 +
setBorderSizes(100, 50, 150, 0)
 +
-- big border at the top, bigger at the bottom, small at the right, none at the left
  
* ''labelName:''
+
setBorderSizes(100, 50, 150)
: The name of the label to attach a callback function to.
+
-- big border at the top, bigger at the bottom, small at the right and the left
* ''luaFunctionName:''
 
: The Lua function name to call, as a string.
 
* ''any arguments:''
 
: (optional) Any amount of arguments you'd like to pass to the calling function.
 
  
==setLabelMoveCallback==
+
setBorderSizes(100, 50)  
;setLabelMoveCallback(labelName, luaFunctionName, [any arguments])
+
-- big border at the top and the bottom, small at the right and the left
: Specifies a Lua function to be called when the mouse moves while inside the specified label/console. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]]
 
  
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
+
setBorderSizes(100)  
 +
-- big borders at all four sides
  
;Parameters
+
setBorderSizes()
 +
-- no borders at all four sides
 +
</syntaxhighlight>
  
* ''labelName:''
+
==setBorderTop==
: The name of the label to attach a callback function to.
+
;setBorderTop(size)
* ''luaFunctionName:''
+
: Sets the size of the top border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
: The Lua function name to call, as a string.
+
: See Also: [[Manual:Lua_Functions#setBorderSizes|setBorderSizes()]], [[Manual:Lua_Functions#setBorderColor|setBorderColor()]], [[Manual:Lua_Functions#getBorderTop|getBorderTop()]]
* ''any arguments:''
 
: (optional) Any amount of arguments you'd like to pass to the calling function.
 
  
{{MudletVersion|3.6}}
+
;Parameters
 
+
* ''size:''
==setLabelOnEnter==
+
: Height of the border in pixels - with 0 indicating no border.
;setLabelOnEnter(labelName, luaFunctionName, [any arguments])
 
: Specifies a Lua function to be called when the mouse enters within the labels borders. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, similar to [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], but with slightly different information.
 
: For this callback, the '''event''' argument has the following structure:
 
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
event = {
+
setBorderTop(100)
  x = 100,
 
  y = 200,
 
  globalX = 300,
 
  globalY = 320,
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
+
==setFgColor==
 +
;setFgColor([windowName], red, green, blue)
 +
:Sets the current text foreground color in the main window unless windowName parameter given.
  
;Parameters
+
* ''windowName:''
 +
: (optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
 +
* ''red:''
 +
: The red component of the gauge color. Passed as an integer number from 0 to 255
 +
* ''green:''
 +
: The green component of the gauge color. Passed as an integer number from 0 to 255
 +
* ''blue:''
 +
: The blue component of the gauge color. Passed as an integer number from 0 to 255
  
* ''labelName:''
+
: See also: [[#setBgColor | setBgColor()]], [[#setHexFgColor | setHexFgColor()]], [[#setHexBgColor | setHexBgColor()]], [[#resetFormat | resetFormat()]]
: The name of the label to attach a callback function to.
 
* ''luaFunctionName:''
 
: The Lua function name to call, as a string - it must be registered as a global function, and not inside any namespaces (tables).
 
* ''any arguments:''
 
: (optional) Any amount of arguments you'd like to pass to the calling function.
 
  
 
;Example
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onMouseOver()
+
--highlights the first occurrence of the string "Tom" in the current line with a red foreground color.
  echo("The mouse is hovering over the label!\n")
+
selectString( "Tom", 1 )
end
+
setFgColor( 255, 0, 0 )
 
 
setLabelOnEnter( "compassNorthImage", "onMouseOver" )
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLabelOnLeave==
+
==setButtonStyleSheet==
;setLabelOnLeave(labelName, luaFunctionName, [any arguments])
+
;setButtonStyleSheet(button, markup)
: Specifies a Lua function to be called when the mouse leaves the labels borders. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button.
+
: Applies Qt style formatting to a button via a special markup language.
  
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]]
+
; Parameters
 +
* ''button:''
 +
: The name of the button to be formatted.
 +
* ''markup:''
 +
: The string instructions, as specified by the Qt Style Sheet reference.
 +
: Note: You can instead use QWidget { markup }. QWidget will reference 'button', allowing the use of pseudostates like QWidget:hover and QWidget:selected
  
;Parameters
+
;References
 +
: https://doc.qt.io/qt-5/stylesheet-reference.html
  
* ''labelName:''
+
;Example
: The name of the label to attach a callback function to.
+
<syntaxhighlight lang="lua">
* ''luaFunctionName:''
+
setButtonStyleSheet("my test button", [[
: The Lua function name to call, as a string - it must be registered as a global function, and not inside any namespaces (tables).
+
  QWidget {
* ''any arguments:''
+
    background-color: #999999;
: (optional) Any amount of arguments you'd like to pass to the calling function.
+
    border: 3px #777777;
 +
  }
 +
  QWidget:hover {
 +
    background-color: #bbbbbb;
 +
  }
 +
  QWidget:checked {
 +
    background-color: #77bb77;
 +
    border: 3px #559955;
 +
  }
 +
  QWidget:hover:checked {
 +
    background-color: #99dd99;
 +
  } ]])</syntaxhighlight>
 +
 
 +
==setClipboardText==
 +
;setClipboardText(textContent)
 +
: Sets the value of the computer's clipboard to the string data provided.
 +
: See also: [[#getClipboardText | getClipboardText()]]
 +
 
 +
; Parameters
 +
* ''textContent:''
 +
: The text to be put into the clipboard.
 +
 
 +
: {{note}} Note: Available in Mudlet 4.10+
  
 
;Example
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onMouseLeft(argument)
+
setClipboardText("New Clipboard Contents")
  echo("The mouse quit hovering over the label the label! We also got this as data on the function: "..argument)
+
echo("Clipboard: " .. getClipboardText()) -- should echo "Clipboard: New Clipboard Contents"
end
 
 
 
setLabelOnLeave( "compassNorthImage", "onMouseLeft", "argument to pass to function" )
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLabelReleaseCallback==
+
==setCmdLineAction==
;setLabelReleaseCallback(labelName, luaFunctionName, [any arguments])
+
;setCmdLineAction(commandLineName, luaFunctionName, [any arguments])
: Specifies a Lua function to be called when a mouse click ends that originated on the specified label/console. This function is called even if you drag the mouse off of the label/console before releasing the click. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]]
+
: Specifies a Lua function to be called if the user sends text to the command line. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the command line action. Additionally, this function passes the command line input text as the final argument.
 
+
{{note}} If no action is set the command line behaves like the main command line and sends commands directly to the game or alias engine.
{{MudletVersion|3.0}}
+
 
 +
The function specified in ''luaFunctionName'' is called like so:
 +
 
 +
<syntaxhighlight lang="lua">
 +
luaFuncName(optional number of arguments, text)
 +
</syntaxhighlight>
  
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
+
: See also: [[Manual:UI_Functions#resetCmdLineAction|resetCmdLineAction()]]
  
 
;Parameters
 
;Parameters
  
* ''labelName:''
+
* ''commandLineName:''
: The name of the label to attach a callback function to.
+
: The name of the command line to attach the action function to.
 
* ''luaFunctionName:''
 
* ''luaFunctionName:''
 
: The Lua function name to call, as a string.
 
: The Lua function name to call, as a string.
Line 4,181: Line 4,239:
 
: (optional) Any amount of arguments you'd like to pass to the calling function.
 
: (optional) Any amount of arguments you'd like to pass to the calling function.
  
{{note}}
+
{{note}} You can also pass a function directly instead of using a string
The ''event'' argument only available since Mudlet 3.6
+
 
 +
{{MudletVersion|4.10}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onReleaseNorth()
+
function sendTextToMiniConsole(miniConsoleName, cmdLineText)
   echo("the north button was released!")
+
   echo(miniConsoleName, cmdLineText.."\n")
 
end
 
end
  
setLabelReleaseCallback( "compassNorthImage", "onReleaseNorth" )
+
setCmdLineAction("myCmdLine", "sendTextToMiniConsole", "myMiniConsole")
 
 
-- you can also use them within tables:
 
mynamespace = {
 
  onReleaseNorth = function()
 
    echo("the north button was released!")
 
  end
 
}
 
  
setLabelReleaseCallback( "compassNorthImage", "mynamespace.onReleaseNorth" )
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLabelStyleSheet==
+
==setCmdLineStyleSheet==
;setLabelStyleSheet(label, markup)
+
;setCmdLineStyleSheet([commandLineName], markup)
: Applies Qt style formatting to a label via a special markup language.
+
: Applies Qt style formatting to a command line via a special markup language.
  
; Parameters
+
;Parameters
* ''label:''
+
* ''commandLineName:''
: The name of the label to be formatted (passed when calling createLabel).
+
: (optional) Name of the command line (or miniconsole the command line is in). If not given the stylesheet will be applied to the main command line.
* ''markup:''
+
* ''markup''
 
: The string instructions, as specified by the Qt Style Sheet reference.
 
: The string instructions, as specified by the Qt Style Sheet reference.
: Note that when specifying a file path for styling purposes, forward slashes, / , must be used, even if your OS uses backslashes, \ , normally.
 
  
;References
+
{{note}} Moving the command line over can adjust the other elements on the same horizontal axis, such as the search feature, buttons and network latency monitor.  These additional components can take up to 30% of the screen size (400px when <code>getMainWindowSize()</code> was returning 1216px width). Don't go too aggressive with the numbers at first otherwise it will push elements off screen. Moving the command line over 250px on the above monitor also needed modifying of the <code>width</code> and <code>max-width</code> CSS properties.
: https://doc.qt.io/qt-5/stylesheet-reference.html
+
<code>setCmdLineStyleSheet("main", [[QPlainTextEdit {margin-left: 250px; max-width: 562px; width: 562px}]])</code>
 +
 
 +
{{MudletVersion|4.10}}
 +
 
 +
: See also: [[Manual:UI_Functions#enableCommandLine|enableCommandLine()]], [[Manual:UI_Functions#createCommandLine|createCommandLine()]]
  
;Example
+
;Examples
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- This creates a label with a white background and a green border, with the text "test"
+
-- move the main command line over to the right
-- inside.
+
setCmdLineStyleSheet("main", [[
createLabel("test", 50, 50, 100, 100, 0)
+
   QPlainTextEdit {
setLabelStyleSheet("test", [[
+
    margin-left: 100px; /* change 100 to your number */
   background-color: white;
+
    background-color: black; /* change it to your background color */
  border: 10px solid green;
+
   }
   font-size: 12px;
+
]])
  ]])
+
 
echo("test", "test")
+
--only change font-size of your main command line
</syntaxhighlight>
+
setCmdLineStyleSheet("main", [[
<syntaxhighlight lang="lua">
+
   QPlainTextEdit {
-- This creates a label with a single image, that will tile or clip depending on the
+
    font-sizeː20pt;  
-- size of the label. To use this example, please supply your own image.
+
   }
createLabel("test5", 50, 353, 164, 55, 0)
+
]])
setLabelStyleSheet("test5", [[
+
 
   background-image: url("C:/Users/Administrator/.config/mudlet/profiles/Midkemia Online/Vyzor/MkO_logo.png");
+
--change the border colour of your main command line to a nice blue
   ]])
+
setCmdLineStyleSheet("main", "QPlainTextEdit {background-color: #000000; border: 1px solid #4987d2;}")
</syntaxhighlight>
+
 
<syntaxhighlight lang="lua">
+
--change bg/fg color of your miniconsole command line (name of the miniconsole is 'myMiniconsole'
-- This creates a label with a single image, that can be resized (such as during a
+
--the command line in the miniconsole has to be enabled
-- sysWindowResizeEvent). To use this example, please supply your own image.
+
setCmdLineStyleSheet("myMiniConsole", [[
createLabel("test9", 215, 353, 100, 100, 0)
+
  QPlainTextEdit {
setLabelStyleSheet("test9", [[
+
    background: rgb(0,100,0);
  border-image: url("C:/Users/Administrator/.config/mudlet/profiles/Midkemia Online/Vyzor/MkO_logo.png");
+
    color: rgb(0,200,255);
   ]])
+
    font-size: 10pt;
 +
   }
 +
]])
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==setFont==
 +
;setFont(name, font)
 +
: Sets the font on the given window or console name. Can be used to change font of the main console, miniconsoles, and userwindows. Prefer a monospaced font - those work best with text games. See here [https://doc.qt.io/qt-5/qfont.html#setFamily for more].
 +
: See also: [[#getFont|getFont()]], [[#setFontSize|setFontSize()]], [[#getFontSize|getFontSize()]], [[#openUserWindow|openUserWindow()]], [[#getAvailableFonts|getAvailableFonts()]]
 +
 +
;Parameters
 +
* ''name:''
 +
: Optional - the window name to set font size of - can either be none or "main" for the main console, or a miniconsole / userwindow name.
 +
* ''font:''
 +
: The font to use.
 +
 +
{{MudletVersion|3.9}}
 +
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--This creates a label whose background changes when the users mouse hovers over it.
+
-- The following will set the "main" console window font to Ubuntu Mono, another font included in Mudlet.
 +
setFont("Ubuntu Mono")
 +
setFont("main", "Ubuntu Mono")
  
--putting the styleSheet in a variable allows us to easily change the styleSheet. We also are placing colors in variables that have been preset.
+
-- This will set the font size of a miniconsole named "combat" to Ubuntu Mono.
local labelBackgroundColor = "#123456"
+
setFont("combat", "Ubuntu Mono")
local labelHoverColor = "#654321"
+
</syntaxhighlight>
local labelFontSize = 12
+
 
local labelName = "HoverLabel"
+
==setFontSize==
local ourLabelStyle = [[
+
;setFontSize(name, size)
QLabel{
+
: Sets a font size on the given window or console name. Can be used to change font size of the Main console as well as dockable UserWindows.
background-color: ]]..labelBackgroundColor..[[;
+
: See Also: [[#getFontSize|getFontSize()]], [[#openUserWindow|openUserWindow()]]
font-size: ]]..labelFontSize..[[px;
+
 
qproperty-alignment: 'AlignCenter | AlignCenter';
+
;Parameters
}
+
* ''name:''
QLabel::hover{
+
: Optional - the window name to set font size of - can either be none or "main" for the main console, or a UserWindow name.
background-color: ]]..labelHoverColor..[[;
+
* ''size:''
font-size: ]]..labelFontSize..[[px;
+
: The font size to apply to the window.
qproperty-alignment: 'AlignCenter | AlignCenter';
+
 
}
+
{{MudletVersion|3.4}}
]]
 
  
--Creating the label using the labelName and ourLabelStyle variables created above.
+
;Example
createLabel(labelName,0,0,400,400,1)
 
setLabelStyleSheet(labelName, ourLabelStyle)
 
echo("HoverLabel","This text shows while mouse is or is not over the label.")
 
</syntaxhighlight>
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--Using QLabel::hover mentioned above. Lets "trick" the label into changing it's text.
+
-- The following will set the "main" console window font to 12-point font.
--Please keep in mind that the setLabelMoveCallback allows for much more control over not just your label but your entire project.
+
setFontSize(12)
 +
setFontSize("main", 12)
  
--putting the styleSheet in a variable allows us to easily change the styleSheet. We also are placing colors in variables that have been preset. 
+
-- This will set the font size of a user window named "uw1" to 12-point font.
local labelBackgroundColor = "#123456"
+
setFontSize("uw1", 12)
local labelHoverColor = "#654321"
 
local labelFontSize = 12
 
local labelName = "HoverLabel"
 
--Notice we are adding a string returned from a function. In this case, the users profile directory.
 
local ourLabelStyle = [[
 
QLabel{
 
border-image: url("]]..getMudletHomeDir()..[[/imagewithtext.png");
 
}
 
QLabel::hover{
 
border-image: url("]]..getMudletHomeDir()..[[/imagewithhovertext.png");
 
}
 
]]
 
 
 
--Creating the label using the labelName and ourLabelStyle variables created above.
 
createLabel(labelName,0,0,400,400,1)
 
setLabelStyleSheet(labelName, ourLabelStyle)
 
--This is just to example that echos draw on top of the label. You would not want to echo onto a label you were drawing text on with images, because echos would draw on top of them.
 
echo("HoverLabel","This text shows while mouse is or is not over the label.")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLabelCursor==
+
==setGauge==
;setLabelCursor(labelName, cursorShape)
+
;setGauge(gaugeName, currentValue, maxValue, gaugeText)
: Changes how the mouse cursor looks like when over the label. To reset the cursor shape, use [[#resetLabelCursor|resetLabelCursor()]].
+
: 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.
  
: See also: [[#resetLabelCursor|resetLabelCursor()]], [[#setLabelCustomCursor|setLabelCustomCursor()]]
+
: See also: [[Manual:Lua_Functions#moveGauge|moveGauge()]], [[Manual:Lua_Functions#createGauge|createGauge()]], [[Manual:Lua_Functions#setGaugeText|setGaugeText()]]
  
{{MudletVersion|4.8}}
 
 
;Parameters
 
* ''labelName:''
 
: Name of the label which you want the mouse cursor change at.
 
* ''cursorShape''
 
: Shape of the mouse cursor. List of possible cursor shapes is [[CursorShapes| available here]].
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setLabelCursor("myLabel", "Cross")
+
-- create a gauge
-- This will change the mouse cursor to a cross if it's over the label myLabel
+
createGauge("healthBar", 300, 20, 30, 300, nil, "green")
 +
 
 +
--Change the looks of the gauge named healthBar and make it
 +
--fill to half of its capacity. The height is always remembered.
 +
setGauge("healthBar", 200, 400)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLabelCustomCursor==
+
<syntaxhighlight lang="lua">
;setLabelCustomCursor(labelName, custom cursor, [hotX, hotY])
+
--If you wish to change the text on your gauge, you’d do the following:
: Changes the mouse cursor shape over your label to a custom cursor. To reset the cursor shape, use [[#resetLabelCursor|resetLabelCursor()]].
+
setGauge("healthBar", 200, 400, "some text")
 +
</syntaxhighlight>
  
: See also: [[#resetLabelCursor|resetLabelCursor()]], [[#setLabelCursor|setLabelCursor()]]
+
==setGaugeStyleSheet==
 +
;setGaugeStyleSheet(gaugeName, css, cssback, csstext)
 +
: Sets the CSS stylesheets on a gauge - one on the front (the part that resizes according to the values on the gauge) and one in the back. You can use [https://build-system.fman.io/qt-designer-download Qt Designer] to create stylesheets.
  
{{MudletVersion|4.8}}
 
 
;Parameters
 
* ''labelName:''
 
: Name of the label which you want the mouse cursor change at.
 
* ''custom cursor''
 
: Location of your custom cursor file. To be compatible with all systems it is recommended to use png files with size of 32x32.
 
* ''hotX''
 
: X-coordinate of the cursors hotspot position. Optional, if not set it is set to -1 which is in the middle of your custom cursor.
 
* ''hotY''
 
: Y-coordinate of the cursors hotspot position. Optional, if not set it is set to -1 which is in the middle of your custom cursor.
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setLabelCustomCursor("myLabel", getMudletHomeDir().."/custom_cursor.png")
+
setGaugeStyleSheet("hp_bar", [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f04141, stop: 0.1 #ef2929, stop: 0.49 #cc0000, stop: 0.5 #a40000, stop: 1 #cc0000);
-- This will change the mouse cursor to your custom cursor if it's over the label myLabel
+
border-top: 1px black solid;
 +
border-left: 1px black solid;
 +
border-bottom: 1px black solid;
 +
border-radius: 7;
 +
padding: 3px;]],
 +
[[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bd3333, stop: 0.1 #bd2020, stop: 0.49 #990000, stop: 0.5 #700000, stop: 1 #990000);
 +
border-width: 1px;
 +
border-color: black;
 +
border-style: solid;
 +
border-radius: 7;
 +
padding: 3px;]])
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLabelWheelCallback==
+
==setGaugeText==
;setLabelWheelCallback(labelName, luaFunctionName, [any arguments])
+
;setGaugeText(gaugename, css, ccstext )
: Specifies a Lua function to be called when the mouse wheel is scrolled while inside the specified label/console. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, similar to [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], but with slightly different information.
+
: Set the formatting of the text used inside the inserted gaugename.
: For this callback, the ''event'' argument has the following structure:
 
  
 +
;Example:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
event = {
+
setGaugeText("healthBar", [[<p style="font-weight:bold;color:#C9C9C9;letter-spacing:1pt;word-spacing:2pt;font-size:12px;text-align:center;font-family:arial black, sans-serif;">]]..MY_NUMERIC_VARIABLE_HERE..[[</p>]])</syntaxhighlight>
  x = 100,
 
  y = 200,
 
  globalX = 300,
 
  globalY = 320,
 
  buttons = {"RightButton", "MidButton"},
 
  angleDeltaX = 0,
 
  angleDeltaY = 120
 
}
 
</syntaxhighlight>
 
  
: Keys ''angleDeltaX'' and ''angleDeltaY'' correspond with the horizontal and vertical scroll distance, respectively. For most mice, these values will be multiples of 120.
+
;Useful resources:
 +
:https://www.w3schools.com/colors/colors_picker.asp - Can help you choose colors for your text!
  
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
+
==setHexBgColor==
 +
;setHexBgColor([windowName], hexColorString)
 +
:Sets the current text background color in the main window unless windowName parameter given. This function allows to specify the color as a 6 character hexadecimal string.
  
;Parameters
+
* ''windowName:''
 +
: Optional parameter set the current text background color in windowname given.
 +
* ''hexColorString''
 +
: 6 character long hexadecimal string to set the color to. The first two characters 00-FF represent the red part of the color, the next two the green and the last two characters stand for the blue part of the color
  
* ''labelName:''
+
: See also: [[#setBgColor | setBgColor()]], [[#setHexFgColor | setHexFgColor()]]
: The name of the label to attach a callback function to.
 
* ''luaFunctionName:''
 
: The Lua function name to call, as a string.
 
* ''any arguments:''
 
: (optional) Any amount of arguments you'd like to pass to the calling function.
 
 
 
{{MudletVersion|3.6}}
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onWheelNorth(event)
+
--highlights the first occurrence of the string "Tom" in the current line with a red Background color.
  if event.angleDeltaY > 0 then
+
selectString( "Tom", 1 )
    echo("the north button was wheeled forwards over!")
+
setHexBgColor( "FF0000" )
  else
+
</syntaxhighlight>
    echo("the north button was wheeled backwards over!")
 
  end
 
end
 
  
setLabelWheelCallback( "compassNorthImage", "onWheelNorth" )
+
==setHexFgColor==
 +
;setHexFgColor([windowName], hexColorString)
 +
:Sets the current text foreground color in the main window unless windowName parameter given. This function allows to specify the color as a 6 character hexadecimal string.
  
-- you can also use them within tables:
+
* ''windowName:''
mynamespace = {
+
: Optional parameter set the current text foreground color in windowname given.
  onWheelNorth = function()
+
* ''hexColorString''
    echo("the north button was wheeled over!")
+
: 6 character long hexadecimal string to set the color to. The first two characters 00-FF represent the red part of the color, the next two the green and the last two characters stand for the blue part of the color
  end
 
}
 
  
setWheelReleaseCallback( "compassNorthImage", "mynamespace.onWheelNorth" )
+
: See also: [[#setFgColor | setFgColor()]], [[#setHexBgColor | setHexBgColor()]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
--highlights the first occurrence of the string "Tom" in the current line with a red foreground color.
 +
selectString( "Tom", 1 )
 +
setHexFgColor( "FF0000" )
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setLink==
+
==setItalics==
;setLink([windowName], command, tooltip)
+
;setItalics(windowName, bool)
: Turns the [[Manual:Lua_Functions#selectString|selected]] text into a clickable link - upon being clicked, the link will do the command code. Tooltip is a string which will be displayed when the mouse is over the selected text.
+
: Sets the current text font to italics/non-italics mode. If the windowName parameters omitted, the main screen will be used.
  
 +
==setLabelToolTip==
 +
;setLabelToolTip(labelName, text, [duration])
 +
: Sets a tooltip on the given label.
 +
{{MudletVersion|4.6.1}}
 
;Parameters
 
;Parameters
* ''windowName:''
 
: (optional) name of a miniconsole or a userwindow in which to select the text in.
 
* ''command:''
 
: command to do when the text is clicked, as text or Lua function.
 
* ''tooltip:''
 
: tooltip to show when the mouse is over the text - explaining what would clicking do.
 
  
;Example
+
* ''labelName:''
 +
: The name of the label to set the tooltip to.
 +
* ''text:''
 +
: The text to be shown. Can contain Qt rich text formats.
 +
* ''duration:''
 +
: Duration of the tooltip timeout in seconds. Optional, if not set the default duration will be set.
 +
 
 +
: See also: [[Manual:UI_Functions#resetLabelToolTip|resetLabelToolTip()]]
 +
 
 +
==setLabelClickCallback==
 +
;setLabelClickCallback(labelName, luaFunctionName, [any arguments])
 +
: Specifies a Lua function to be called if the user clicks on the label/image. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument. This table contains information about the mouse button clicked, other buttons that were pressed at the time, and the mouse cursor's local (relative to the label) and global (relative to the Mudlet window) position. The function specified in ''luaFunctionName'' is called like so:
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- you can clickify a lot of things to save yourself some time - for example, you can change
+
luaFuncName(optional number of arguments, event)
--  the line where you receive a message to be clickable to read it!
+
</syntaxhighlight>
-- perl regex trigger:
 
-- ^You just received message #(\w+) from \w+\.$
 
-- script:
 
selectString(matches[2], 1)
 
setUnderline(true) setLink([[send("msg read ]]..matches[2]..[[")]], "Read #"..matches[2])
 
resetFormat()
 
  
-- example of selecting text in a miniconsole and turning it into a link:
+
where '''event''' has the following structure:
HelloWorld = Geyser.MiniConsole:new({
 
  name="HelloWorld",
 
  x="70%", y="50%",
 
  width="30%", height="50%",
 
})
 
HelloWorld:echo("hi")
 
selectString("HelloWorld", "hi", 1)
 
setLink("HelloWorld", "echo'you clicked hi!'", "click me!")
 
</syntaxhighlight>
 
 
 
==setMainWindowSize==
 
;setMainWindowSize(mainWidth, mainHeight)
 
: Changes the size of your main Mudlet window to the values given.
 
: See Also: [[Manual:Lua_Functions#getMainWindowSize|getMainWindowSize()]]
 
  
; Parameters
 
* ''mainWidth:''
 
: The new width in pixels.
 
* ''mainHeight:''
 
: The new height in pixels.
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--this will resize your main Mudlet window
+
event = {
setMainWindowSize(1024, 768)
+
  x = 100,
 +
  y = 200,
 +
  globalX = 300,
 +
  globalY = 320,
 +
  button = "LeftButton",
 +
  buttons = {"RightButton", "MidButton"},
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMapWindowTitle==
+
: See also: [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]],[[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
;setMapWindowTitle(text)
 
: Changes the title shown in the mapper window when it's popped out.
 
: See also: [[#resetMapWindowTitle|resetMapWindowTitle()]]
 
  
; Parameters
+
;Parameters
* ''text:''
 
: New window title to set.
 
  
{{MudletVersion|4.8}}
+
* ''labelName:''
 +
: The name of the label to attach a callback function to.
 +
* ''luaFunctionName:''
 +
: Lua function to call, or the function name, as a string.
 +
* ''any arguments:''
 +
: (optional) Any amount of arguments you'd like to pass to the calling function.
 +
 
 +
{{note}} Event argument is available in 3.6+, and in 4.8+ you can pass a function directly instead of a string.
  
 +
{{note}}
 +
While '''event.button''' may contain a single string of any listed below, '''event.buttons''' will only ever contain some combination of "LeftButton", "MidButton", and "RightButton"
 +
:The following mouse button strings are defined:
 +
<pre>
 +
"LeftButton"        "RightButton"        "MidButton"
 +
"BackButton"        "ForwardButton"      "TaskButton"
 +
"ExtraButton4"      "ExtraButton5"      "ExtraButton6"
 +
"ExtraButton7"      "ExtraButton8"      "ExtraButton9"
 +
"ExtraButton10"    "ExtraButton11"      "ExtraButton12"
 +
"ExtraButton13"    "ExtraButton14"      "ExtraButton15"
 +
"ExtraButton16"    "ExtraButton17"      "ExtraButton18"
 +
"ExtraButton19"    "ExtraButton20"      "ExtraButton21"
 +
"ExtraButton22"    "ExtraButton23"      "ExtraButton24"
 +
</pre>
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setMapWindowTitle("my cool game map")
+
createLabel("testLabel", 50, 50, 100, 100, 0)
</syntaxhighlight>
 
  
==setMiniConsoleFontSize==
+
function onClickGoNorth(event)
;setMiniConsoleFontSize(name, fontSize)
+
  if event.button == "LeftButton" then
: Sets the font size of the mini console. see also: [[#setFontSize | setFontSize()]], [[#createMiniConsole | createMiniConsole()]], [[#createLabel | createLabel()]]
+
    send("walk north")
 +
  elseif event.button == "RightButton" then
 +
    send("swim north")
 +
  elseif event.button == "MidButton" then
 +
    send("gallop north")
 +
  end
 +
end
  
==setMovie==
+
setLabelClickCallback("testLabel", "onClickGoNorth")
;setMovie(label name, path to gif)
 
  
: Adds a gif to the selected label and animates it. Note that gifs are pretty expensive to play, so don't add too many at once.
+
-- you can also use them within tables:
: Some websites you can get gifs from are [https://tenor.com/search/stickers-gifs Tenor] and [https://giphy.com/stickers Giphy] (not officially endorsed).
+
mynamespace =
 +
  {
 +
    onClickGoNorth =
 +
      function()
 +
        echo("the north button was clicked!")
 +
      end,
 +
  }
 +
setLabelClickCallback("testLabel", "mynamespace.onClickGoNorth")
 +
 
 +
-- or by passing the function directly:
 +
setLabelClickCallback("testLabel", onClickGoNorth)
 +
</syntaxhighlight>
  
: Returns true
+
==setLabelDoubleClickCallback==
 +
;setLabelDoubleClickCallback(labelName, luaFunctionName, [any arguments])
 +
: Specifies a Lua function to be called if the user double clicks on the label/image. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]]
  
: See also: [[Manual:Lua_Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#pauseMovie|pauseMovie()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
+
{{MudletVersion|3.6}}
  
{{MudletVersion|4.15}}
+
: See also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
  
 
;Parameters
 
;Parameters
* ''label name:''
 
: name of the label the gif will be animated on
 
* ''path:''
 
: path of the gif file
 
  
;Example
+
* ''labelName:''
<syntaxhighlight lang="lua">
+
: The name of the label to attach a callback function to.
-- download & show a gif within mudlet
+
* ''luaFunctionName:''
local saveto = getMudletHomeDir().."/kymip.gif"
+
: The Lua function name to call, as a string.
-- animation credit to https://opengameart.org/content/kymiball-ii-third-prototype-scraps
+
* ''any arguments:''
local url = "https://opengameart.org/sites/default/files/kymip_0.gif"
+
: (optional) Any amount of arguments you'd like to pass to the calling function.
  
if downloadHandler then killAnonymousEventHandler(downloadHandler) end
+
==setLabelMoveCallback==
downloadHandler = registerAnonymousEventHandler("sysDownloadDone",
+
;setLabelMoveCallback(labelName, luaFunctionName, [any arguments])
  function(_, filename)
+
: Specifies a Lua function to be called when the mouse moves while inside the specified label/console. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]]
    if filename ~= saveto then
 
      return true
 
    end
 
   
 
    local width, height = getImageSize(saveto)
 
  
    createLabel("kymip", 300, 300, width, height, 0)
+
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
    setMovie("kymip", saveto)
+
 
    setLabelReleaseCallback("kymip", function() deleteLabel("kymip") end)
+
;Parameters
  end, true)
 
  
downloadFile(saveto, url)
+
* ''labelName:''
</syntaxhighlight>
+
: The name of the label to attach a callback function to.
 +
* ''luaFunctionName:''
 +
: The Lua function name to call, as a string.
 +
* ''any arguments:''
 +
: (optional) Any amount of arguments you'd like to pass to the calling function.
  
<syntaxhighlight lang="lua">
+
{{MudletVersion|3.6}}
local gifpath = getMudletHomeDir().."/movie.gif"
 
  
local width, height = getImageSize(gifpath)
+
==setLabelOnEnter==
 +
;setLabelOnEnter(labelName, luaFunctionName, [any arguments])
 +
: Specifies a Lua function to be called when the mouse enters within the labels borders. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, similar to [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], but with slightly different information.
 +
: For this callback, the '''event''' argument has the following structure:
  
-- create a label with the name mygif
+
<syntaxhighlight lang="lua">
createLabel("mygif", 0, 0, width, height,0)
+
event = {
-- put the gif on the label and animate it
+
  x = 100,
setMovie("mygif", gifpath)
+
  y = 200,
 +
  globalX = 300,
 +
  globalY = 320,
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMovieFrame==
+
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
;setMovieFrame(label name, frame nr)
 
  
: Jump to a specific frame in the gif.
+
;Parameters
: Returns true if successful, and false if frame doesn't exist.
 
  
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#pauseMovie|pauseMovie()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
+
* ''labelName:''
 
+
: The name of the label to attach a callback function to.
{{MudletVersion|4.15}}
+
* ''luaFunctionName:''
 +
: The Lua function name to call, as a string - it must be registered as a global function, and not inside any namespaces (tables).
 +
* ''any arguments:''
 +
: (optional) Any amount of arguments you'd like to pass to the calling function.
  
;Parameters
+
;Example
* ''label name:''
 
: name of the gif label
 
* ''frame nr:''
 
: the gif animations frame nr to jump to
 
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a label with the name myMovie
+
function onMouseOver()
createLabel("myMovie",0,0,200,200,0)
+
  echo("The mouse is hovering over the label!\n")
 
+
end
-- puts the gif on the label and animates it
 
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
 
--stops the animation
 
pauseMovie("myMovie")
 
-- jumps to frame 12 of the animation
 
setMovieFrame("myMovie", 12)
 
--start the animation
 
startMovie("myMovie")
 
  
 +
setLabelOnEnter( "compassNorthImage", "onMouseOver" )
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMovieSpeed==
+
==setLabelOnLeave==
;setMovieSpeed(label name, speed in percent)
+
;setLabelOnLeave(labelName, luaFunctionName, [any arguments])
 +
: Specifies a Lua function to be called when the mouse leaves the labels borders. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button.
  
: Set the animation speed, in percent.
+
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]]
: Returns true
 
 
 
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#pauseMovie|pauseMovie()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]]
 
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
* ''label name:''  
+
 
: name of the gif label
+
* ''labelName:''
* ''speed in percent:''
+
: The name of the label to attach a callback function to.
: the gif animations speed in percent for example 50 for 50% speed
+
* ''luaFunctionName:''
 +
: The Lua function name to call, as a string - it must be registered as a global function, and not inside any namespaces (tables).
 +
* ''any arguments:''
 +
: (optional) Any amount of arguments you'd like to pass to the calling function.
  
 
;Example
 
;Example
 +
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a label with the name myMovie
+
function onMouseLeft(argument)
createLabel("myMovie",0,0,200,200,0)
+
  echo("The mouse quit hovering over the label the label! We also got this as data on the function: "..argument)
 +
end
 +
 
 +
setLabelOnLeave( "compassNorthImage", "onMouseLeft", "argument to pass to function" )
 +
</syntaxhighlight>
  
-- puts the gif on the label and animates it
+
==setLabelReleaseCallback==
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
+
;setLabelReleaseCallback(labelName, luaFunctionName, [any arguments])
--accelerates the animation to a speed of 150%
+
: Specifies a Lua function to be called when a mouse click ends that originated on the specified label/console. This function is called even if you drag the mouse off of the label/console before releasing the click. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]]
setMovieSpeed("myMovie",150)
 
  
 +
{{MudletVersion|3.0}}
  
</syntaxhighlight>
+
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelWheelCallback|setLabelWheelCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
  
==setOverline==
+
;Parameters
;setOverline([windowName], boolean)
 
: Sets the current text font to be overlined (true) or not overlined (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be overlined. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will be overlined until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
 
  
* ''windowName:''
+
* ''labelName:''
: (optional) name of the window to set the text to be overlined or not.
+
: The name of the label to attach a callback function to.
 +
* ''luaFunctionName:''
 +
: The Lua function name to call, as a string.
 +
* ''any arguments:''
 +
: (optional) Any amount of arguments you'd like to pass to the calling function.
  
* ''boolean:''
+
{{note}}
: A ''true'' or ''false'' that enables or disables overlining of text
+
The ''event'' argument only available since Mudlet 3.6
  
 
;Example
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- enable overlined text
+
function onReleaseNorth()
setOverline(true)
+
  echo("the north button was released!")
-- the following echo will be have an overline
+
end
echo("hi")
+
 
-- turns off bolding, italics, underlines, colouring, and strikethrough (and, after this and reverse have been added, them as well). It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
+
setLabelReleaseCallback( "compassNorthImage", "onReleaseNorth" )
resetFormat()
+
 
 +
-- you can also use them within tables:
 +
mynamespace = {
 +
  onReleaseNorth = function()
 +
    echo("the north button was released!")
 +
  end
 +
}
 +
 
 +
setLabelReleaseCallback( "compassNorthImage", "mynamespace.onReleaseNorth" )
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|3.17}}
+
==setLabelStyleSheet==
 
+
;setLabelStyleSheet(label, markup)
==setPopup==
+
: Applies Qt style formatting to a label via a special markup language.
;setPopup([windowName], {lua code}, {hints})
 
: Turns the [[Manual:Lua_Functions#selectString|selected()]] text into a left-clickable link, and a right-click menu for more options. The selected text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
 
  
 
; Parameters
 
; Parameters
* ''windowName:''
+
* ''label:''
: the name of the console to operate on. If not using this in a miniConsole, use "main" as the name.
+
: The name of the label to be formatted (passed when calling createLabel).
: This argument was ignored before Mudlet 4.11.
+
* ''markup:''
* ''{lua code}:''
+
: The string instructions, as specified by the Qt Style Sheet reference.
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
+
: Note that when specifying a file path for styling purposes, forward slashes, / , must be used, even if your OS uses backslashes, \ , normally.
* ''{hints}:''
 
: a table of strings which will be shown on the popup and right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>.
 
  
 +
;References
 +
: https://doc.qt.io/qt-5/stylesheet-reference.html
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- In a `Raising your hand in greeting, you say "Hello!"` exact match trigger,
+
-- This creates a label with a white background and a green border, with the text "test"
-- the following code will make left-clicking on `Hello` show you an echo, while right-clicking
+
-- inside.
-- will show some commands you can do.
+
createLabel("test", 50, 50, 100, 100, 0)
 
+
setLabelStyleSheet("test", [[
selectString("Hello", 1)
+
  background-color: white;
setPopup("main", {function() send("bye") end, function() echo("hi!") end}, {"send 'bye' to the MUD", "click to echo 'hi!'"})
+
  border: 10px solid green;
 
+
  font-size: 12px;
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
+
  ]])
setPopup("main", {[[send("bye")]], [[echo("hi!")]]}, {"send 'bye' to the MUD", "click to echo 'hi!'"})
+
echo("test", "test")
 
+
</syntaxhighlight>
 +
<syntaxhighlight lang="lua">
 +
-- This creates a label with a single image, that will tile or clip depending on the
 +
-- size of the label. To use this example, please supply your own image.
 +
createLabel("test5", 50, 353, 164, 55, 0)
 +
setLabelStyleSheet("test5", [[
 +
  background-image: url("C:/Users/Administrator/.config/mudlet/profiles/Midkemia Online/Vyzor/MkO_logo.png");
 +
  ]])
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="lua">
 +
-- This creates a label with a single image, that can be resized (such as during a
 +
-- sysWindowResizeEvent). To use this example, please supply your own image.
 +
createLabel("test9", 215, 353, 100, 100, 0)
 +
setLabelStyleSheet("test9", [[
 +
  border-image: url("C:/Users/Administrator/.config/mudlet/profiles/Midkemia Online/Vyzor/MkO_logo.png");
 +
  ]])
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
<syntaxhighlight lang="lua">
 +
--This creates a label whose background changes when the users mouse hovers over it.
  
==setProfileStyleSheet==
+
--putting the styleSheet in a variable allows us to easily change the styleSheet. We also are placing colors in variables that have been preset. 
;setProfileStyleSheet(stylesheet)
+
local labelBackgroundColor = "#123456"
: Sets a stylesheet for the current Mudlet profile - allowing you to customise content outside of the main window (the profile tabs, the scrollbar, and so on). This function is better than setAppStyleSheet() because it affects only the current profile and not every other one as well.
+
local labelHoverColor = "#654321"
 
+
local labelFontSize = 12
: See also: [[#setAppStyleSheet|setAppStyleSheet()]]
+
local labelName = "HoverLabel"
 
+
local ourLabelStyle = [[
;Parameters
+
QLabel{
 
+
background-color: ]]..labelBackgroundColor..[[;
* ''stylesheet:''
+
font-size: ]]..labelFontSize..[[px;
: The entire stylesheet you'd like to use. See [http://qt-project.org/doc/qt-5/stylesheet-reference.html Qt Style Sheets Reference] for the list of widgets you can style and CSS properties you can apply on them.
+
qproperty-alignment: 'AlignCenter | AlignCenter';
+
}
: See also [https://github.com/vadi2/QDarkStyleSheet/blob/master/qdarkstyle/style.qss QDarkStyleSheet], a rather extensive stylesheet that shows you all the different configuration options you could apply, available as an [http://forums.mudlet.org/viewtopic.php?f=6&t=17624 mpackage here].
+
QLabel::hover{
 
+
background-color: ]]..labelHoverColor..[[;
;Example
+
font-size: ]]..labelFontSize..[[px;
<syntaxhighlight lang="lua">
+
qproperty-alignment: 'AlignCenter | AlignCenter';
-- credit to Akaya @ http://forums.mudlet.org/viewtopic.php?f=5&t=4610&start=10#p21770
+
}
local background_color = "#26192f"
+
]]
local border_color = "#b8731b"
+
 
 +
--Creating the label using the labelName and ourLabelStyle variables created above.
 +
createLabel(labelName,0,0,400,400,1)
 +
setLabelStyleSheet(labelName, ourLabelStyle)
 +
echo("HoverLabel","This text shows while mouse is or is not over the label.")
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="lua">
 +
--Using QLabel::hover mentioned above. Lets "trick" the label into changing it's text.
 +
--Please keep in mind that the setLabelMoveCallback allows for much more control over not just your label but your entire project.
  
setProfileStyleSheet([[
+
--putting the styleSheet in a variable allows us to easily change the styleSheet. We also are placing colors in variables that have been preset. 
  QMainWindow {
+
local labelBackgroundColor = "#123456"
    background: ]]..background_color..[[;
+
local labelHoverColor = "#654321"
  }
+
local labelFontSize = 12
  QToolBar {
+
local labelName = "HoverLabel"
    background: ]]..background_color..[[;
+
--Notice we are adding a string returned from a function. In this case, the users profile directory.
  }
+
local ourLabelStyle = [[
  QToolButton {
+
QLabel{
    background: ]]..background_color..[[;
+
border-image: url("]]..getMudletHomeDir()..[[/imagewithtext.png");
    border-style: solid;
+
}
    border-width: 2px;
+
QLabel::hover{
    border-color: ]]..border_color..[[;
+
border-image: url("]]..getMudletHomeDir()..[[/imagewithhovertext.png");
    border-radius: 5px;
+
}
    font-family: BigNoodleTitling;
+
]]
    color: white;
+
 
    margin: 2px;
+
--Creating the label using the labelName and ourLabelStyle variables created above.
    font-size: 12pt;
+
createLabel(labelName,0,0,400,400,1)
  }
+
setLabelStyleSheet(labelName, ourLabelStyle)
  QToolButton:hover { background-color: grey;}
+
--This is just to example that echos draw on top of the label. You would not want to echo onto a label you were drawing text on with images, because echos would draw on top of them.
  QToolButton:focus { background-color: grey;}
+
echo("HoverLabel","This text shows while mouse is or is not over the label.")
 +
</syntaxhighlight>
  
  QTreeView {
+
==setLabelCursor==
    background: ]]..background_color..[[;
+
;setLabelCursor(labelName, cursorShape)
    color: white;
+
: Changes how the mouse cursor looks like when over the label. To reset the cursor shape, use [[#resetLabelCursor|resetLabelCursor()]].
  }
 
  
  QMenuBar{ background-color: ]]..background_color..[[;}
+
: See also: [[#resetLabelCursor|resetLabelCursor()]], [[#setLabelCustomCursor|setLabelCustomCursor()]]
  
  QMenuBar::item{ background-color: ]]..background_color..[[;}
+
{{MudletVersion|4.8}}
  
  QDockWidget::title {
+
;Parameters
    background: ]]..border_color..[[;
+
* ''labelName:''
  }
+
: Name of the label which you want the mouse cursor change at.
  QStatusBar {
+
* ''cursorShape''
    background: ]]..border_color..[[;
+
: Shape of the mouse cursor. List of possible cursor shapes is [[CursorShapes| available here]].
  }
+
;Example
  QScrollBar:vertical {
+
<syntaxhighlight lang="lua">
    background: ]]..background_color..[[;
+
setLabelCursor("myLabel", "Cross")
    width: 15px;
+
-- This will change the mouse cursor to a cross if it's over the label myLabel
    margin: 22px 0 22px 0;
+
</syntaxhighlight>
  }
+
 
  QScrollBar::handle:vertical {
+
==setLabelCustomCursor==
    background-color: ]]..background_color..[[;
+
;setLabelCustomCursor(labelName, custom cursor, [hotX, hotY])
    min-height: 20px;
+
: Changes the mouse cursor shape over your label to a custom cursor. To reset the cursor shape, use [[#resetLabelCursor|resetLabelCursor()]].
    border-width: 2px;
+
 
    border-style: solid;
+
: See also: [[#resetLabelCursor|resetLabelCursor()]], [[#setLabelCursor|setLabelCursor()]]
    border-color: ]]..border_color..[[;
+
 
    border-radius: 7px;
+
{{MudletVersion|4.8}}
  }
+
 
  QScrollBar::add-line:vertical {
+
;Parameters
  background-color: ]]..background_color..[[;
+
* ''labelName:''
  border-width: 2px;
+
: Name of the label which you want the mouse cursor change at.
  border-style: solid;
+
* ''custom cursor''
  border-color: ]]..border_color..[[;
+
: Location of your custom cursor file. To be compatible with all systems it is recommended to use png files with size of 32x32.
  border-bottom-left-radius: 7px;
+
* ''hotX''
  border-bottom-right-radius: 7px;
+
: X-coordinate of the cursors hotspot position. Optional, if not set it is set to -1 which is in the middle of your custom cursor.
        height: 15px;
+
* ''hotY''
        subcontrol-position: bottom;
+
: Y-coordinate of the cursors hotspot position. Optional, if not set it is set to -1 which is in the middle of your custom cursor.
        subcontrol-origin: margin;
+
;Example
  }
+
<syntaxhighlight lang="lua">
  QScrollBar::sub-line:vertical {
+
setLabelCustomCursor("myLabel", getMudletHomeDir().."/custom_cursor.png")
  background-color: ]]..background_color..[[;
+
-- This will change the mouse cursor to your custom cursor if it's over the label myLabel
  border-width: 2px;
+
</syntaxhighlight>
  border-style: solid;
 
  border-color: ]]..border_color..[[;
 
  border-top-left-radius: 7px;
 
  border-top-right-radius: 7px;
 
        height: 15px;
 
        subcontrol-position: top;
 
        subcontrol-origin: margin;
 
  }
 
  QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
 
    background: white;
 
    width: 4px;
 
    height: 3px;
 
  }
 
  QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
 
    background: none;
 
  }
 
]])
 
  
-- if you'd like to reset it, use:
+
==setLabelWheelCallback==
setProfileStyleSheet("")
+
;setLabelWheelCallback(labelName, luaFunctionName, [any arguments])
 +
: Specifies a Lua function to be called when the mouse wheel is scrolled while inside the specified label/console. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, similar to [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], but with slightly different information.
 +
: For this callback, the ''event'' argument has the following structure:
  
-- to only affect scrollbars within the main window and miniconsoles, prefix them with 'TConsole':
+
<syntaxhighlight lang="lua">
setProfileStyleSheet[[
+
event = {
  TConsole QScrollBar:vertical {
+
   x = 100,
      border: 2px solid grey;
+
   y = 200,
      background: #32CC99;
+
   globalX = 300,
      width: 15px;
+
   globalY = 320,
      margin: 22px 0 22px 0;
+
   buttons = {"RightButton", "MidButton"},
   }
+
   angleDeltaX = 0,
   TConsole QScrollBar::handle:vertical {
+
   angleDeltaY = 120
      background: white;
+
}
      min-height: 20px;
 
   }
 
   TConsole QScrollBar::add-line:vertical {
 
      border: 2px solid grey;
 
      background: #32CC99;
 
      height: 20px;
 
      subcontrol-position: bottom;
 
      subcontrol-origin: margin;
 
  }
 
   TConsole QScrollBar::sub-line:vertical {
 
      border: 2px solid grey;
 
      background: #32CC99;
 
      height: 20px;
 
      subcontrol-position: top;
 
      subcontrol-origin: margin;
 
  }
 
   TConsole QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
 
      border: 2px solid grey;
 
      width: 3px;
 
      height: 3px;
 
      background: white;
 
  }
 
   TConsole QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
 
      background: none;
 
  }
 
]]
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.6}}
+
: Keys ''angleDeltaX'' and ''angleDeltaY'' correspond with the horizontal and vertical scroll distance, respectively. For most mice, these values will be multiples of 120.
  
==setReverse==
+
: See Also: [[Manual:UI_Functions#setLabelClickCallback|setLabelClickCallback()]], [[Manual:UI_Functions#setLabelDoubleClickCallback|setLabelDoubleClickCallback()]], [[Manual:UI_Functions#setLabelReleaseCallback|setLabelReleaseCallback()]], [[Manual:UI_Functions#setLabelMoveCallback|setLabelMoveCallback()]], [[Manual:UI_Functions#setLabelOnEnter|setLabelOnEnter()]], [[Manual:UI_Functions#setLabelOnLeave|setLabelOnLeave()]]
;setReverse([windowName], boolean)
 
: Sets the current text to swap foreground and background color settings (true) or not (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will have it's colors swapped. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will have their foreground and background colors swapped until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
 
  
* ''windowName:''
+
;Parameters
: (optional) name of the window to set the text colors to be reversed or not.
 
  
* ''boolean:''
+
* ''labelName:''
: A ''true'' or ''false'' that enables or disables reversing of the fore- and back-ground colors of text
+
: The name of the label to attach a callback function to.
 +
* ''luaFunctionName:''
 +
: The Lua function name to call, as a string.
 +
* ''any arguments:''
 +
: (optional) Any amount of arguments you'd like to pass to the calling function.
 +
 
 +
{{MudletVersion|3.6}}
  
 
;Example
 
;Example
 +
<syntaxhighlight lang="lua">
 +
function onWheelNorth(event)
 +
  if event.angleDeltaY > 0 then
 +
    echo("the north button was wheeled forwards over!")
 +
  else
 +
    echo("the north button was wheeled backwards over!")
 +
  end
 +
end
  
<syntaxhighlight lang="lua">
+
setLabelWheelCallback( "compassNorthImage", "onWheelNorth" )
-- enable fore/back-ground color reversal of text
 
setReverse(true)
 
-- the following echo will have the text colors reversed
 
echo("hi")
 
-- turns off bolding, italics, underlines, colouring, and strikethrough (and, after this and overline have been added, them as well). It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
 
resetFormat()
 
</syntaxhighlight>
 
  
{{MudletVersion|3.17}}
+
-- you can also use them within tables:
 +
mynamespace = {
 +
  onWheelNorth = function()
 +
    echo("the north button was wheeled over!")
 +
  end
 +
}
  
{{note}} Although the visual effect on-screen is the same as that of text being selected if both apply to a piece of text they neutralise each other - however the effect of the reversal ''will'' be carried over in copies made by the "Copy to HTML" and in logs made in HTML format log file mode.
+
setWheelReleaseCallback( "compassNorthImage", "mynamespace.onWheelNorth" )
 +
</syntaxhighlight>
  
==setStrikeOut==
+
==setLink==
;setStrikeOut([windowName], boolean)
+
;setLink([windowName], command, tooltip)
: Sets the current text font to be striken out (true) or not striken out (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be bolded. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will be striken out until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
+
: Turns the [[Manual:Lua_Functions#selectString|selected]] text into a clickable link - upon being clicked, the link will do the command code. Tooltip is a string which will be displayed when the mouse is over the selected text.
  
 +
;Parameters
 
* ''windowName:''
 
* ''windowName:''
: (optional) name of the window to set the text to be stricken out or not.
+
: (optional) name of a miniconsole or a userwindow in which to select the text in.
 
+
* ''command:''
* ''boolean:''
+
: command to do when the text is clicked, as text or Lua function.
: A ''true'' or ''false'' that enables or disables striking out of text
+
* ''tooltip:''
 +
: tooltip to show when the mouse is over the text - explaining what would clicking do.
  
 
;Example
 
;Example
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- enable striken-out text
+
-- you can clickify a lot of things to save yourself some time - for example, you can change
setStrikeOut(true)
+
-- the line where you receive a message to be clickable to read it!
-- the following echo will be have a strikethrough
+
-- perl regex trigger:
echo("hi")
+
-- ^You just received message #(\w+) from \w+\.$
-- turns off bolding, italics, underlines, colouring, and strikethrough. It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
+
-- script:
 +
selectString(matches[2], 1)
 +
setUnderline(true) setLink([[send("msg read ]]..matches[2]..[[")]], "Read #"..matches[2])
 
resetFormat()
 
resetFormat()
 +
 +
-- example of selecting text in a miniconsole and turning it into a link:
 +
HelloWorld = Geyser.MiniConsole:new({
 +
  name="HelloWorld",
 +
  x="70%", y="50%",
 +
  width="30%", height="50%",
 +
})
 +
HelloWorld:echo("hi")
 +
selectString("HelloWorld", "hi", 1)
 +
setLink("HelloWorld", "echo'you clicked hi!'", "click me!")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setTextFormat==
+
==setMainWindowSize==
;setTextFormat(windowName, r1, g1, b1, r2, g2, b2, bold, underline, italics, [strikeout], [overline], [reverse])
+
;setMainWindowSize(mainWidth, mainHeight)
: Sets current text format of selected window. This is a more convenient means to set all the individual features at once compared to using [[#setFgColor|setFgColor]](windowName, r,g,b), [[#setBold|setBold]](windowName, true), [[#setItalics|setItalics]](windowName, true), [[#setUnderline|setUnderline]](windowName, true), [[#setStrikeOut|setStrikeOut]](windowName, true).
+
: Changes the size of your main Mudlet window to the values given.
: See Also: [[Manual:Lua_Functions#getTextFormat|getTextFormat()]]
+
: See Also: [[Manual:Lua_Functions#getMainWindowSize|getMainWindowSize()]]
  
;Parameters
+
; Parameters
* ''windowName''
+
* ''mainWidth:''
: Specify name of selected window. If empty string "" or "main" format will be applied to the main console
+
: The new width in pixels.
* ''r1,g1,b1''
+
* ''mainHeight:''
: To color text background, give number values in RBG style
+
: The new height in pixels.
* ''r2,g2,b2''
 
: To color text foreground, give number values in RBG style
 
* ''bold''
 
: To format text bold, set to 1 or true, otherwise 0 or false
 
* ''underline''
 
: To underline text, set to 1 or true, otherwise 0 or false
 
* ''italics''
 
: To format text italic, set to 1 or true, otherwise 0 or false
 
* ''strikeout
 
: (optional) To strike text out, set to 1 or true, otherwise 0 or false or simply no argument
 
* ''overline
 
: (optional) To use overline, set to 1 or true, otherwise 0 or false or simply no argument
 
* ''reverse
 
: (optional) To swap foreground and background colors, set to 1 or true, otherwise 0 or false or simply no argument
 
  
;Example:
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--This script would create a mini text console and write with bold, struck-out, yellow foreground color and blue background color "This is a test".
+
--this will resize your main Mudlet window
createMiniConsole( "con1", 0,0,300,100);
+
setMainWindowSize(1024, 768)
setTextFormat("con1",0,0,255,255,255,0,true,0,false,1);
 
echo("con1","This is a test")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} In versions prior to 3.7.0 the error messages ''and this wiki'' were wrong in that they had the foreground color parameters as r1, g1 and b1 and the background ones as r2, g2 and b2.
+
==setMapWindowTitle==
 +
;setMapWindowTitle(text)
 +
: Changes the title shown in the mapper window when it's popped out.
 +
: See also: [[#resetMapWindowTitle|resetMapWindowTitle()]]
  
==setUnderline==
+
; Parameters
;setUnderline(windowName, bool)
+
* ''text:''
: Sets the current text font to underline/non-underline mode. If the windowName parameters omitted, the main screen will be used.
+
: New window title to set.
 
 
==setUserWindowTitle==
 
;setUserWindowTitle(windowName, text)
 
: sets a new title text for the UserWindow windowName
 
 
 
;Parameters
 
* ''windowName:''
 
: Name of the userwindow
 
* ''text''
 
: new title text
 
  
 
{{MudletVersion|4.8}}
 
{{MudletVersion|4.8}}
  
: See also: [[#resetUserWindowTitle|resetUserWindowTitle()]], [[#openUserWindow|openUserWindow()]]
+
;Example
 +
<syntaxhighlight lang="lua">
 +
setMapWindowTitle("my cool game map")
 +
</syntaxhighlight>
 +
 
 +
==setMiniConsoleFontSize==
 +
;setMiniConsoleFontSize(name, fontSize)
 +
: Sets the font size of the mini console. see also: [[#setFontSize | setFontSize()]], [[#createMiniConsole | createMiniConsole()]], [[#createLabel | createLabel()]]
 +
 
 +
==setMovie==
 +
;setMovie(label name, path to gif)
 +
 
 +
: Adds a gif to the selected label and animates it. Note that gifs are pretty expensive to play, so don't add too many at once.
 +
: Some websites you can get gifs from are [https://tenor.com/search/stickers-gifs Tenor] and [https://giphy.com/stickers Giphy] (not officially endorsed).
 +
 
 +
: Returns true
 +
 
 +
: See also: [[Manual:Lua_Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#pauseMovie|pauseMovie()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
  
==setUserWindowStyleSheet==
+
{{MudletVersion|4.15}}
;setUserWindowStyleSheet(windowName, markup)
 
: Applies Qt style formatting to the border/title area of a userwindow via a special markup language.
 
  
 
;Parameters
 
;Parameters
* ''windowName:''
+
* ''label name:''  
: Name of the userwindow
+
: name of the label the gif will be animated on
* ''markup''
+
* ''path:''
: The string instructions, as specified by the Qt Style Sheet reference.
+
: path of the gif file
: Note that when you dock the userwindow the border style is not provided by this
 
 
 
{{MudletVersion|4.10}}
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- changes the title area style of the UserWindow 'myUserWindow'
+
-- download & show a gif within mudlet
setUserWindowStyleSheet("myUserWindow", [[QDockWidget::title{  
+
local saveto = getMudletHomeDir().."/kymip.gif"
     background-color: rgb(0,255,150);
+
-- animation credit to https://opengameart.org/content/kymiball-ii-third-prototype-scraps
     border: 2px solid red;
+
local url = "https://opengameart.org/sites/default/files/kymip_0.gif"
     border-radius: 8px;
+
 
     text-align: center;     
+
if downloadHandler then killAnonymousEventHandler(downloadHandler) end
     }]])
+
downloadHandler = registerAnonymousEventHandler("sysDownloadDone",
 +
  function(_, filename)
 +
    if filename ~= saveto then
 +
      return true
 +
    end
 +
   
 +
    local width, height = getImageSize(saveto)
 +
 
 +
    createLabel("kymip", 300, 300, width, height, 0)
 +
    setMovie("kymip", saveto)
 +
    setLabelReleaseCallback("kymip", function() deleteLabel("kymip") end)
 +
  end, true)
 +
 
 +
downloadFile(saveto, url)
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="lua">
 +
local gifpath = getMudletHomeDir().."/movie.gif"
 +
 
 +
local width, height = getImageSize(gifpath)
 +
 
 +
-- create a label with the name mygif
 +
createLabel("mygif", 0, 0, width, height,0)
 +
-- put the gif on the label and animate it
 +
setMovie("mygif", gifpath)
 +
</syntaxhighlight>
 +
 
 +
==setMovieFrame==
 +
;setMovieFrame(label name, frame nr)
 +
 
 +
: Jump to a specific frame in the gif.
 +
: Returns true if successful, and false if frame doesn't exist.
 +
 
 +
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#pauseMovie|pauseMovie()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
 +
 
 +
{{MudletVersion|4.15}}
 +
 
 +
;Parameters
 +
* ''label name:''
 +
: name of the gif label
 +
* ''frame nr:''
 +
: the gif animations frame nr to jump to
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- create a label with the name myMovie
 +
createLabel("myMovie",0,0,200,200,0)
 +
 
 +
-- puts the gif on the label and animates it
 +
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
 +
--stops the animation
 +
pauseMovie("myMovie")
 +
-- jumps to frame 12 of the animation
 +
setMovieFrame("myMovie", 12)
 +
--start the animation
 +
startMovie("myMovie")
 +
 
 +
</syntaxhighlight>
 +
 
 +
==setMovieSpeed==
 +
;setMovieSpeed(label name, speed in percent)
 +
 
 +
: Set the animation speed, in percent.
 +
: Returns true
 +
 
 +
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#startMovie|startMovie()]], [[Manual:Lua_Functions#pauseMovie|pauseMovie()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]]
 +
 
 +
{{MudletVersion|4.15}}
 +
 
 +
;Parameters
 +
* ''label name:''
 +
: name of the gif label
 +
* ''speed in percent:''
 +
: the gif animations speed in percent for example 50 for 50% speed
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- create a label with the name myMovie
 +
createLabel("myMovie",0,0,200,200,0)
 +
 
 +
-- puts the gif on the label and animates it
 +
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
 +
--accelerates the animation to a speed of 150%
 +
setMovieSpeed("myMovie",150)
 +
 
 +
 
 +
</syntaxhighlight>
 +
 
 +
==setOverline==
 +
;setOverline([windowName], boolean)
 +
: Sets the current text font to be overlined (true) or not overlined (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be overlined. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will be overlined until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
 +
 
 +
* ''windowName:''
 +
: (optional) name of the window to set the text to be overlined or not.
 +
 
 +
* ''boolean:''
 +
: A ''true'' or ''false'' that enables or disables overlining of text
 +
 
 +
;Example
 +
 
 +
<syntaxhighlight lang="lua">
 +
-- enable overlined text
 +
setOverline(true)
 +
-- the following echo will be have an overline
 +
echo("hi")
 +
-- turns off bolding, italics, underlines, colouring, and strikethrough (and, after this and reverse have been added, them as well). It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
 +
resetFormat()
 +
</syntaxhighlight>
 +
 
 +
{{MudletVersion|3.17}}
 +
 
 +
==setPopup==
 +
;setPopup([windowName], {lua code}, {hints})
 +
: Turns the [[Manual:Lua_Functions#selectString|selected()]] text into a left-clickable link, and a right-click menu for more options. The selected text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
 +
 
 +
; Parameters
 +
* ''windowName:''
 +
: the name of the console to operate on. If not using this in a miniConsole, use "main" as the name.
 +
: This argument was ignored before Mudlet 4.11.
 +
* ''{lua code}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>
 +
* ''{hints}:''
 +
: a table of strings which will be shown on the popup and right-click menu. ie, <syntaxhighlight lang="lua" inline="">{"send the hi command", "echo hi to yourself"}</syntaxhighlight>.
 +
 
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- In a `Raising your hand in greeting, you say "Hello!"` exact match trigger,
 +
-- the following code will make left-clicking on `Hello` show you an echo, while right-clicking
 +
-- will show some commands you can do.
 +
 
 +
selectString("Hello", 1)
 +
setPopup("main", {function() send("bye") end, function() echo("hi!") end}, {"send 'bye' to the MUD", "click to echo 'hi!'"})
 +
 
 +
-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
 +
setPopup("main", {[[send("bye")]], [[echo("hi!")]]}, {"send 'bye' to the MUD", "click to echo 'hi!'"})
 +
 
 +
</syntaxhighlight>
 +
 
 +
==setProfileStyleSheet==
 +
;setProfileStyleSheet(stylesheet)
 +
: Sets a stylesheet for the current Mudlet profile - allowing you to customise content outside of the main window (the profile tabs, the scrollbar, and so on). This function is better than setAppStyleSheet() because it affects only the current profile and not every other one as well.
 +
 
 +
: See also: [[#setAppStyleSheet|setAppStyleSheet()]]
 +
 
 +
;Parameters
 +
 
 +
* ''stylesheet:''
 +
: The entire stylesheet you'd like to use. See [http://qt-project.org/doc/qt-5/stylesheet-reference.html Qt Style Sheets Reference] for the list of widgets you can style and CSS properties you can apply on them.
 +
 +
: See also [https://github.com/vadi2/QDarkStyleSheet/blob/master/qdarkstyle/style.qss QDarkStyleSheet], a rather extensive stylesheet that shows you all the different configuration options you could apply, available as an [http://forums.mudlet.org/viewtopic.php?f=6&t=17624 mpackage here].
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- credit to Akaya @ http://forums.mudlet.org/viewtopic.php?f=5&t=4610&start=10#p21770
 +
local background_color = "#26192f"
 +
local border_color = "#b8731b"
 +
 
 +
setProfileStyleSheet([[
 +
  QMainWindow {
 +
    background: ]]..background_color..[[;
 +
  }
 +
  QToolBar {
 +
    background: ]]..background_color..[[;
 +
  }
 +
  QToolButton {
 +
    background: ]]..background_color..[[;
 +
    border-style: solid;
 +
    border-width: 2px;
 +
    border-color: ]]..border_color..[[;
 +
    border-radius: 5px;
 +
    font-family: BigNoodleTitling;
 +
    color: white;
 +
    margin: 2px;
 +
    font-size: 12pt;
 +
  }
 +
  QToolButton:hover { background-color: grey;}
 +
  QToolButton:focus { background-color: grey;}
 +
 
 +
  QTreeView {
 +
    background: ]]..background_color..[[;
 +
    color: white;
 +
  }
 +
 
 +
  QMenuBar{ background-color: ]]..background_color..[[;}
 +
 
 +
  QMenuBar::item{ background-color: ]]..background_color..[[;}
 +
 
 +
  QDockWidget::title {
 +
    background: ]]..border_color..[[;
 +
  }
 +
  QStatusBar {
 +
    background: ]]..border_color..[[;
 +
  }
 +
  QScrollBar:vertical {
 +
    background: ]]..background_color..[[;
 +
    width: 15px;
 +
    margin: 22px 0 22px 0;
 +
  }
 +
  QScrollBar::handle:vertical {
 +
    background-color: ]]..background_color..[[;
 +
    min-height: 20px;
 +
    border-width: 2px;
 +
    border-style: solid;
 +
    border-color: ]]..border_color..[[;
 +
    border-radius: 7px;
 +
  }
 +
  QScrollBar::add-line:vertical {
 +
  background-color: ]]..background_color..[[;
 +
  border-width: 2px;
 +
  border-style: solid;
 +
  border-color: ]]..border_color..[[;
 +
  border-bottom-left-radius: 7px;
 +
  border-bottom-right-radius: 7px;
 +
        height: 15px;
 +
        subcontrol-position: bottom;
 +
        subcontrol-origin: margin;
 +
  }
 +
  QScrollBar::sub-line:vertical {
 +
  background-color: ]]..background_color..[[;
 +
  border-width: 2px;
 +
  border-style: solid;
 +
  border-color: ]]..border_color..[[;
 +
  border-top-left-radius: 7px;
 +
  border-top-right-radius: 7px;
 +
        height: 15px;
 +
        subcontrol-position: top;
 +
        subcontrol-origin: margin;
 +
  }
 +
  QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
 +
    background: white;
 +
    width: 4px;
 +
    height: 3px;
 +
  }
 +
  QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
 +
    background: none;
 +
  }
 +
]])
 +
 
 +
-- if you'd like to reset it, use:
 +
setProfileStyleSheet("")
 +
 
 +
-- to only affect scrollbars within the main window and miniconsoles, prefix them with 'TConsole':
 +
setProfileStyleSheet[[
 +
  TConsole QScrollBar:vertical {
 +
      border: 2px solid grey;
 +
      background: #32CC99;
 +
      width: 15px;
 +
      margin: 22px 0 22px 0;
 +
  }
 +
  TConsole QScrollBar::handle:vertical {
 +
      background: white;
 +
      min-height: 20px;
 +
  }
 +
  TConsole QScrollBar::add-line:vertical {
 +
      border: 2px solid grey;
 +
      background: #32CC99;
 +
      height: 20px;
 +
      subcontrol-position: bottom;
 +
      subcontrol-origin: margin;
 +
  }
 +
  TConsole QScrollBar::sub-line:vertical {
 +
      border: 2px solid grey;
 +
      background: #32CC99;
 +
      height: 20px;
 +
      subcontrol-position: top;
 +
      subcontrol-origin: margin;
 +
  }
 +
  TConsole QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
 +
      border: 2px solid grey;
 +
      width: 3px;
 +
      height: 3px;
 +
      background: white;
 +
  }
 +
  TConsole QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
 +
      background: none;
 +
  }
 +
]]
 +
</syntaxhighlight>
 +
 
 +
{{MudletVersion|4.6}}
 +
 
 +
==setReverse==
 +
;setReverse([windowName], boolean)
 +
: Sets the current text to swap foreground and background color settings (true) or not (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will have it's colors swapped. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will have their foreground and background colors swapped until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
 +
 
 +
* ''windowName:''
 +
: (optional) name of the window to set the text colors to be reversed or not.
 +
 
 +
* ''boolean:''
 +
: A ''true'' or ''false'' that enables or disables reversing of the fore- and back-ground colors of text
 +
 
 +
;Example
 +
 
 +
<syntaxhighlight lang="lua">
 +
-- enable fore/back-ground color reversal of text
 +
setReverse(true)
 +
-- the following echo will have the text colors reversed
 +
echo("hi")
 +
-- turns off bolding, italics, underlines, colouring, and strikethrough (and, after this and overline have been added, them as well). It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
 +
resetFormat()
 +
</syntaxhighlight>
 +
 
 +
{{MudletVersion|3.17}}
 +
 
 +
{{note}} Although the visual effect on-screen is the same as that of text being selected if both apply to a piece of text they neutralise each other - however the effect of the reversal ''will'' be carried over in copies made by the "Copy to HTML" and in logs made in HTML format log file mode.
 +
 
 +
==setStrikeOut==
 +
;setStrikeOut([windowName], boolean)
 +
: Sets the current text font to be striken out (true) or not striken out (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be bolded. Any text you add after with [[Manual:Lua_Functions#echo|echo()]] or [[Manual:Lua_Functions#insertText|insertText()]] will be striken out until you use [[Manual:Lua_Functions#resetFormat|resetFormat()]].
 +
 
 +
* ''windowName:''
 +
: (optional) name of the window to set the text to be stricken out or not.
 +
 
 +
* ''boolean:''
 +
: A ''true'' or ''false'' that enables or disables striking out of text
 +
 
 +
;Example
 +
 
 +
<syntaxhighlight lang="lua">
 +
-- enable striken-out text
 +
setStrikeOut(true)
 +
-- the following echo will be have a strikethrough
 +
echo("hi")
 +
-- turns off bolding, italics, underlines, colouring, and strikethrough. It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
 +
resetFormat()
 +
</syntaxhighlight>
 +
 
 +
==setTextFormat==
 +
;setTextFormat(windowName, r1, g1, b1, r2, g2, b2, bold, underline, italics, [strikeout], [overline], [reverse])
 +
: Sets current text format of selected window. This is a more convenient means to set all the individual features at once compared to using [[#setFgColor|setFgColor]](windowName, r,g,b), [[#setBold|setBold]](windowName, true), [[#setItalics|setItalics]](windowName, true), [[#setUnderline|setUnderline]](windowName, true), [[#setStrikeOut|setStrikeOut]](windowName, true).
 +
: See Also: [[Manual:Lua_Functions#getTextFormat|getTextFormat()]]
 +
 
 +
;Parameters
 +
* ''windowName''
 +
: Specify name of selected window. If empty string "" or "main" format will be applied to the main console
 +
* ''r1,g1,b1''
 +
: To color text background, give number values in RBG style
 +
* ''r2,g2,b2''
 +
: To color text foreground, give number values in RBG style
 +
* ''bold''
 +
: To format text bold, set to 1 or true, otherwise 0 or false
 +
* ''underline''
 +
: To underline text, set to 1 or true, otherwise 0 or false
 +
* ''italics''
 +
: To format text italic, set to 1 or true, otherwise 0 or false
 +
* ''strikeout
 +
: (optional) To strike text out, set to 1 or true, otherwise 0 or false or simply no argument
 +
* ''overline
 +
: (optional) To use overline, set to 1 or true, otherwise 0 or false or simply no argument
 +
* ''reverse
 +
: (optional) To swap foreground and background colors, set to 1 or true, otherwise 0 or false or simply no argument
 +
 
 +
;Example:
 +
<syntaxhighlight lang="lua">
 +
--This script would create a mini text console and write with bold, struck-out, yellow foreground color and blue background color "This is a test".
 +
createMiniConsole( "con1", 0,0,300,100);
 +
setTextFormat("con1",0,0,255,255,255,0,true,0,false,1);
 +
echo("con1","This is a test")
 +
</syntaxhighlight>
 +
 
 +
{{note}} In versions prior to 3.7.0 the error messages ''and this wiki'' were wrong in that they had the foreground color parameters as r1, g1 and b1 and the background ones as r2, g2 and b2.
 +
 
 +
==setUnderline==
 +
;setUnderline(windowName, bool)
 +
: Sets the current text font to underline/non-underline mode. If the windowName parameters omitted, the main screen will be used.
 +
 
 +
==setUserWindowTitle==
 +
;setUserWindowTitle(windowName, text)
 +
: sets a new title text for the UserWindow windowName
 +
 
 +
;Parameters
 +
* ''windowName:''
 +
: Name of the userwindow
 +
* ''text''
 +
: new title text
 +
 
 +
{{MudletVersion|4.8}}
 +
 
 +
: See also: [[#resetUserWindowTitle|resetUserWindowTitle()]], [[#openUserWindow|openUserWindow()]]
 +
 
 +
==setUserWindowStyleSheet==
 +
;setUserWindowStyleSheet(windowName, markup)
 +
: Applies Qt style formatting to the border/title area of a userwindow via a special markup language.
 +
 
 +
;Parameters
 +
* ''windowName:''
 +
: Name of the userwindow
 +
* ''markup''
 +
: The string instructions, as specified by the Qt Style Sheet reference.
 +
: Note that when you dock the userwindow the border style is not provided by this
 +
 
 +
{{MudletVersion|4.10}}
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- changes the title area style of the UserWindow 'myUserWindow'
 +
setUserWindowStyleSheet("myUserWindow", [[QDockWidget::title{  
 +
     background-color: rgb(0,255,150);
 +
     border: 2px solid red;
 +
     border-radius: 8px;
 +
     text-align: center;     
 +
     }]])
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
: See also: [[#openUserWindow|openUserWindow()]]
 
: See also: [[#openUserWindow|openUserWindow()]]
  
==setWindow==
+
==setWindow==
;setWindow(windowName, name, [Xpos, Ypos, show])
+
;setWindow(windowName, name, [Xpos, Ypos, show])
: Changes the parent window of an element.
+
: Changes the parent window of an element.
{{MudletVersion|4.8}}
+
{{MudletVersion|4.8}}
 +
 
 +
;Parameters
 +
* ''windowName:''
 +
: Name of the userwindow which you want the element put in. If you want to put the element into the main window, use windowName "main".
 +
* ''name''
 +
: Name of the element which you want to switch the parent from. Elements can be labels, miniconsoles and the embedded mapper. If you want to move the mapper use the name "mapper"
 +
* ''Xpos:''
 +
: X position of the element. Measured in pixels, with 0 being the very left. Passed as an integer number. Optional, if not given it will be 0.
 +
* ''Ypos:''
 +
: Y position of the element. Measured in pixels, with 0 being the very top. Passed as an integer number. Optional, if not given it will be 0.
 +
* ''show:''
 +
: true or false to decide if the element will be shown or not in the new parent window. Optional, if not given it will be true.
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
setWindow("myuserwindow", "mapper")
 +
-- This will put your embedded mapper in your userwindow "myuserwindow".
 +
</syntaxhighlight>
 +
 
 +
==setWindowWrap==
 +
;setWindowWrap(windowName, wrapAt)
 +
: sets at what position in the line the will start word wrap.
 +
 
 +
;Parameters
 +
* ''windowName:''
 +
: Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
 +
* ''wrapAt:''
 +
: Number of characters at which the wrap must happen at the latest. This means, it probably will be wrapped earlier than that.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
setWindowWrap("main", 10)
 +
display("This is just a test")
 +
 
 +
-- The following output will result in the main window console:
 +
"This is
 +
just a
 +
test"
 +
 
 +
-- wrap to the exact amount that fits on the screen
 +
setWindowWrap(window, getColumnCount(window))
 +
</syntaxhighlight>
 +
 
 +
==setWindowWrapHangingIndent==
 +
 
 +
;setWindowWrapHangingIndent(windowName, indentSize)
 +
 
 +
:Sets how many spaces the second and all subsequent line(s) of text from a wrapped line will be indented.
 +
 
 +
;See also: [[#setWindowWrap|setWindowWrap()]], [[#setWindowWrapIndent|setWindowWrapIndent()]]
 +
 
 +
{{MudletVersion|4.20}}
 +
 
 +
;Parameters
 +
* ''windowName:''
 +
: Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
 +
* ''indentSize:''
 +
: Number of spaces which hanging wrapped lines are prefixed with.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- |Make wrapped text indent
 +
-- |  like this. (Keep going
 +
-- |  until a linebreak.)
 +
 
 +
setWindowWrap("main", 25)
 +
setWindowWrapIndent("main", 0)          -- First line indent
 +
setWindowWrapHangingIndent("main", 2)  -- subsequent line(s)
 +
</syntaxhighlight>
 +
 
 +
==setWindowWrapIndent==
 +
 
 +
;setWindowWrapIndent(windowName, indentSize)
  
;Parameters
+
:Sets how many spaces the first line of text from a wrapped line will be indented.  
* ''windowName:''
 
: Name of the userwindow which you want the element put in. If you want to put the element into the main window, use windowName "main".
 
* ''name''
 
: Name of the element which you want to switch the parent from. Elements can be labels, miniconsoles and the embedded mapper. If you want to move the mapper use the name "mapper"
 
* ''Xpos:''
 
: X position of the element. Measured in pixels, with 0 being the very left. Passed as an integer number. Optional, if not given it will be 0.
 
* ''Ypos:''
 
: Y position of the element. Measured in pixels, with 0 being the very top. Passed as an integer number. Optional, if not given it will be 0.
 
* ''show:''
 
: true or false to decide if the element will be shown or not in the new parent window. Optional, if not given it will be true.
 
;Example
 
<syntaxhighlight lang="lua">
 
setWindow("myuserwindow", "mapper")
 
-- This will put your embedded mapper in your userwindow "myuserwindow".
 
</syntaxhighlight>
 
  
==setWindowWrap==
+
;See also: [[#setWindowWrap|setWindowWrap()]], [[#setWindowWrapHangingIndent|setWindowWrapHangingIndent()]]
;setWindowWrap(windowName, wrapAt)
 
: sets at what position in the line the will start word wrap.
 
  
;Parameters
+
{{MudletVersion|4.20}}
* ''windowName:''
 
: Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
 
* ''wrapAt:''
 
: Number of characters at which the wrap must happen at the latest. This means, it probably will be wrapped earlier than that.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
setWindowWrap("main", 10)
 
display("This is just a test")
 
 
 
-- The following output will result in the main window console:
 
"This is
 
just a
 
test"
 
</syntaxhighlight>
 
 
 
==setWindowWrapIndent==
 
;setWindowWrapIndent(windowName, wrapTo)
 
: sets how many spaces wrapped text will be indented with (after the first line of course).
 
  
 
;Parameters
 
;Parameters
 
* ''windowName:''
 
* ''windowName:''
 
: Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
 
: Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
* ''wrapTo:''
+
* ''indentSize:''
 
: Number of spaces which wrapped lines are prefixed with.
 
: Number of spaces which wrapped lines are prefixed with.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setWindowWrap("main", 10)
+
-- |  Make wrapped text indent
setWindowWrapIndent("main", 3)
+
-- |indent like this. (Only
display("This is just a test")
+
-- |first line indented.)
  
-- The following output will result in the main window console:
+
setWindowWrap("main", 25)
"This is
+
setWindowWrapIndent("main", 2)          -- First line indent
  just a
+
setWindowWrapHangingIndent("main", 0)  -- subsequent line(s)
  test"
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 21:20, 1 April 2026

UI Functions

All functions that help you construct custom GUIs. They deal mainly with miniconsole/label/gauge creation and manipulation as well as displaying or formatting information on the screen.

addCommandLineMenuEvent

addCommandLineMenuEvent([window,] label, eventName)

Adds item to right click menu associated with command line.

Mudlet VersionAvailable in Mudlet4.14+
See also
removeCommandLineMenuEvent()
Parameters
  • window:
Window that command line belongs to. Optional, will default to "main" (main window console)
  • label:
Label of item
  • eventName:
Event name that will be fired when clicked.
Returns
  • Returns true if the mouse event was added successfully.
Example
addCommandLineMenuEvent("My very own special paste from clipboard", "pasteFromClipboardWithoutLineBreaks" )
registerAnonymousEventHandler("pasteFromClipboardWithoutLineBreaks", function()
  local text = string.gsub(getClipboardText(), "[\r|\n]", "")
  appendCmdLine(text)
end)

addMouseEvent

addMouseEvent(uniqueName, eventName, [displayName, tooltipText])
Registers a new context menu option when right-clicked on a console window. Will return true if the event was added successfully, otherwise nil+message will be returned. If the displayName isn't set, uniqueName will be used for the menu label. eventName should be a Mudlet event that will handle the click data that includes event, unique name, window name, selection upper left column and row and selection bottom right column and row in that order. This is intended to be used with available cursor functions for any selection or processing needs.
Mudlet VersionAvailable in Mudlet4.13+
See also
getMouseEvents(), moveCursor()
Parameters
  • uniqueName:
A unique identifier for the mouse event.
  • eventName:
Name of the Mudlet event that will handle the data.
  • displayName:
(optional) Label text for the mouse context menu. If not set, the label defaults to uniqueName.
  • tooltipText:
(optional) Tooltip text when mouse is hovered on the option. If not set, no tooltip will be visible.
Returns
  • Returns true if the mouse event was added successfully.
Example
-- An example showing implementing a hecho-friendly copy option:

addMouseEvent("hecho copy", "onMouseCopyExample")

function rgbToHex(r,g,b)
    local rgb = (r * 0x10000) + (g * 0x100) + b
    return string.format("#%x", rgb)
end

function onMouseCopyExample(event, menu, window, startCol, startRow, endCol, endRow)
  -- Check whether there's an actual selection
  if startCol == endCol and startRow == endRow then return end
  local parsed = ""
  local lastColor = nil
  -- Loop through each symbol within the range
  for l = startRow, endRow do
    local cStart = l == startRow and startCol or 0
    moveCursor(window, cStart, l)
    local cEnd = l == endRow and endCol or #getCurrentLine() - 1
    for c = cStart, cEnd do
      selectSection(window, c, 1)
      local symbol = getSelection(window) or ""
      -- Convert the foreground color to a hex format, suitable for hecho
      local color = rgbToHex(getFgColor(window))
      -- Don't repeat the color if previous one was the same
      if color == lastColor then
        parsed = parsed .. symbol
      else
        lastColor = color
        parsed = parsed .. color .. symbol
      end
    end
    if l ~= endRow then parsed = parsed .. "\n" end
  end
  setClipboardText(parsed)
end

registerAnonymousEventHandler("onMouseCopyExample", "onMouseCopyExample")

ansi2decho

ansi2decho(text, default_colour)
Converts ANSI colour sequences in text to colour tags that can be processed by the decho() function.
See also: decho()
Mudlet VersionAvailable in Mudlet3.0+

Note Note: ANSI bold is available since Mudlet 3.7.1+.

Note Note: underline, italics, overline, and strikethrough supported since Mudlet 4.15+

Parameters
  • text:
String that contains ANSI colour sequences that should be replaced.
  • default_colour:
Optional - ANSI default colour code (used when handling orphan bold tags).
Return values
  • string text:
The decho-valid converted text.
  • string colour:
The ANSI code for the last used colour in the substitution (useful if you want to colour subsequent lines according to this colour).
Example
local replaced = ansi2decho('\27[0;1;36;40mYou say in a baritone voice, "Test."\27[0;37;40m')
-- 'replaced' should now contain <r><0,255,255:0,0,0>You say in a baritone voice, "Test."<r><192,192,192:0,0,0>
decho(replaced)

Or show a complete colourful squirrel! It's a lotta code to do all the colours, so click the Expand button on the right to show it:

decho(ansi2decho([[
                                                  �[38;5;95m▄�[48;5;95;38;5;130m▄▄▄�[38;5;95m█�[49m▀�[0m    �[0m
╭───────────────────────╮          �[38;5;95m▄▄�[0m          �[38;5;95m▄�[48;5;95;38;5;130m▄▄�[48;5;130m█�[38;5;137m▄�[48;5;137;38;5;95m▄�[49m▀�[0m      �[0m
│                       │         �[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95m▄�[49;38;5;95m▄▄▄�[48;5;95;38;5;137m▄▄▄�[49;38;5;95m▄▄�[48;5;95;38;5;130m▄�[48;5;130m███�[38;5;137m▄�[48;5;137m█�[48;5;95;38;5;95m█�[0m       �[0m
│  Encrypt everything!  │       �[38;5;95m▄�[48;5;187;38;5;16m▄�[48;5;16;38;5;187m▄�[38;5;16m█�[48;5;137;38;5;137m███�[38;5;187m▄�[38;5;16m▄▄�[38;5;137m██�[48;5;95;38;5;95m█�[48;5;130;38;5;130m█████�[48;5;137;38;5;137m██�[48;5;95;38;5;95m█�[0m       �[0m
│                       ├────  �[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;16m▄▄▄�[48;5;137m███�[48;5;16;38;5;16m█�[48;5;187m▄�[48;5;16m█�[48;5;137;38;5;137m█�[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[0m      �[0m
╰───────────────────────╯      �[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;16m▄�[38;5;16m█�[38;5;137m▄�[48;5;137m██████�[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95m▄�[49;38;5;95m▄�[0m    �[0m
                                �[38;5;95m▀�[48;5;137m▄�[38;5;137m███████�[38;5;95m▄�[49m▀�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95m▄�[49;38;5;95m▄�[0m   �[0m
                                  �[48;5;95;38;5;187m▄▄▄�[38;5;137m▄�[48;5;137m██�[48;5;95;38;5;95m█�[0m    �[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[48;5;137;38;5;137m███�[48;5;95m▄�[49;38;5;95m▄�[0m  �[0m
                                 �[38;5;187m▄�[48;5;187m███�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m   �[48;5;95;38;5;95m█�[48;5;130;38;5;130m█████████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[0m �[0m
                                �[38;5;187m▄�[48;5;187m███�[38;5;137m▄�[48;5;137m█�[48;5;95;38;5;95m█�[48;5;137;38;5;137m███�[48;5;95m▄�[49;38;5;95m▄�[0m  �[38;5;95m▀�[48;5;130m▄�[38;5;130m███████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                               �[48;5;95;38;5;95m█�[48;5;187;38;5;187m████�[48;5;137;38;5;137m██�[48;5;95m▄�[48;5;137;38;5;95m▄�[38;5;137m██�[38;5;95m▄�[38;5;137m█�[48;5;95m▄�[49;38;5;95m▄�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                              �[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;187;38;5;187m████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95m▄�[49;38;5;95m▄�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                           �[38;5;95m▄�[48;5;95m██�[48;5;137m▄▄�[48;5;187;38;5;187m████�[48;5;137;38;5;95m▄▄�[48;5;95;38;5;137m▄�[48;5;137m█�[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;137m████�[48;5;95;38;5;95m█�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                                �[48;5;187;38;5;187m███�[48;5;95m▄�[38;5;137m▄▄▄▄�[48;5;137m██████�[48;5;95;38;5;95m█�[49m▄�[48;5;95;38;5;130m▄�[48;5;130m██████�[48;5;137;38;5;137m███�[38;5;95m▄�[49m▀�[0m�[0m
                                �[48;5;187;38;5;95m▄�[38;5;187m████�[48;5;137;38;5;137m█�[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;137m█████�[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[38;5;137m▄�[48;5;137m████�[48;5;95;38;5;95m█�[0m �[0m
                                �[48;5;95;38;5;95m█�[48;5;187;38;5;137m▄�[38;5;187m███�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██████�[48;5;95m▄▄�[48;5;130m▄▄▄▄▄�[48;5;137m██████�[48;5;95;38;5;95m█�[0m  �[0m
                              �[38;5;95m▄▄▄�[48;5;95;38;5;137m▄�[48;5;187m▄�[38;5;187m██�[48;5;95m▄�[48;5;137;38;5;95m▄�[38;5;137m█████�[38;5;95m▄�[38;5;137m███████████�[48;5;95;38;5;95m█�[0m   �[0m
                            �[38;5;95m▀▀▀▀▀▀▀▀�[48;5;187m▄▄▄�[48;5;95;38;5;137m▄�[48;5;137m██�[38;5;95m▄�[49m▀�[0m �[38;5;95m▀▀�[48;5;137m▄▄▄▄▄▄�[49m▀▀▀�[0m    �[0m
                                  �[38;5;95m▀▀▀▀▀▀▀▀▀�[0m                 �[0m
                                                                    ]]))

Squirrel-in-Mudlet.png

ansi2string

ansi2string(text)
Strips ANSI colour sequences from a string (text)
See also: ansi2decho()
Mudlet VersionAvailable in Mudlet4.10+
Parameters
  • text:
String that contains ANSI colour sequences that should be removed.
Return values
  • string text:
The plain text without ANSI colour sequences.
Example
local replaced = ansi2string('\27[0;1;36;40mYou say in a baritone voice, "Test."\27[0;37;40m')
-- 'replaced' should now contain You say in a baritone voice, "Test."
print(replaced)

appendBuffer

appendBuffer(name)
Pastes the previously copied rich text (including text formats like color etc.) into user window name.
See also: selectCurrentLine(), copy(), paste()
Parameters
  • name:
The name of the user window to paste into. Passed as a string.
Example
--selects and copies an entire line to user window named "Chat"
selectCurrentLine()
copy()
appendBuffer("Chat")

bg

bg([window, ]colorName)
Changes the background color of the text. Useful for highlighting text.
See Also: fg(), setBgColor()
Parameters
  • window:
The miniconsole to operate on - optional. If you'd like it to work on the main window, don't specify anything, or use main (since Mudlet 3.0).
  • colorName:
The name of the color to set the background to. Color Table
Example
--This would change the background color of the text on the current line to magenta
selectCurrentLine()
bg("magenta")

-- or echo text with a green background to a miniconsole
bg("my window", "green")
echo("my window", "some green text\n")

calcFontSize

calcFontSize(window_or_fontsize, [fontname])
Returns the average height and width of characters in a particular window, or a font name and size combination. Helpful if you want to size a miniconsole to specific dimensions.
Returns two numbers, width/height
See also: setMiniConsoleFontSize(), getMainWindowSize()
Parameters
  • window_or_fontsize:
The miniconsole or font size you are wanting to calculate pixel sizes for.
  • fontname:
Specific font name (along with the size as the first argument) to calculate for.

Note Note: Window as an argument is available in Mudlet 3.10+, and font name in Mudlet 4.1+.

Example
--this snippet will calculate how wide and tall a miniconsole designed to hold 4 lines of text 20 characters wide
--would need to be at 9 point font, and then changes miniconsole Chat to be that size
local width,height = calcFontSize(9)
width = width * 20
height = height * 4
resizeWindow("Chat", width, height)

cecho

cecho([window], text)
Echoes text that can be easily formatted with colour and the below tags. You can also include unicode art in it - try some examples from 1lineart.
Formatting
<b>  - bold
</b> - bold off
<i>  - italics
</i> - italics off
<u>  - underline
</u> - underline off
<o>  - overline
</o> - overline off
<s>  - strikethrough
</s> - strikethrough off
See also: decho(), hecho(), creplaceLine()

Note Note: Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you cecho it will erase any previous echo sent to the label.

Parameters
  • window:
Optional - the window name to echo to - can either be none or "main" for the main window, or a miniconsole, userwindow, or label name.
  • text:
The text to display, with color names inside angle brackets <>, ie <red>. If you'd like to use a background color, put it after a colon : - <:red>. You can use the <reset> tag to reset to the default color. You can select any from this list: Color Table
Example
cecho("Hi! This text is <red>red, <blue>blue, <green> and green.")

cecho("Hi! This text is <ansi_001>red, <ansi_004>blue, <ansi_002> and green<reset> using ansi keys.")

cecho("<:green>Green background on normal foreground. Here we add an <ivory>ivory foreground.")

cecho("<blue:yellow>Blue on yellow text!")

cecho("\n<red>Red text with <i>italics</i>, <u>underline</u>, <s>strikethrough</s>, <o>overline</o>, and <b>bold</b>.")

cecho("\n<green><o><u>Green text with over and underline at the same time.</o></u>")

-- \n adds a new line
cecho("<red>one line\n<green>another line\n<blue>last line")

cecho("myinfo", "<green>All of this text is green in the myinfo miniconsole.")

cecho("<green>(╯°□°)<dark_green>╯︵ ┻━┻")

cecho("°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸")

cecho([[
 ██╗    ██╗     ██╗███╗   ██╗███████╗     █████╗ ██████╗ ████████╗
███║    ██║     ██║████╗  ██║██╔════╝    ██╔══██╗██╔══██╗╚══██╔══╝
╚██║    ██║     ██║██╔██╗ ██║█████╗      ███████║██████╔╝   ██║
 ██║    ██║     ██║██║╚██╗██║██╔══╝      ██╔══██║██╔══██╗   ██║
 ██║    ███████╗██║██║ ╚████║███████╗    ██║  ██║██║  ██║   ██║
 ╚═╝    ╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝    ╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝
]])

cechoLink

cechoLink([windowName], text, command, hint, true)
Echos a piece of text as a clickable link, at the end of the current selected line - similar to cecho(). This version allows you to use colours within your link text.
See also: echoLink(), dechoLink(), hechoLink()
Parameters
  • windowName:
optional parameter, allows selection between sending the link to a miniconsole or the main window.
  • text:
text to display in the echo. Same as a normal cecho().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
text for the tooltip to be displayed when the mouse is over the link.
  • true:
requires argument for the colouring to work.
Example
-- echo a link named 'press me!' that'll send the 'hi' command to the game
cechoLink("<red>press <brown:white>me!", function() send("hi") end, "This is a tooltip", true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
cechoLink("<red>press <brown:white>me!", [[send("hi")]], "This is a tooltip", true)

cecho2ansi

ansiFormattedString = cecho2ansi(text)
Converts cecho formatted text to ansi formatted text. Used by cfeedTriggers, but useful if you want ansi formatted text for any other reason.
See also
cecho(), cfeedTriggers()
Mudlet VersionAvailable in Mudlet4.15+

Note Note: This function uses the ansi short colors (0-15) for color names which have base 16 ansi equivalents, such as 'red', 'blue', "lightBlue", "cyan", etc rather than the values defined in the color_table. If there is no base ansi equivalent then it will use the rgb values from the color_table for the color.

Parameters
  • text:
The cecho formatted text for conversion
Returns
  • String converted to ansi formatting
Example
-- replicates the functionality of cfeedTriggers() for a single line.
-- you would most likely just use cfeedTriggers, but it makes for a tidy example.
feedTriggers(cecho2ansi("\n<red>This is red.<reset> <i>italic</i>, <b>bold</b>, <s>strikethrough</s>, <u>underline</u>\n"))


cecho2decho

convertedString = cecho2decho(str)
Converts a cecho formatted string to a decho formatted one.
See also
decho2cecho(), cecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from cecho to decho
Returns
  • a string formatted for decho
Example
-- convert to a decho string and use decho to display it
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
decho(cecho2decho(cechoString))

cecho2hecho

convertedString = cecho2hecho(str)
Converts a cecho formatted string to an hecho formatted one.
See also
hecho2cecho(), cecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from cecho to decho
Returns
  • a string formatted for hecho
Example
-- convert to an hecho string and use hecho to display it
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
hecho(cecho2hecho(cechoString))

cecho2html

convertedString = cecho2html(str[, resetFormat])
Converts a cecho formatted string to an html formatted one.
See also
decho2cecho(), cecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from cecho to decho
  • resetFormat
optional table of default formatting options. As returned by getLabelFormat()
Returns
  • a string formatted for html
Example
-- create the base string
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"

-- create a label to display the result onto
testLabel = Geyser.Label:new({name = "testLabel"})

-- convert the cecho string to an html one, using the default formatting of testLabel created above
local htmlString = cecho2html(cechoString, testLabel:getFormat())

-- and finally echo it to the label to see
-- I use rawEcho as that displays the html exactly as given.
testLabel:rawEcho(htmlString)

cechoPopup

cechoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like cecho(). The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
(optional) name of the window to echo to. Use either main or omit for the main window, or the miniconsoles name otherwise.
  • text:
the text to display
  • {commands}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}
  • {hints}:
a table of strings which will be shown on the popup and right-click menu. ie, {"send the hi command", "echo hi to yourself"}
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Example
-- Create some text as a clickable with a popup menu:
cechoPopup("<red>activities<reset> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
cechoPopup("<red>activities<reset> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)

cinsertLink

cinsertLink([windowName], text, command, hint, true)
Echos a piece of text as a clickable link, at the end of the current cursor position - similar to cinsertText(). This version allows you to use colours within your link text.
See also: insertLink(), hinsertLink()
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
optional parameter, allows selection between sending the link to a miniconsole or the main window.
  • text:
text to display in the echo. Same as a normal cecho().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
text for the tooltip to be displayed when the mouse is over the link.
  • true:
requires argument for the colouring to work.
Example
-- echo a link named 'press me!' that'll send the 'hi' command to the game
cinsertLink("<red>press <brown:white>me!", function() send("hi") end, "This is a tooltip", true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
cinsertLink("<red>press <brown:white>me!", [[send("hi")]], "This is a tooltip", true)

cinsertPopup

cinsertPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current cursor position, like cinsertText(). The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
(optional) name of the window to echo to. Use either main or omit for the main window, or the miniconsoles name otherwise.
  • text:
the text to display
  • {commands}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}
  • {hints}:
a table of strings which will be shown on the popup and right-click menu. ie, {"send the hi command", "echo hi to yourself"}
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Example
-- Create some text as a clickable with a popup menu:
cinsertPopup("<red>activities<reset> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)

-- Create some text as a clickable with a popup menu:
cinsertPopup("<red>activities<reset> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)

cinsertText

cinsertText([window], text)
inserts text at the current cursor position, with the possibility for color tags.
See Also: cecho(), creplaceLine()
Parameters
  • window:
Optional - the window name to echo to - can either be none or "main" for the main window, or the miniconsoles name.
  • text:
The text to display, with color names inside angle brackets <>, ie <red>. If you'd like to use a background color, put it after a double colon : - <:red>. You can use the <reset> tag to reset to the default color. You can select any from this list: Color Table
Example
cinsertText("Hi! This text is <red>red, <blue>blue, <green> and green.")

cinsertText("<:green>Green background on normal foreground. Here we add an <ivory>ivory foreground.")

cinsertText("<blue:yellow>Blue on yellow text!")

cinsertText("myinfo", "<green>All of this text is green in the myinfo miniconsole.")

clearUserWindow

clearUserWindow([name])
This is (now) identical to clearWindow().

clearWindow

clearWindow([windowName])
Clears the label, mini console, or user window with the name given as argument (removes all text from it). If you don't give it a name, it will clear the main window.
Parameters
  • windowName:
(optional) The name of the label, mini console, or user window to clear. Passed as a string.
Example
--This would clear a label, user window, or miniconsole with the name "Chat"
clearWindow("Chat")
-- this can clear your whole main window
clearWindow()

closestColor

closestColor(colorOrR[,G,B])
Returns the closest color from the color_table to the one provided for use in cecho and associated functions.
Mudlet VersionAvailable in Mudlet4.13+
Parameters
  • colorOrR:
Either the string representation of a color from decho or hecho (IE "#ff0077" or "<255,0,128>"), a table of color values (IE {255,0,18}), or the Red component of RGB when followed by two next optional parameters
  • G:
(optional) green component of RGB coordinates. Only needed if first parameter sent as the Red component only
  • B:
(optional) blue component of RGB coordinates. Only needed if first parameter sent as the Red component only
Returns
  • The closest color name from the color_table to the one supplied on success
  • nil + error if it cannot parse the parameters into a color.
Example
local colorName = closestColor(255, 0, 0) -- "ansi_light_red"
local colorName = closestColor({127, 255, 127}) -- "ansi_120"
local colorName = closestColor("<127, 127, 127>") -- "ansi_008"
local colorName = closestColor("#a020e6") -- "purple"
local colorName = closestColor("blue") -- "blue" (you wouldn't necessarily do this on purpose, but during automated color conversions this might occur)

copy

copy([windowName])
Copies the current selection to the lua virtual clipboard. This function operates on rich text, i. e. the selected text including all its format codes like colors, fonts etc. in the lua virtual clipboard until it gets overwritten by another copy operation.
See also: selectString(), selectCurrentLine(), paste(), appendBuffer(), replace(), createMiniConsole(), openUserWindow()
Parameters
  • windowName (optional):
the window from which to copy text - use the main console if not specified.
Example
-- This script copies the current line on the main screen to a window (miniconsole or userwindow) called 'chat' and gags the output on the main screen.
selectString(line, 1)
copy()
appendBuffer("chat")
replace("This line has been moved to the chat window!")

copy2decho

copy2decho([window], [stringToCopy], [instanceToCopy])
Copies a string from the current line of window, including color information in decho format.
See also: decho()
Mudlet VersionAvailable in Mudlet4.8+
Parameters
  • window (optional):
the window to copy the text from. Defaults to "main".
  • stringToCopy (optional):
the string to copy. Defaults to copying the entire line.
  • instanceToCopy (optional):
the instance of the string to copy. Defaults to 1.
Example
-- This copies the current line on the main console and dechos it to a miniconsole named "test"
decho("test", copy2decho())
-- This when put into a trigger would copy matches[2] with color information and decho it to a Geyser miniconsole stored as the variable enemylist
enemylist:decho(copy2decho(matches[2]))

copy2html

copy2html([window], [stringToCopy], [instanceToCopy])
Copies a string from the current line of window, including color information in html format for echoing to a label.
Mudlet VersionAvailable in Mudlet4.8+
Parameters
  • window (optional):
the window to copy the text from. Defaults to "main"
  • stringToCopy (optional):
the string to copy. Defaults to copying the entire line
  • instanceToCopy (optional):
the instance of the string to copy. Defaults to 1
Example
-- This copies the current line on the main console and echos it to a label named "TestLabel"
echo("TestLabel", copy2html())
-- This when put into a trigger would copy matches[2] with color information and echo it to a Geyser label stored as the variable enemylist
enemylist:echo(copy2html(matches[2]))

createBuffer

createBuffer(name)
Creates a named buffer for formatted text, much like a miniconsole, but the buffer is not intended to be shown on the screen - use it for formatting text or storing formatted text.
See also: selectString(), selectCurrentLine(), copy(), paste()
Parameters
  • name:
The name of the buffer to create.
Example
--This creates a named buffer called "scratchpad"
createBuffer("scratchpad")

createCommandLine

createCommandLine([name of userwindow], name, x, y, width, height)
Creates a new command line inside the main window of Mudlet. If only a command line inside a miniConsole/UserWindow is needed see enableCommandLine().
You can use appendCmdLine() / getCmdLine() and other command line functions to customize the input.

Note Note: setCmdLineAction allows you to attach an action to your command line input.

Returns true or false.
See also: enableCommandLine(), disableCommandLine(), clearCmdLine(), getCmdLine(), printCmdLine(), appendCmdLine(), , selectCmdLineText()
Parameters
  • name of userwindow:
Name of userwindow the command line is created in. Optional, defaults to the main window if not provided.
  • name:
The name of the command line. Must be unique. Passed as a string.
  • x, y, width, height
Parameters to set the command line size and location - it is also possible to set them by using moveWindow() and resizeWindow(), as createCommandLine() will only set them once.
Mudlet VersionAvailable in Mudlet4.10+

createConsole

createConsole([name of userwindow], consoleName, fontSize, charsPerLine, numberOfLines, Xpos, Ypos)
Makes a new miniconsole which can be sized based upon the width of a 'W' character and the extreme top and bottom positions any character of the font should use. The background will be black, and the text color white.
Parameters
  • name of userwindow:
Name of userwindow your new miniconsole is created in. Optional, defaults to the main window if not provided.
  • consoleName:
The name of your new miniconsole. Passed as a string.
  • fontSize:
The font size to use for the miniconsole. Passed as an integer number.
  • charsPerLine:
How many characters wide to make the miniconsole. Passed as an integer number.
  • numberOfLines:
How many lines high to make the miniconsole. Passed as an integer number.
  • Xpos:
X position of miniconsole. Measured in pixels, with 0 being the very left. Passed as an integer number.
  • Ypos:
Y position of miniconsole. Measured in pixels, with 0 being the very top. Passed as an integer number.

Note Note: userwindow argument only available in 4.6.1+

Example
-- this will create a console with the name of "myConsoleWindow", font size 8, 80 characters wide,
-- 20 lines high, at coordinates 300x,400y
createConsole("myConsoleWindow", 8, 80, 20, 200, 400)

Note Note:

(For Mudlet Makers) This function is implemented outside the application's core via the GUIUtils.lua file of the Mudlet supporting Lua code using createMiniConsole() and other functions to position and size the mini-console and configure the font.

createGauge

createGauge([name of userwindow], name, width, height, Xpos, Ypos, gaugeText, r, g, b, orientation)
createGauge([name of userwindow], name, width, height, Xpos, Ypos, gaugeText, colorName, orientation)
Creates a gauge that you can use to express completion with. For example, you can use this as your healthbar or xpbar.
See also: moveGauge(), setGauge(), setGaugeText(), setGaugeStyleSheet()
Parameters
  • name of userwindow:
Name of userwindow the gauge is created in. Optional, defaults to the main window if not provided.
  • name:
The name of the gauge. Must be unique, you can not have two or more gauges with the same name. Passed as a string.
  • width:
The width of the gauge, in pixels. Passed as an integer number.
  • height:
The height of the gauge, in pixels. Passed as an integer number.
  • Xpos:
X position of gauge. Measured in pixels, with 0 being the very left. Passed as an integer number.
  • Ypos:
Y position of gauge. Measured in pixels, with 0 being the very top. Passed as an integer number.
  • gaugeText:
Text to display on the gauge. Passed as a string, unless you do not wish to have any text, in which case you pass nil
  • r:
The red component of the gauge color. Passed as an integer number from 0 to 255
  • g:
The green component of the gauge color. Passed as an integer number from 0 to 255
  • b:
The blue component of the gauge color. Passed as an integer number from 0 to 255
  • colorName:
the name of color for the gauge. Passed as a string.
  • orientation:
the gauge orientation. Can be horizontal (fills from left to right), vertical (fills bottom to top), goofy (fills right to left), or batty (fills top to bottom).

Note Note: userwindow argument only available in 4.6.1+

Example
-- This would make a gauge at that's 300px width, 20px in height, located at Xpos and Ypos and is green.
-- The second example is using the same names you'd use for something like [[fg]]() or [[bg]]().
createGauge("healthBar", 300, 20, 30, 300, nil, 0, 255, 0)
createGauge("healthBar", 300, 20, 30, 300, nil, "green")


-- If you wish to have some text on your label, you'll change the nil part and make it look like this:
createGauge("healthBar", 300, 20, 30, 300, "Now with some text", 0, 255, 0)
-- or
createGauge("healthBar", 300, 20, 30, 300, "Now with some text", "green")

Note Note:

If you want to put text on the back of the gauge when it's low, use an echo with the <gauge name>_back.
echo("healthBar_back", "This is a test of putting text on the back of the gauge!")

createLabel

createLabel([name of userwindow], name, Xpos, Ypos, width, height, fillBackground, [enableClickthrough])
Creates a highly manipulable overlay which can take some css and html code for text formatting. Labels are clickable, and as such can be used as a sort of button. Labels are meant for small variable or prompt displays, messages, images, and the like. You should not use them for larger text displays or things which will be updated rapidly and in high volume, as they are much slower than miniconsoles.
Returns true or false.
See also: hideWindow(), showWindow(), resizeWindow(), setLabelClickCallback(), setTextFormat(), getTextFormat(), moveWindow(), setBackgroundColor(), getMainWindowSize(), calcFontSize(), deleteLabel()
Parameters
  • name of userwindow: Name of userwindow label is created in. Optional, defaults to the main window if not provided.
  • name: name of the label. Must be unique, you can not have two or more labels with the same name. Passed as a string.
  • Xpos: X position of the label. Measured in pixels, with 0 being the very left. Passed as an integer number.
  • Ypos: Y position of the label. Measured in pixels, with 0 being the very top. Passed as an integer number.
  • width: width of the label, in pixels. Passed as an integer number.
  • height: height of the label, in pixels. Passed as an integer number.
  • fillBackground: whether or not to display the background. Passed as integer number (1 or 0) or as boolean (true, false). 1 or true will display the background color, 0 or false will not.
  • enableClickthrough: whether or not enable clickthrough on this label. Passed as integer number (1 or 0) or as boolean (true, false). 1 or true will enable clickthrough, 0 or false will not. Optional, defaults to clickthrough not enabled if not provided.

Note Note: userwindow argument only available in 4.6.1+

Example
-- a label situated at x=300 y=400 with dimensions 100x200
createLabel("a very basic label",300,400,100,200,1)
-- this example creates a transparent overlay message box to show a big warning message "You are under attack!" in the middle
-- of the screen. Because the background color has a transparency level of 150 (0-255, with 0 being completely transparent
-- and 255 opaque) the background text can still be read through.
local width, height = getMainWindowSize()
createLabel("messageBox",(width/2)-300,(height/2)-100,250,150,1)
resizeWindow("messageBox",500,70)
moveWindow("messageBox", (width/2)-300,(height/2)-100 )
setBackgroundColor("messageBox", 255, 204, 0, 200)
echo("messageBox", [[<p style="font-size:35px"><b><center><font color="red">You are under attack!</font></center></b></p>]])

-- you can also make it react to clicks!
mynamespace = {
  messageBoxClicked = function()
    echo("hey you've clicked the box!\n")
  end
}

setLabelClickCallback("messageBox", "mynamespace.messageBoxClicked")


-- uncomment code below to make it also hide after a short while
-- tempTimer(2.3, [[hideWindow("messageBox")]] ) -- close the warning message box after 2.3 seconds

createMiniConsole

createMiniConsole([name of userwindow], name, x, y, width, height)
Opens a miniconsole window inside the main window of Mudlet. This is the ideal fast colored text display for everything that requires a bit more text, such as status screens, chat windows, etc. Unlike labels, you cannot have transparency in them.
You can use clearWindow() / moveCursor() and other functions for this window for custom printing as well as copy & paste functions for colored text copies from the main window. setWindowWrap() will allow you to set word wrapping, and move the main window to make room for miniconsole windows on your screen (if you want to do this as you can also layer mini console and label windows) see setBorderSizes(), setBorderColor() functions.
Returns true or false.
See also: createLabel(), hideWindow(), showWindow(), resizeWindow(), setTextFormat(), getTextFormat(), moveWindow(), setMiniConsoleFontSize(), handleWindowResizeEvent(), setBorderSizes(), setWindowWrap(), getMainWindowSize(), setMainWindowSize(), calcFontSize()
Parameters
  • name of userwindow: (available in Mudlet 4.6.1+)
(Optional) name of userwindow the miniconsole is created in. Defaults to the main window if not provided.
  • name:
The name of the miniconsole. Must be unique. Passed as a string.
  • x, y, width, height
Parameters to set set the window size and location - in Mudlet version 2.1 and below it's best to set them via moveWindow() and resizeWindow(), as createMiniConsole() will only set them once. Starting with Mudlet version 3.0, however, that is fine and calling createMiniConsole() will re-position your miniconsole appropriately.
Note
Profile switching and autowrap
When using miniconsoles with autowrap enabled across multiple profiles, text may appear cut off on the right side immediately after switching profiles. This occurs because Qt's widget geometry isn't fully updated until the event loop processes visibility changes.
If you're implementing custom autowrap logic outside of Geyser, defer width-dependent calculations using tempTimer(0, function() ... end) to allow geometry updates to complete:
-- Example: Refreshing miniconsole wrap after profile becomes active
function refreshMyConsoleWrap()
  -- Defer to next event loop iteration so geometry is correct
  tempTimer(0, function()
    local fontWidth = calcFontSize(myConsole)
    local consoleWidth = myConsole:get_width()
    
    -- Validate width before using
    if consoleWidth >= 50 then
      setWindowWrap(myConsole, math.floor(consoleWidth / fontWidth))
    end
  end)
end
Geyser's Geyser.MiniConsole handles this automatically as of Mudlet 4.21.

createScrollBox

createScrollBox([name of parent window], name, x, y, width, height)
creates a graphical elements able to hold other graphical elements such as labels, miniconsoles, command lines etc. in it.

If the added elements don't fit into the ScrollBox scrollbars appear and allow scrolling.

Returns true or false.
See also: createLabel(), hideWindow(), showWindow(), resizeWindow(), moveWindow(), setWindow()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • name of parent window:
(Optional) name of the parent window the scrollBox is created in. Defaults to the main window if not provided.
  • name:
The name of the scrollBox. Must be unique. Passed as a string.
  • x, y, width, height
Parameters to set set the window size and location
Example
-- create a ScrollBox with the name sBox
createScrollBox("SBox",0,0,300,200)

-- create 3 Labels and put them into the ScrollBox
createLabel("SBox","SBoxLabel",0,0,200,200,1)
createLabel("SBox","SBoxLabel2",200,0,200,200,1)
createLabel("SBox","SBoxLabel3",400,0,200,200,1)

-- put some text on the labels
echo("SBoxLabel","Label")
echo("SBoxLabel2","Label2")
echo("SBoxLabel3","Label3")

-- change the colours of the labels to make it easier to distinguish them
setBackgroundColor("SBoxLabel",255,0,0)
setBackgroundColor("SBoxLabel2",0,255,0)
setBackgroundColor("SBoxLabel3",0,0,255)

creplace

creplace([window, ]text)
Replaces the output line from the game with a colour-tagged string.

See Also: cecho(), cinsertText()

Parameters
  • window:
    The window to replace the selection in. Optional, defaults to the main window if not provided.
  • text:
    The text to display, with color names inside angle brackets as with cecho(). You can select any from this list: Color Table
Example
selectCaptureGroup(1)
creplace("<magenta>[ALERT!]: <reset>"..matches[2])

creplaceLine

creplaceLine ([window], text)
Replaces the output line from the game with a colour-tagged string.

See Also: cecho(), cinsertText()

Parameters
  • window (optional):
the window to copy the text from. Defaults to "main". Only supported in Mudlet 4.12+
  • text:
    The text to display, with color names inside angle brackets <>, ie <red>. If you'd like to use a background color, put it after a colon : - <:red>. You can use the <reset> tag to reset to the default color. You can select any from this list: Color Table
Example
creplaceLine("<magenta>[ALERT!]: <reset>"..line)

decho

decho ([name of console,] text)
Color changes can be made using the format <FR,FG,FB:BR,BG,BB,[BA]> 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,[BA]>. Arguments 2 and 3 set the default fore and background colors for the string using the same format as is used within the string, sans angle brackets, e.g. decho("<50,50,0:0,255,0>test").
You can also include the below tags.
Formatting
<b>  - bold
</b> - bold off
<i>  - italics
</i> - italics off
<u>  - underline
</u> - underline off
<o>  - overline
</o> - overline off
<s>  - strikethrough
</s> - strikethrough off
<r> - reset formatting

Note Note: Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you decho it will erase any previous echo sent to the label.

See also: cecho(), hecho(), copy2decho()
Parameters
  • name of console
(Optional) Name of the console to echo to. If no name is given, this will defaults to the main window.
  • text:
The text that you’d like to echo with embedded color tags. Tags take the RGB values only, see below for an explanation.


Note Note: Optional background transparancy parameter (BA) available in Mudlet 4.10+

Example
decho("<50,50,0:0,255,0>test")

decho("miniconsolename", "<50,50,0:0,255,0>test")

decho("\n<255,0,0>Red text with <i>italics</i>, <u>underline</u>, <s>strikethrough</s>, and <b>bold</b> formatting.")

decho("<\n<0,128,0><o><u>Green text with both over and underlines.</u></o>")

decho2ansi

ansiFormattedString = decho2ansi(text)
Converts decho formatted text to ansi formatted text. Used by dfeedTriggers, but useful if you want ansi formatted text for any other reason.
See also
decho(), dfeedTriggers()
Mudlet VersionAvailable in Mudlet4.10++

Note Note: non-color formatting added in Mudlet 4.15+

Parameters
  • text:
The decho formatted text for conversion
Returns
  • String converted to ansi formatting
Example
-- replicates the functionality of dfeedTriggers() for a single line.
-- you would most likely just use dfeedTriggers, but it makes for a tidy example.
feedTriggers(decho2ansi("\n<128,0,0>This is red.<r> <i>italic</i>, <b>bold</b>, <s>strikethrough</s>, <u>underline</u>\n"))

decho2cecho

convertedString = decho2cecho(str)
Converts a decho formatted string to a cecho formatted one.
See also
cecho2decho(), decho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from decho to cecho
Returns
  • a string formatted for cecho
Example
-- convert to a decho string and use cecho to display it
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
cecho(decho2cecho(dechoString))

decho2hecho

convertedString = decho2hecho(str)
Converts a decho formatted string to an hecho formatted one.
See also
hecho2decho(), decho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from decho to decho
Returns
  • a string formatted for hecho
Example
-- convert to an hecho string and use hecho to display it
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
hecho(decho2hecho(dechoString))

decho2html

convertedString = decho2html(str[, resetFormat])
Converts a decho formatted string to an html formatted one.
See also
cecho2decho(), decho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from decho to decho
  • resetFormat
optional table of default formatting options. As returned by getLabelFormat()
Returns
  • a string formatted for html
Example
-- create the base string
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"

-- create a label to display the result onto
testLabel = Geyser.Label:new({name = "testLabel"})

-- convert the decho string to an html one, using the default formatting of testLabel created above
local htmlString = decho2html(dechoString, testLabel:getFormat())

-- and finally echo it to the label to see
-- I use rawEcho as that displays the html exactly as given.
testLabel:rawEcho(htmlString)

dechoLink

dechoLink([windowName], text, command, hint, true)
Echos a piece of text as a clickable link, at the end of the current selected line - similar to decho(). This version allows you to use colours within your link text.
Parameters
  • windowName:
(optional) allows selection between sending the link to a miniconsole or the "main" window.
  • text:
text to display in the echo. Same as a normal decho().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
text for the tooltip to be displayed when the mouse is over the link.
  • true:
requires argument for the colouring to work.
Example
-- echo a link named 'press me!' that'll send the 'hi' command to the game
dechoLink("<50,50,0:0,255,0>press me!", function() send("hi") end, "This is a tooltip", true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
dechoLink("<50,50,0:0,255,0>press me!", [[send("hi")]], "This is a tooltip", true)

dechoPopup

dechoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like decho(). The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
(optional) name of the window to echo to. Use either main or omit for the main window, or the miniconsoles name otherwise.
  • text:
the text to display
  • {commands}:
a table of lua code strings to do or a functions (since Mudlet 4.11). ie, {[[send("hello")]], function() echo("hi!") end}
  • {hints}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {"send the hi command", "echo hi to yourself"}
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Example
-- Create some text as a clickable with a popup menu:
dechoPopup("<255,0,0>activities<r> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
dechoPopup("<255,0,0>activities<r> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)

dinsertLink

dinsertLink([windowName], text, command, hint, true)
Echos a piece of text as a clickable link, at the end of the current cursor position - similar to dinsertText(). This version allows you to use colours within your link text.
See also: insertLink(), hinsertLink()
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
optional parameter, allows selection between sending the link to a miniconsole or the main window.
  • text:
text to display in the echo. Same as a normal decho().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
text for the tooltip to be displayed when the mouse is over the link.
  • true:
requires argument for the colouring to work.
Example
-- echo a link named 'press me!' that'll send the 'hi' command to the game
dinsertLink("<255,0,0>press <165,42,42:255,255,255>me!", function() send("hi") end, "This is a tooltip", true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
dinsertLink("<255,0,0>press <165,42,42:255,255,255>me!", [[send("hi")]], "This is a tooltip", true)

dinsertPopup

dinsertPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current cursor position, like dinsertText(). The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
(optional) name of the window to echo to. Use either main or omit for the main window, or the miniconsoles name otherwise.
  • text:
the text to display
  • {commands}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}
  • {hints}:
a table of strings which will be shown on the popup and right-click menu. ie, {"send the hi command", "echo hi to yourself"}
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Example
-- Create some text as a clickable with a popup menu:
dinsertPopup("<255,0,0>activities<r> to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
dinsertPopup("<255,0,0>activities<r> to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)

deleteCommandLine

deleteCommandLine(commandLineName)
Deletes a command line with the given name. This performs complete cleanup, removing the command line from memory and all tracking structures.

Note Note: If you are using the Geyser layout manager, use myCommandLine:delete() instead. This will handle proper cleanup from Geyser's internal structures.

Note Note: While disabling a command line with disableCommandLine() keeps it in memory but hidden, deleting it completely removes it. Deleted command lines cannot be shown again - you would need to create a new one. It's more efficient to enable/disable command lines than to delete and recreate them if you'll need them again.

Note Note: The main command line ("main") cannot be deleted - attempting to do so will return false with an error message.

See also
createCommandLine(), enableCommandLine(), disableCommandLine()
Mudlet VersionAvailable in Mudlet4.20+
Parameters
  • commandLineName: The name of the command line to delete. Cannot be "main".
Returns
  • true on success
  • false and an error message if the command line doesn't exist or is "main"
Example
-- Create a custom command line
createCommandLine("myCommandLine", 10, 400, 300, 30)

-- Later, delete it completely
local success, err = deleteCommandLine("myCommandLine")
if not success then
  cecho(f"<red>Error: {err}\n")
end

-- This will fail - cannot delete main command line
local success, err = deleteCommandLine("main")
-- success = false, err = "the main command line cannot be deleted"

-- With Geyser:
local myCommandLine = Geyser.CommandLine:new({
  name = "myGeyserCommandLine",
  x = 100, y = 400,
  width = 300, height = 30,
})

-- Delete it (handles all cleanup automatically)
myCommandLine:delete()

deleteLabel

deleteLabel(labelName)
Deletes and removes a label from the screen. Note that if you'd like to show the label again, it is much more performant to hide/show it instead.
Note that you shouldn't use the Geyser label associated with the label you delete afterwards - that doesn't make sense and Geyser right now wouldn't know that it's been deleted, either.
See also: hideWindow(), showWindow(), createLabel()
Parameters
  • labelName: name of the label to delete.
createLabel("a very basic label",300,400,100,200,1)
setBackgroundColor("a very basic label", 255, 204, 0, 200)

-- delete the label after 3 seconds
tempTimer(3, function()
  deleteLabel("a very basic label")
end)
Mudlet VersionAvailable in Mudlet4.5+

deleteLine

deleteLine([windowName])
Deletes the current line under the user cursor. This is a high speed gagging tool and is very good at this task, but is only meant to be use when a line should be omitted entirely in the output. If you echo() to that line it will not be shown, and lines deleted with deleteLine() are simply no longer rendered. This is purely visual - triggers will still fire on the line as expected.
See also: replace(), wrapLine()
Parameters
  • windowName:
(optional) name of the window to delete the line in. If no name is given, it just deletes the line it is used on.

Note Note: for replacing text, replace() is the proper option; doing the following: selectCurrentLine(); replace(""); cecho("new line!\n") is better.

Example
-- deletes the line - just put this command into the big script box. Keep the case the same -
-- it has to be deleteLine(), not Deleteline(), deleteline() or anything else
deleteLine()

--This example creates a temporary line trigger to test if the next line is a prompt, and if so gags it entirely.
--This can be useful for keeping a pile of prompts from forming if you're gagging chat channels in the main window
--Note: isPrompt() only works on servers which send a GA signal with their prompt.
tempLineTrigger(1, 1, [[if isPrompt() then deleteLine() end]])

-- example of deleting multiple lines:
deleteLine()                            -- delete the current line
moveCursor(0,getLineNumber()-1)         -- move the cursor back one line
deleteLine()                            -- delete the previous line now

deleteMiniConsole

deleteMiniConsole(miniConsoleName)
Deletes a miniconsole with the given name. This performs complete cleanup, removing the miniconsole from memory and all tracking structures.

Note Note: If you are using the Geyser layout manager, use myMiniConsole:delete() instead. This will handle proper cleanup from Geyser's internal structures.

Note Note: While hiding a miniconsole with hideWindow() keeps it in memory for later use, deleting it completely removes it. Deleted miniconsoles cannot be shown again - you would need to create a new one. It's more efficient to hide/show miniconsoles than to delete and recreate them if you'll need them again.

Note Note: The "main" console cannot be deleted.

See also
createMiniConsole(), createConsole(), hideWindow(), showWindow()
Mudlet VersionAvailable in Mudlet4.20+
Parameters
  • miniConsoleName: The name of the miniconsole to delete.
Returns
  • true on success
  • false and an error message if the miniconsole doesn't exist
Example
-- Create a miniconsole
createMiniConsole("myConsole", 10, 10, 300, 200)
echo("myConsole", "Hello, World!")

-- Later, delete it completely
local success, err = deleteMiniConsole("myConsole")
if not success then
  cecho(f"<red>Error: {err}\n")
end

-- With Geyser:
local myConsole = Geyser.MiniConsole:new({
  name = "myGeyserConsole",
  x = 100, y = 100,
  width = 300, height = 200,
})

-- Delete it (handles all cleanup automatically)
myConsole:delete()

deleteMultiline

ok,err = deleteMultiline([triggerDelta])
Deletes all lines between when the multiline trigger fires and when the first trigger matched. Put another way, it deletes everything since the pattern in slot 1 matched.
See also
deleteLine(), replaceLine()
Mudlet VersionAvailable in Mudlet4.18+

Note Note: This deletes all the lines since the first match of the multiline trigger matched. Do not use this if you do not want to delete ALL of those lines.

Parameters
  • [optional]triggerDelta:
The line delta from the multiline trigger it is being called from. It is best to pass this in to ensure all lines are caught. If not given it will try to guess based on the number of patterns how many lines at most it might have to delete.
Returns
  • true if the function was able to run successfully, nil+error if something went wrong.
Example
-- if this trigger has a line delta of 3, you would call
deleteMultiline(3)

-- same thing, but with error handling
local ok,err = deleteMultiline(3)
if not ok then
  cecho("\n<firebrick>I could not delete the lines because: " .. err)
end
Additional development notes

deleteScrollBox

deleteScrollBox(scrollBoxName)
Deletes a scrollbox with the given name. This performs complete cleanup, removing the scrollbox and all its contents from memory and tracking structures.

Note Note: If you are using the Geyser layout manager, use myScrollBox:delete() instead. This will handle proper cleanup from Geyser's internal structures.

Note Note: While hiding a scrollbox with hideWindow() keeps it in memory for later use, deleting it completely removes it. Deleted scrollboxes cannot be shown again - you would need to create a new one. It's more efficient to hide/show scrollboxes than to delete and recreate them if you'll need them again.

See also
createScrollBox()
Mudlet VersionAvailable in Mudlet4.20+
Parameters
  • scrollBoxName: The name of the scrollbox to delete.
Returns
  • true on success
  • false and an error message if the scrollbox doesn't exist
Example
-- Create a scrollbox
createScrollBox("myScrollBox", 10, 10, 300, 400)

-- Later, delete it completely
local success, err = deleteScrollBox("myScrollBox")
if not success then
  cecho(f"<red>Error: {err}\n")
end

-- With Geyser:
local myScrollBox = Geyser.ScrollBox:new({
  name = "myGeyserScrollBox",
  x = 100, y = 100,
  width = 300, height = 400,
})

-- Delete it (handles all cleanup automatically)
myScrollBox:delete()

deselect

deselect([window name])
This is used to clear the current selection (to no longer have anything selected). Should be used after changing the formatting of text, to keep from accidentally changing the text again later with another formatting call.
See also: selectString(), selectCurrentLine()
Parameters
  • window name:
(optional) The name of the window to stop having anything selected in. If name is not provided the main window will have its selection cleared.
Example
--This will change the background on an entire line in the main window to red, and then properly clear the selection to keep further
--changes from effecting this line as well.
selectCurrentLine()
bg("red")
deselect()

disableClickthrough

disableClickthrough(label)
Disables clickthrough for a label - making it act 'normal' again and receive clicks, doubleclicks, onEnter, and onLeave events. This is the default behaviour for labels.
See also: enableClickthrough()
Parameters
  • label:
Name of the label to restore clickability on.
Mudlet VersionAvailable in Mudlet3.17+

disableCommandLine

disableCommandLine(windowName)
Disables the command line for the miniConsole named windowName
See Also: enableCommandLine()
Parameters
  • windowName:
The name of the miniConsole to disable the command line in.
Mudlet VersionAvailable in Mudlet4.10+

disableHorizontalScrollBar

disableHorizontalScrollBar([windowName])
Disables the horizontal scroll bar for the miniConsole/userwindow windowName or the main window
See Also: enableHorizontalScrollBar()
Parameters
  • windowName:
The name of the window to disable the scroll bar in. If "main" or not provided it is the main console.
Mudlet VersionAvailable in Mudlet4.10+

disableScrollBar

disableScrollBar([windowName])
Disables the scroll bar for the miniConsole/userwindow windowName or the main window
See Also: enableScrollBar()
Parameters
  • windowName:
(optional) The name of the window to disable the scroll bar in. If "main" or not provided it is the main console.

disableScrolling

disableScrolling([windowName])
Disables whether the split-screen bar is shown while scrolling in a miniconsole.
Parameters
  • windowName:
The name of the miniconsole window to disable the split-screen bar. "main" is not a valid option.

dreplace

dreplace([window, ]text)
Replaces the output line from the game with a colour-tagged string.

See Also: decho(), dinsertText()

Parameters
  • window:
    The window to replace the selection in. Optional, defaults to the main window if not provided.
  • text:
    The text to display, as with decho()
Example
    selectCaptureGroup(1)
    dreplace("<255,0,255>[ALERT!]: <r>"..matches[2])

dreplaceLine

dreplaceLine ([window], text)
Replaces the output line from the game with a colour-tagged string.
Mudlet VersionAvailable in Mudlet4.12+

See Also: decho(), dinsertText()

Parameters
  • window (optional):
the window to copy the text from. Defaults to "main".
  • text:
    The text to display, with RGB color values inside angle brackets <>, ie <128,0,0>. If you'd like to use a background color, put it after a colon : - <:128,0,0>. You can use the <r> tag to reset to the default color.
Example
dreplaceLine("<255,0,255>[ALERT!]: <r>"..line)

echoLink

echoLink([windowName], text, command, hint, [useCurrentFormatElseDefault])
Echos a piece of text as a clickable link, at the end of the current selected line - similar to echo().
See also: cechoLink(), hechoLink()
Parameters
  • windowName:
(optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
  • text:
Text to display in the echo. Same as a normal echo().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
Text for the tooltip to be displayed when the mouse is over the link.
  • useCurrentFormat:
If true, then the link will use the current selection style (colors, underline, etc). If missing or false, it will use the default link style - blue on black underlined text.
Example
-- echo a link named 'press me!' that'll send the 'hi' command to the game
echoLink("press me!", function() send("hi") end, "This is a tooltip")

-- want to capture a value, say from matches?
local thing = matches[2]
echolink(" Yes!", f[[echo("Captured {matches[2]}\n")]], f"Click on {thing}")

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
echoLink("press me!", [[send("hi")]], "This is a tooltip")

-- do the same, but send this link to a miniConsole
echoLink("my miniConsole", "press me!", function() send("hi") end, "This is a tooltip")

--

Note Note: The hint can contain the same sort of "rich-text" as can be used for "labels" - and if the command is set to be the empty string "" then this can be a means to show extra information for the text when the mouse is hovered over it but without a command being run should it be clicked upon, e.g.:

Screenshot showing example of fancy visual link

echoUserWindow

echoUserWindow(windowName, text)
This function will print text to both mini console windows, dock windows and labels. It is outdated however - echo() instead.

echoPopup

echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if there is one extra hint then the first one will be used as a (maybe containing Qt rich-text markup) tool-tip for the text otherwise the remaining hints will be concatenated, one-per-line, as a tool-tip when the text is hovered over by the pointer.
Parameters
  • windowName:
(optional) name of the window as a string to echo to. Use either main or omit for the main window, or the miniconsole's or user-window's name otherwise.
  • text:
the text string to display.
  • {commands}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}.
  • {hints}:
a table of strings which will be shown on the right-click menu and as a tool-tip for the text. If the number is the same as that of the commands table then they all will be used for the right-click menu and listed (one per line) as a plain text tooltip; alternatively if there is one extra in number than the commands table the first will be used purely for the tool tip and the remainder will be used for the right-click menu. This additional entry may be formatted as Qt style "rich-text" (in the same manner as labels elsewhere in the GUI).
  • If a particular position in the commands table is an empty string "" but there is something in the hints table then it will be listed in the right-click menu but as it does not do anything it will be shown greyed-out i.e. disabled and will not be clickable.
  • If a particular position in both the commands and the hints table are empty strings "" then this item will show as a separator (usually as a horizontal-line) in the right-click menu and it will not be clickable/do anything.
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if true or the link default (blue underline) if false, if omitted the default format is used.
Example
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})

-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})

-- one can also provide helpful information

-- todo: an example with rich-text in the tool-tips(s) - not complete yet!
echoPopup("Fancy popup", {[[echo("Doing command 1 (default one)")]], "", "", [[echo("Doing command 3")]], [[echo("Doing another command (number 4)"]], [[echo("Doing another command (number 5)"]]}, {"<p>This tooltip has HTML type tags in/around it, and it will get word-wrapped automatically to fit into a reasonable rectangle.</p><p><b>Plus</b> it can have those HTML like <i>effects</i> and be easily formatted into more than one paragraph and with <span style=\"color:cyan\">bits</span> in <span style=\"color:lime\">different</span> colors!</p><p>This example also demonstrates how to produce disabled menu (right-click) items, how to insert separators and how it now will handle multiple items with the same hint (prior to PR 6945 such duplicates will all run the command associated with the last one!) If the first command/function is an empty string then clicking on the text will have no effect, but hovering the mouse over the text will still produce the tooltip, this could be useful to display extra information about the text without doing anything by default.</p>", "Command 1 (default)", "", "Command 2 (disabled)", "Command 3", "Another command", "Another command"}, true)
echo(" remaining text.\n")

enableClickthrough

enableClickthrough(label)
Make a label 'invisible' to clicks - so if you have another label underneath, it'll be clicked on instead of this one on top.
This affects clicks, double-clicks, right-clicks, as well as the onEnter/onLeave events.
See also: disableClickthrough()
Parameters
  • label:
The name of the label to enable clickthrough on.
Mudlet VersionAvailable in Mudlet3.17+

enableCommandLine

enableCommandLine(windowName)
Enables the command line for the miniConsole named windowName
See Also: disableCommandLine()
Parameters
  • windowName:
The name of the miniConsole to enable the command line in.

Note Note: The command line name is the same as the miniConsole name

Mudlet VersionAvailable in Mudlet4.10+

enableHorizontalScrollBar

enableHorizontalScrollBar([windowName])
Enables the horizontal scroll bar for the miniConsole/userwindow windowName or the main window
See Also: disableHorizontalScrollBar()
Parameters
  • windowName:
The name of the window to enable the scroll bar in. If "main" or not provided it is the main console.
Mudlet VersionAvailable in Mudlet4.10+

enableScrollBar

enableScrollBar([windowName])
Enables the scroll bar for the miniConsole/userwindow windowName or the main window
See Also: disableScrollBar()
Parameters
  • windowName:
The name of the window to enable the scroll bar in. If "main" or not provided it is the main console.

enableScrolling

enableScrolling([windowName])
Enables whether the split-screen bar is shown while scrolling in a miniconsole.
Parameters
  • windowName:
The name of the miniconsole window to enable the split-screen bar. "main" is not a valid option.

fg

fg([window], colorName)
If used on a selection, sets the foreground color to colorName - otherwise, it will set the color of the next text-inserting calls (echo(), insertText, echoLink(), and others)
See Also: bg(), setBgColor()
Parameters
  • window:
(optional) name of the miniconsole to operate on. If you'd like it to work on the main window, don't specify anything or use main (since Mudlet 3.0).
  • colorName:
The name of the color to set the foreground to - list of possible names: Color Table
Example
--This would change the color of the text on the current line to green
selectCurrentLine()
fg("green")
resetFormat()

--This will echo red, green, blue in their respective colors
fg("red")
echo("red ")
fg("green")
echo("green ")
fg("blue")
echo("blue ")
resetFormat()

-- example of working on a miniconsole
fg("my console", "red")
echo("my console", "red text")

getAvailableFonts

getAvailableFonts()
This returns a "font - true" key-value list of available fonts which you can use to verify that Mudlet has access to a given font.
To install a new font with your package, include the font file in your zip/mpackage and it'll be automatically installed for you.
See also: getFont(), setFont()
Mudlet VersionAvailable in Mudlet3.10+
Example
-- check if Ubuntu Mono is a font we can use
if getAvailableFonts()["Ubuntu Mono"] then
  -- make the miniconsole use the font at size 16
  setFont("my miniconsole", "Ubuntu Mono")
  setFontSize("my miniconsole", 16)
end

getBackgroundColor

getBackgroundColor([windowName])
Gets the background for the given label, miniconsole, or userwindow.
Returns 4 values - red, green, blue, transparency. Colors returned are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
Parameters
  • windowName:
(optional) name of the label/miniconsole/userwindow to getthe background color from, or "main" for the main window.
Mudlet VersionAvailable in Mudlet4.15+
Example
local r, g, b, a = getBackgroundColor()
local rW, gW, bW, aW = getBackgroundColor("myWindow")

getBgColor

getBgColor(windowName)
This function returns the rgb values of the background color of the first character of the current selection on mini console (window) windowName. If windowName is omitted Mudlet will use the main screen.
See also: setBgColor()
Parameters
  • windowName:
A window to operate on - either a miniconsole or the main window.
Example
local r,g,b;
selectString("troll",1)
r,g,b = getBgColor()
if r == 255 and g == 0 and b == 0 then
    echo("HELP! troll is highlighted in red letters, the monster is aggressive!\n");
end

getBorderBottom

getBorderBottom()
Returns the size of the bottom border of the main window in pixels.
See also: getBorderSizes(), setBorderBottom()
Mudlet VersionAvailable in Mudlet4.0+
Example
setBorderBottom(150)
getBorderBottom()
-- returns: 150

getBorderLeft

getBorderLeft()
Returns the size of the left border of the main window in pixels.
See also: getBorderSizes(), setBorderLeft()
Mudlet VersionAvailable in Mudlet4.0+
Example
setBorderLeft(5)
getBorderLeft()
-- returns: 5

getBorderRight

getBorderRight()
Returns the size of the right border of the main window in pixels.
See also: getBorderSizes(), setBorderRight()
Mudlet VersionAvailable in Mudlet4.0+
Example
setBorderRight(50)
getBorderRight()
-- returns: 50

getBorderSizes

getBorderSizes()
Returns the a named table with the sizes of all borders of the main window in pixels.
See also: setBorderSizes(), getBorderTop(), getBorderRight(),getBorderBottom(), getBorderLeft()
Mudlet VersionAvailable in Mudlet4.0+
Example
setBorderSizes(100, 50, 150, 0)
getBorderSizes()
-- returns: { top = 100, right = 50, bottom = 150, left = 0 }
getBorderSizes().right
-- returns: 50

getBorderTop

getBorderTop()
Returns the size of the top border of the main window in pixels.
See also: getBorderSizes(), setBorderTop()
Mudlet VersionAvailable in Mudlet4.0+
Example
setBorderTop(100)
getBorderTop()
-- returns: 100

getClipboardText

getClipboardText()
Returns any text that is currently present in the clipboard.
See also: setClipboardText()
Note Note: Note: Available in Mudlet 4.10+
Example
local clipboardContents = getClipboardText()
echo("Clipboard: " .. clipboardContents)

getColorWildcard

getColorWildcard(ansi color number)
This function, given an ANSI color number (list), will return all strings on the current line that match it.
See also: isAnsiFgColor(), isAnsiBgColor()
Parameters
  • ansi color number:
A color number (list) to match.
Example
-- we can run this script on a line that has the players name coloured differently to easily capture it from
-- anywhere on the line
local match = getColorWildcard(14) -- this will be a table of every match

if match then -- if there's a table, then we try and print it on the screen!
  echo("\nFound "..table.concat(match, ", ").."!") -- this will combine all captured strings and separate them with a comma so it's easy to read.
else -- if there isn't something in match, then we haven't found anything to print on the screen!
  echo("\nDidn't find anyone.") 
end

getColumnCount

getColumnCount([windowName])
Gets the maximum number of columns (characters) that a given window can display on a single row, taking into consideration factors such as window width, font size, spacing, etc.
Parameters
  • windowName:
(optional) name of the window whose number of columns we want to calculate. By default it operates on the main window.
Mudlet VersionAvailable in Mudlet3.7+
Example
print("Maximum number of columns on the main window "..getColumnCount())

getColumnNumber

getColumnNumber([windowName])
Gets the absolute column number of the current user cursor.
Parameters
  • windowName:
(optional) either be none or "main" for the main console, or a miniconsole / userwindow name.

Note Note: the argument is available since Mudlet 3.0.

Example
HelloWorld = Geyser.MiniConsole:new({
  name="HelloWorld",
  x="70%", y="50%",
  width="30%", height="50%",
})

HelloWorld:echo("hello!\n")
HelloWorld:echo("hello!\n")
HelloWorld:echo("hello!\n")

moveCursor("HelloWorld", 3, getLastLineNumber("HelloWorld"))
-- should say 3, because we moved the cursor in the HellWorld window to the 3rd position in the line
print("getColumnNumber: "..tostring(getColumnNumber("HelloWorld")))

moveCursor("HelloWorld", 1, getLastLineNumber("HelloWorld"))
-- should say 3, because we moved the cursor in the HellWorld window to the 1st position in the line
print("getColumnNumber: "..tostring(getColumnNumber("HelloWorld")))

getCurrentLine

getCurrentLine([windowName])
Returns the content of the current line under the user cursor in the buffer. The Lua variable line holds the content of getCurrentLine() before any triggers have been run on this line. When triggers change the content of the buffer, the variable line will not be adjusted and thus hold an outdated string. line = getCurrentLine() will update line to the real content of the current buffer. This is important if you want to copy the current line after it has been changed by some triggers. selectString( line,1 ) will return false and won't select anything because line no longer equals getCurrentLine(). Consequently, selectString( getCurrentLine(), 1 ) is what you need.
Parameters
  • windowName:
(optional) name of the window in which to select text.
Example
print("Currently selected line: "..getCurrentLine())

getFgColor

getFgColor(windowName)
This function returns the rgb values of the color of the first character of the current selection on mini console (window) windowName. If windowName is omitted Mudlet will use the main screen.
Parameters
  • windowName:
A window to operate on - either a miniconsole or the main window.
Example
selectString("troll",1)
local r,g,b = getFgColor()
if r == 255 and g == 0 and b == 0 then
  echo("HELP! troll is written in red letters, the monster is aggressive!\n")
end

getFont

getFont([windowName])
Gets the current font of the given window or console name. Can be used to get font of the main console, dockable userwindows and miniconsoles.
See also: setFont(), setFontSize(), openUserWindow(), getAvailableFonts()
Mudlet VersionAvailable in Mudlet3.4+

Note Note: Since Mudlet 3.10, returns the actual font that was used in case you didn't have the required font when using setFont().

Parameters
  • windowName:
The window name to get font size of - can either be none or "main" for the main console, or a miniconsole/userwindow name.
Example
-- The following will get the "main" console font size.
display("Font in the main window: "..getFont())

display("Font in the main window: "..getFont("main"))

-- This will get the font size of a user window named "user window awesome".
display("Font size: " .. getFont("user window awesome"))

getFontSize

getFontSize([windowName])
Gets the current font size of the given window or console name. Can be used to get font size of the Main console as well as dockable UserWindows.
See also: setFontSize(), openUserWindow()
Parameters
  • windowName:
The window name to get font size of - can either be none or "main" for the main console, or a UserWindow name.
Mudlet VersionAvailable in Mudlet3.4+
Example
-- The following will get the "main" console font size.
local mainWindowFontSize = getFontSize()
if mainWindowFontSize then
    display("Font size: " .. mainWindowFontSize)
end

local mainWindowFontSize = getFontSize("main")
if mainWindowFontSize then
    display("Font size: " .. fs2)
end

-- This will get the font size of a user window named "user window awesome".
local awesomeWindowFontSize = getFontSize("user window awesome")
if awesomeWindowFontSize then
    display("Font size: " .. awesomeWindowFontSize)
end

getHTMLformat

spanTag = getHTMLformat(formatTable)
Takes in a table of formatting options in the same style as getTextFormat() and returns a span tag which will format text after it as the table describes.
See also
getTextFormat(), getLabelFormat()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • formatTable:
Table with formatting options configured. Keys are foreground, background, bold, underline, overline, strikeout, italic, and reverse. All except for foreground and background should be boolean (true/false) values. Foreground and background are either { r, g, b, a } tables, or strings with QSS formatting directives
Returns
  • A string with the html span tag to format text in accordance with the format table.
Example
-- Returns a span tag for bold, red text on a green background
local span = getHTMLformat({
  foreground = { 255, 0, 0 },
  background = "#00FF00",
  bold = true
})

-- span will be '<span style="color: rgb(255, 0, 0);background-color: #00FF00; font-weight: bold; font-style: normal; text-decoration: none;">'

getImageSize

getImageSize(imageLocation)
Returns the width and the height of the given image. If the image can't be found, loaded, or isn't a valid image file - nil+error message will be returned instead.
See also: createLabel()
Parameters
  • imageLocation:
Path to the image.
Mudlet VersionAvailable in Mudlet4.5+
Example
local path = getMudletHomeDir().."/my-image.png"

cecho("Showing dimensions of the picture in: "..path.."\n")

local width, height = getImageSize(path)

if not width then
  -- in case of an problem, we don't get a height back - but the error message
  cecho("error: "..height.."\n")
else
  cecho(string.format("They are: %sx%s", width, height))
end

getLabelFormat

formatTable = getLabelFormat(labelName)
Returns a format table like the one returned by getTextFormat and suitable for getHTMLformat which will format text the same way as simply doing an echo to the label would
See also
getTextFormat(), getHTMLformat()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • labelName:
The name of the label to scan the format of
Returns
  • A table with all the formatting options to achieve a default text format for label labelName.
Example
-- creates a test label, sets a stylesheet, and then returns the default format table for that label.
createLabel("testLabel", 10, 10, 300, 200, 1)
setLabelStyleSheet([[
  color: rgb(0,0,180);
  border-width: 1px;
  border-style: solid;
  border-color: gold;
  border-radius: 10px;
  font-size: 12.0pt;
  background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);
]])
local fmt = getLabelFormat("testLabel"))

--[[
{
  background = "rgba(0, 0, 0, 0)", -- this is transparent
  bold = false,
  foreground = "rgb(0,0,180)",
  italic = false,
  overline = false,
  reverse = false,
  strikeout = false,
  underline = false
}
--]]

getLabelSizeHint

width, height = getLabelSizeHint(labelName)
Returns the suggested labelsize as width and height
See also
getTextFormat(), getHTMLformat()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • labelName:
The name of the label to get the suggested size from
Returns
  • suggested width and height (to fit text and/or an image on a label)
Example
-- text resizing example
-- create the label
createLabel("textLabel",400,400,300,300,1)
-- put some text on it
echo("textLabel", "This is my Test.\nAnother Test")
-- resizes the label to fit the text
resizeWindow("textLabel", getLabelSizeHint("textLabel"))

-- image resizing example
-- create the label
createLabel("imageLabel",400,400,300,300,1)
-- put some image on it
setBackgroundImage("imageLabel", getMudletHomeDir.."/myLabelImage.png")
-- resizes the label to fit the image
resizeWindow("imageLabel", getLabelSizeHint("imageLabel"))

getLabelStyleSheet

getLabelStyleSheet(labelName)
Returns the stylesheet set on a given label, which is used to customise the labels look and feel.
See also
getTextFormat()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • labelName:
The name of the label to get the stylesheet from
Returns
  • stylesheet as a string
Example
createLabel("test", 50, 50, 100, 100, 0)
setLabelStyleSheet("test", [[
  background-color: white;
  border: 10px solid green;
  font-size: 12px;
  ]])
echo("test", "test")

-- now retrieve it and display:
local stylesheet = getLabelStyleSheet("test")
cecho(f"<green>the label's stylesheet is now: \n<white>{stylesheet}\n")

getLastLineNumber

getLastLineNumber([windowName])
Returns the latest line's number in the main window or the miniconsole. This could be different from getLineNumber() if the cursor was moved around.
Parameters
  • windowName:
Optional name of the window to use. Defaults to the main window.
Example
-- get the latest line's # in the buffer
local latestline = getLastLineNumber("main")

getLineCount

getLineCount([windowName])
Gets the absolute amount of lines in the current console buffer
Parameters
  • windowName
Optional name of the window to get the line count of. Defaults to the main window.
Example
echo("Main window has " .. getLineCount() .. " lines of text in it.")

getLines

getLines([windowName,] from_line_number, to_line_number)
Returns a section of the content of the screen text buffer. Returns a Lua table with the content of the lines on a per line basis. The form value is result = {relative_linenumber = line}.
Absolute line numbers are used.
Parameters
  • windowName
(optional) name of the miniconsole/userwindow to get lines for, or "main" for the main window (Mudlet 3.17+)
  • from_line_number:
First line number
  • to_line_number:
End line number
Example
-- retrieve & echo the last line:
echo(getLines(getLineNumber()-1, getLineNumber())[1])
-- find out which server and port you are connected to (as per Mudlet settings dialog):
local t = getLines(0, getLineNumber())

local server, port

for i = 1, #t do
  local s, p = t[i]:match("looking up the IP address of server:(.-):(%d+)")
  if s then server, port = s, p break end
end

display(server)
display(port)

getLineNumber

getLineNumber([windowName])
Returns the absolute line number of the current user cursor (the y position). The cursor by default is on the current line the triggers are processing - which you can move around with moveCursor() and moveCursorEnd(). This function can come in handy in combination when using with moveCursor() and getLines().
Parameters
  • windowName:
(optional) name of the miniconsole to operate on. If you'd like it to work on the main window, don't specify anything.

Note Note: The argument is available since Mudlet 3.0.

Example
-- use getLines() in conjuction with getLineNumber() to check if the previous line has a certain word
if getLines(getLineNumber()-1, getLineNumber())[1]:find("attacks") then echo("previous line had the word 'attacks' in it!\n") end

-- check how many lines you've got in your miniconsole after echoing some text.
-- Note the use of moveCursorEnd() to update getLineNumber()'s output
HelloWorld = Geyser.MiniConsole:new({
  name="HelloWorld",
  x="70%", y="50%",
  width="30%", height="50%",
})

print(getLineNumber("HelloWorld"))

HelloWorld:echo("hello!\n")
HelloWorld:echo("hello!\n")
HelloWorld:echo("hello!\n")

-- update the cursors position, as it seems to be necessary to do
moveCursorEnd("HelloWorld")
print(getLineNumber("HelloWorld"))

getMainConsoleWidth

getMainConsoleWidth()
Returns a single number; the width of the main console with respect to where the output lines wrap (not the total main console area; see getMainWindowSize() for that). i.e., The maximum size of a line length (game output) in pixels.
See also: getMainWindowSize()
Parameters
None
Example
-- Save width of the main console to a variable for future use.
consoleWidth = getMainConsoleWidth()

getMouseEvents

events = getMouseEvents()
Returns a table of registered mouse events, including any of the additional arguments they may have.
Mudlet VersionAvailable in Mudlet4.13+
See also
addMouseEvent(), removeMouseEvent()
Returns
  • Returns a table with mouse event uniqueName as indexes, containing all the creation arguments as the sub-table members.

getMousePosition

getMousePosition()
Returns the coordinates of the mouse's position, relative to the Mudlet window itself.
Parameters
None
Mudlet VersionAvailable in Mudlet3.1+
Example
-- Retrieve x and y position of the mouse to determine where to create a new label, then use that position to create a new label
local x, y = getMousePosition()
createLabel("clickGeneratedLabel", x, y, 100, 100, 1)
-- if the label already exists, just move it
moveWindow("clickGeneratedLabel", x, y)
-- and make it easier to notice
setBackgroundColor("clickGeneratedLabel", 255, 204, 0, 200)

getProfileTabNumber

getProfileTabNumber()
Returns the current tab number you're in. If you have just one profile loaded, it'll always return 1 - otherwise it'll be the nth tab that is currently open.
Parameters
None
Mudlet VersionAvailable in Mudlet4.11+
Example
print(f"Current playing in tab #{getProfileTabNumber()}.")

getMainWindowSize

getMainWindowSize()
Returns two numbers, the width and height in pixels of the main window.
See also: getUserWindowSize(), setMainWindowSize(), getMainConsoleWidth()
Parameters
None
Example
--this will get the size of your main mudlet window and save them
--into the variables mainHeight and mainWidth
mainWidth, mainHeight = getMainWindowSize()

getRowCount

getRowCount([windowName])
Gets the maximum number of rows that a given window can display at once, taking into consideration factors such as window height, font type, spacing, etc.
Parameters
  • windowName:
(optional) name of the window whose maximum number of rows we want to calculate. By default it operates on the main window.
Mudlet VersionAvailable in Mudlet3.7+
Example
print("Maximum of rows on the main window "..getRowCount())

getScroll

getScroll([windowName])
Returns line that the window is currently scrolled to.
See also: scrollTo, scrollUp, scrollDown
Parameters
  • windowName:
(optional) name of the window to ask about. Default is the main window.
Mudlet VersionAvailable in Mudlet4.17.0+
Example
-- button to jump to next instance of "Timbo"
local current = getScroll()
local data = getLines(current, getLineCount())
for count, line in ipairs(data) do
  local match = string.findPattern(line, "Timbo")
  if match then
    scrollTo(current + count)
    break
  end
end

getSelection

getSelection([windowName])
Returns the text currently selected with selectString(), selectSection(), or selectCurrentLine(). Note that this isn't the text currently selected with the mouse.
Also returns the start offset and length of the selection as second and third value.
Parameters
  • windowName:
(optional) name of the window to get the selection from. By default it operates on the main window.
Mudlet VersionAvailable in Mudlet3.16+
Example
selectCurrentLine()
print("Current line contains: "..getSelection())
retrieving the selection
text,offset,len = getSelection()
-- manipulate the selection, e.g. to discover the color of characters other than the first
-- then restore it
selectSection(offset, len)

getTextFormat

getTextFormat([windowName])
Gets the current text format of the currently selected text. May be used with other console windows. The returned values come in a table containing text attribute names and their values. The values given will be booleans for: bold, italics, underline, overline, strikeout, and reverse - followed by color triplet tables for the foreground and background colors.
See Also: setTextFormat()
Parameters
  • windowName
(optional) Specify name of selected window. If no name or "main" is given, the format will be gathered from the main console.
Mudlet VersionAvailable in Mudlet3.20+
Example
-- A suitable test for getTextFormat()
-- (copy it into an alias or a script)

clearWindow()

echo("\n")

local SGR = string.char(27)..'['
feedTriggers("Format attributes: '"..SGR.."1mBold"..SGR.."0m' '"..SGR.."3mItalic"..SGR.."0m' '"..SGR.."4mUnderline"..SGR.."0m' '"..SGR.."5mBlink"..SGR.."0m' '"..SGR.."6mF.Blink"..SGR.."0m' '"..SGR.."7mReverse"..SGR.."0m' '"..SGR.."9mStruckout"..SGR.."0m' '"..SGR.."53mOverline"..SGR.."0m'.\n")

moveCursor(1,1)
selectSection(1,1)

local results = getTextFormat()
echo("For first character in test line:\nBold detected: " .. tostring(results["bold"]))
echo("\nItalic detected: " .. tostring(results["italic"]))
echo("\nUnderline detected: " .. tostring(results["underline"]))
echo("\nReverse detected: " .. tostring(results["reverse"]))
echo("\nStrikeout detected: " .. tostring(results["strikeout"]))
echo("\nOverline detected: " .. tostring(results["overline"]))
echo("\nForeground color: (" .. results["foreground"][1] .. ", " .. results["foreground"][2] .. ", " .. results["foreground"][3] .. ")")
echo("\nBackground color: (" .. results["background"][1] .. ", " .. results["background"][2] .. ", " .. results["background"][3] .. ")")

selectSection(21,1)
echo("\n\nFor individual parts of test text:")
echo("\nBold detected (character 21): " .. tostring(results["bold"]))

selectSection(28,1)
echo("\nItalic detected (character 28): " .. tostring(results["italic"]))

selectSection(37,1)
echo("\nUnderline detected (character 37): " .. tostring(results["underline"]))

selectSection(67,1)
echo("\nReverse detected (character 67): " .. tostring(results["reverse"]))

selectSection(77,1)
echo("\nStrikeout detected (character 77): " .. tostring(results["strikeout"]))

selectSection(89,1)
echo("\nOverline detected (character 89): " .. tostring(results["overline"]))
echo("\n")

getUserWindowSize

getUserWindowSize(windowName)
Returns two numbers, the width and height in pixels. This is useful for calculating the given userwindow dimensions.
See also: getMainWindowSize()
Parameters
  • windowName
the name of the userwindow we will get the dimensions from
Mudlet VersionAvailable in Mudlet4.6.1+
Example
--this will get the size of your userwindow named "ChatWindow" and save them
--into the variables mainHeight and mainWidth
mainWidth, mainHeight = getUserWindowSize("ChatWindow")

getWindowWrap

getWindowWrap(windowName)
gets at what position in the line the will start word wrap.
Parameters
  • windowName:
Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main" or leave empty.
Example
setWindowWrap("main", 10)
display(getWindowWrap("main"))

-- The following output will result in the main window console:
-- 10
Practical Example
-- display ======== line with maximum possible width without wrapping
echo(string.rep("=", getWindowWrap("main")))
Mudlet VersionAvailable in Mudlet4.11+

handleWindowResizeEvent

handleWindowResizeEvent()
(deprecated) This function is deprecated and should not be used; it's only documented here for historical reference - use the sysWindowResizeEvent event instead.

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.

Parameters
None
Example
function handleWindowResizeEvent()
   -- determine the size of your screen
   WindowWidth=0;
   WindowHeight=0;
   WindowWidth, WindowHeight = getMainWindowSize();

   -- move mini console "sys" to the far right side of the screen whenever the screen gets resized
   moveWindow("sys",WindowWidth-300,0)
end

hasFocus

hasFocus()
Returns true or false depending if Mudlet's main window is currently in focus (ie, the user isn't focused on another window, like a browser). If multiple profiles are loaded, this can also be used to check if a given profile is in focus.
Parameters
None
Example
if attacked and not hasFocus() then
  runaway()
else
  fight()
end

hecho

hecho([windowName], text)
Echoes text that can be easily formatted with colour tags in the hexadecimal format. You can also add the below tags.
Formatting
#b or |b   - bold
#/b or |/b - bold off
#i or |i   - italics
#/i or |/i - italics off
#u or |u   - underline
#/u or |/u - underline off
#o or |o   - overline
#/o or |/o - overline off
#s or |s   - strikethrough
#/s or |/s - strikethrough off
#r or |r   - reset to default
See Also: decho(), cecho()

Note Note: Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you hecho it will erase any previous echo sent to the label.

Parameters
  • windowName:
(optional) name of the window to echo to. Can either be omitted or "main" for the main window, else specify the miniconsoles name.
  • text:
The text to display, with color changes made within the string using the format |cFRFGFB,BRBGBB or #FRFGFB,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 or #r can be used within the string to reset the colors to default. Hexadecimal color codes can be found here: https://www.color-hex.com/

Note Note: Transparency for background in hex-format available in Mudlet 4.10+

Example
hecho("\n#ffffff White text!")
-- your text in white
hecho("\n#ca0004 Red text! And now reset #rit to the default color")
-- your text in red, then reset to default using #r
hecho("\n#ffffff,ca0004 White text with a red background!")
-- your text in white, against a red background
hecho("\n|c0000ff Blue text, this time using |c instead of #")
-- your text in blue, activated with |c vs #.
hecho("\n#ff0000Red text with #iitalics#/i, |uunderline|/u, #ooverline#/o, #sstrikethrough#/s, and #bbold#/b formatting.")
-- shows the various individual formatting options
hecho("\n#008000#o#uGreen text with both over and underlines.#/o#/u")

hecho2ansi

ansiFormattedString = hecho2ansi(text)
Converts hecho formatted text to ansi formatted text. Used by hfeedTriggers, but useful if you want ansi formatted text for any other reason.
See also
hecho(), hfeedTriggers()
Mudlet VersionAvailable in Mudlet4.10++

Note Note: non-color formatting added in Mudlet 4.15+

Parameters
  • text:
The hecho formatted text for conversion
Returns
  • String converted to ansi formatting
Example
-- replicates the functionality of hfeedTriggers() for a single line.
-- you would most likely just use hfeedTriggers, but it makes for a tidy example.
feedTriggers(hecho2ansi("\n#800000This is red.#r #iitalic#/i, #bbold#/b, #sstrikethrough#/s, #uunderline#/u\n"))

hecho2cecho

convertedString = hecho2cecho(str)
Converts a hecho formatted string to a cecho formatted one.
See also
cecho2decho(), hecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from hecho to cecho
Returns
  • a string formatted for cecho
Example
-- convert to a hecho string and use cecho to display it
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
cecho(hecho2cecho(hechoString))

hecho2decho

convertedString = hecho2decho(str)
Converts a hecho formatted string to a decho formatted one.
See also
decho2hecho(), hecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from hecho to decho
Returns
  • a string formatted for decho
Example
-- convert to a decho string and use decho to display it
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
decho(hecho2decho(hechoString))

hecho2html

convertedString = hecho2html(str[, resetFormat])
Converts a hecho formatted string to an html formatted one.
See also
cecho2hecho(), hecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from hecho to hecho
  • resetFormat
optional table of default formatting options. As returned by getLabelFormat()
Returns
  • a string formatted for html
Example
-- create the base string
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""

-- create a label to display the result onto
testLabel = Geyser.Label:new({name = "testLabel"})

-- convert the hecho string to an html one, using the default formatting of testLabel created above
local htmlString = hecho2html(hechoString, testLabel:getFormat())

-- and finally echo it to the label to see
-- I use rawEcho as that displays the html exactly as given.
testLabel:rawEcho(htmlString)

hechoLink

hechoLink([windowName], text, command, hint, true)
Echos a piece of text as a clickable link, at the end of the current selected line - similar to hecho(). This version allows you to use colours within your link text.
See also: cechoLink(), dechoLink()
Parameters
  • windowName:
(optional) - allows selection between sending the link to a miniconsole or the main window.
  • text:
text to display in the echo. Same as a normal hecho().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
text for the tooltip to be displayed when the mouse is over the link.
  • true:
requires argument for the colouring to work.
Example
-- echo a link named 'press me!' that'll send the 'hi' command to the game
hechoLink("|ca00040black!", function() send("hi") end, "This is a tooltip", true)

-- # format also works
hechoLink("#ca00040black!", function() send("hi") end, "This is a tooltip", true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
hechoLink("#ca00040black!", [[send("hi")]], "This is a tooltip", true)

hechoPopup

hechoPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like hecho(). The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
(optional) name of the window to echo to. Use either main or omit for the main window, or the miniconsoles name otherwise.
  • text:
the text to display
  • {commands}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}
  • {hints}:
a table of strings which will be shown on the popup and right-click menu. ie, {"send the hi command", "echo hi to yourself"}
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Example
-- Create some text as a clickable with a popup menu:
hechoPopup("#ff0000activities#r to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
hechoPopup("#ff0000activities#r to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)

hideGauge

hideGauge(gaugeName)
hides the given gauge.
See also: showGauge(), createGauge()
Parameters
  • gaugeName:
name of the gauge to show.
Example
hideGauge("my gauge")
showGauge("my gauge")

hinsertLink

hinsertLink([windowName], text, command, hint, true)
Echos a piece of text as a clickable link, at the end of the current cursor position - similar to hinsertText(). This version allows you to use colours within your link text.
See also: insertLink(), dinsertLink()
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
optional parameter, allows selection between sending the link to a miniconsole or the main window.
  • text:
text to display in the echo. Same as a normal hecho().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
text for the tooltip to be displayed when the mouse is over the link.
  • true:
requires argument for the colouring to work.
Example
-- echo a link named 'press me!' that'll send the 'hi' command to the game
hinsertLink("#ff0000press #a52a2a,ffffffme!", function() send("hi") end, "This is a tooltip", true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
hinsertLink("#ff0000press #a52a2a,ffffffme!", [[send("hi")]], "This is a tooltip", true)

hinsertPopup

hinsertPopup([windowName], text, {commands}, {hints}, [useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current cursor position, like hinsertText(). The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Mudlet VersionAvailable in Mudlet4.1+
Parameters
  • windowName:
(optional) name of the window to echo to. Use either main or omit for the main window, or the miniconsoles name otherwise.
  • text:
the text to display
  • {commands}:
a table of lua code strings to do or a functions (since Mudlet 4.11). ie, {[[send("hello")]], function() echo("hi!") end}
  • {hints}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {"send the hi command", "echo hi to yourself"}
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Example
-- Create some text as a clickable with a popup menu:
hinsertPopup("#ff0000activities#r to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"}, true)

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
hinsertPopup("#ff0000activities#r to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"}, true)

hreplaceLine

hreplaceLine ([window], text)
Replaces the output line from the game with a colour-tagged string.
Mudlet VersionAvailable in Mudlet4.12+

See Also: hecho(), hinsertText()

Parameters
  • window (optional):
the window to copy the text from. Defaults to "main".
  • text:
    The text to display, with hex color values , ie #ff00ff. If you'd like to use a background color, put it after a comma , - #,ff99ff. You can use the #r tag to reset to the default color.
Example
hreplaceLine("#ff00ff[ALERT!]: #r"..line)

hreplace

hreplace([window, ]text)
Replaces the output line from the game with a colour-tagged string.

See Also: hecho(), hinsertText()

Parameters
  • window:
    The window to replace the selection in. Optional, defaults to the main window if not provided.
  • text:
    The text to display, as with hecho()
Example
    selectCaptureGroup(1)
    hreplace("#EE00EE[ALERT!]: #r"..matches[2])
Mudlet VersionAvailable in Mudlet4.5+

hideToolBar

hideToolBar(name)
Hides the toolbar with the given name name and makes it disappear. If all toolbars of a tool bar area (top, left, right) are hidden, the entire tool bar area disappears automatically.
Parameters
  • name:
name of the button group to hide
Example
hideToolBar("my offensive buttons")

hideWindow

hideWindow(name)
This function hides a mini console, a user window or a label with the given name. To show it again, use showWindow().
See also: createMiniConsole(), createLabel(), deleteLabel()
Parameters
  • name
specifies the label or console you want to hide.
Example
function miniconsoleTest()
  local windowWidth, windowHeight = getMainWindowSize()

  -- create the miniconsole
  createMiniConsole("sys", windowWidth-650,0,650,300)
  setBackgroundColor("sys",255,69,0,255)
  setMiniConsoleFontSize("sys", 8)
  -- wrap lines in window "sys" at 40 characters per line - somewhere halfway, as an example
  setWindowWrap("sys", 40)

  print("created red window top-right")

  tempTimer(1, function()
    hideWindow("sys")
    print("hid red window top-right")
  end)

  tempTimer(3, function()
    showWindow("sys")
    print("showed red window top-right")
  end)
end

miniconsoleTest()

insertLink

insertLink([windowName], text, command, hint, [useCurrentLinkFormat])
Inserts a piece of text as a clickable link at the current cursor position - similar to insertText().
See also: echoLink(), insertText(), cinsertLink(), dinsertLink(), hinsertLink()
Parameters
  • windowName:
(optional) the window to insert the link in - use either "main" or omit for the main window.
  • text:
text to display in the window. Same as a normal echo().
  • command:
Lua code to do when the link is clicked, as text or a function (since Mudlet 4.11).
  • hint:
text for the tooltip to be displayed when the mouse is over the link.
  • useCurrentLinkFormat:
(optional) true or false. If true, then the link will use the current selection style (colors, underline, etc). If missing or false, it will use the default link style - blue on black underlined text.
Example
-- link with the default blue on white colors
insertLink("hey, click me!", function() echo("you clicked me!\n") end, "Click me popup")

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
insertLink("hey, click me!", [[echo("you clicked me!\n")]], "Click me popup")

-- use current cursor colors by adding true at the end
fg("red")
insertLink("hey, click me!", function() echo("you clicked me!\n") end, "Click me popup", true)
resetFormat()

Note Note: The hint can contain the same sort of "rich-text" as can be used for "labels" - and if the command is set to be the empty string "" then this can be a means to show extra information for the text when the mouse is hovered over it but without a command being run should it be clicked upon, e.g.:

Screenshot showing example of fancy visual link

insertPopup

insertPopup([windowName,] text, {commands}, {hints}[, useCurrentLinkFormat])
Creates text with a left-clickable link, and a right-click menu for more options exactly where the cursor position is, similar to insertText(). The inserted text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Parameters
  • windowName:
(optional) name of the window to echo to - use either main or omit for the main window, or the miniconsoles name otherwise.
  • text:
the text inserted for the popup to be applied to.
  • {commands}:
a table of lua code commands to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}.
  • {hints}:
a table of strings which will be shown when the pointer hovers over the popup's text and on the right-click menu. ie, {"send the hi command", "echo hi to yourself"}.
  • useCurrentLinkFormat:
(optional) boolean value for using either the current formatting options (colour, underline, italic) or the link default (blue underline).
Example
-- Create some text as a clickable with a popup menu:
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})

insertText

insertText([windowName], text)
Inserts text at cursor postion in window - unlike echo(), which inserts the text at the end of the last line in the buffer (typically the one being processed by the triggers). You can use moveCursor() to move the cursor into position first.
insertHTML() also does the same thing as insertText, if you ever come across it.
See also: cinsertText()
Parameters
  • windowName:
(optional) The window to insert the text to.
  • text:
The text you will insert into the current cursor position.
Example
-- move the cursor to the end of the previous line and insert some text

-- move to the previous line
moveCursor(0, getLineNumber()-1)
-- move the end the of the previous line
moveCursor(#getCurrentLine(), getLineNumber())

fg("dark_slate_gray")
insertText(' <- that looks nice.')

deselect()
resetFormat()
moveCursorEnd()

ioprint

ioprint(text, some more text, ...)
Prints text to the to the stdout. This is only available if you launched Mudlet from cmd.exe on Windows, from the terminal on Mac, or from the terminal on a Linux OS (launch the terminal program, type mudlet and press enter).

Similar to echo(), but does not require a "\n" at the end for a newline and can print several items given to it. It cannot print whole tables. This function works similarly to the print() you will see in guides for Lua.

This function is useful in working out potential crashing problems with Mudlet due to your scripts - as you will still see whatever it printed when Mudlet crashes.

Parameters
  • text:
The information you want to display.
Example
ioprint("hi!")
ioprint(1,2,3)
ioprint(myvariable, someothervariable, yetanothervariable)

isAnsiBgColor

isAnsiBgColor(bgColorCode)
This function tests if the first character of the current selection in the main console has the background color specified by bgColorCode.
Parameters
  • bgColorCode:
A color code to test for, possible codes are:
0 = default text color
1 = light black
2 = dark black
3 = light red
4 = dark red
5 = light green
6 = dark green
7 = light yellow
8 = dark yellow
9 = light blue
10 = dark blue
11 = light magenta
12 = dark magenta
13 = light cyan
14 = dark cyan
15 = light white
16 = dark white
Example
selectString( matches[1], 1 )
if isAnsiBgColor( 5 ) then
    bg( "red" );
    resetFormat();
    echo( "yes, the background of the text is light green" )
else
    echo( "no sorry, some other background color" )
end

Note Note: The variable named matches[1] holds the matched trigger pattern - even in substring, exact match, begin of line substring trigger patterns or even color triggers that do not know about the concept of capture groups. Consequently, you can always test if the text that has fired the trigger has a certain color and react accordingly. This function is faster than using getBgColor() and then handling the color comparison in Lua.

Also note that the color code numbers are Mudlet specific, though they do represent the colors in the 16 ANSI color-set for the main console they are not in the same order and they additionally have the default background color in the zeroth position.

isAnsiFgColor

isAnsiFgColor(fgColorCode)
This function tests if the first character of the current selection in the main console has the foreground color specified by fgColorCode.
Parameters
  • fgColorCode:
A color code to test for, possible codes are:
0 = default text color
1 = light black
2 = dark black
3 = light red
4 = dark red
5 = light green
6 = dark green
7 = light yellow
8 = dark yellow
9 = light blue
10 = dark blue
11 = light magenta
12 = dark magenta
13 = light cyan
14 = dark cyan
15 = light white
16 = dark white
Example
selectString( matches[1], 1 )
if isAnsiFgColor( 5 ) then
    bg( "red" );
    resetFormat();
    echo( "yes, the text is light green" )
else
    echo( "no sorry, some other foreground color" )
end

Note Note: The variable named matches[1] holds the matched trigger pattern - even in substring, exact match, begin of line substring trigger patterns or even color triggers that do not know about the concept of capture groups. Consequently, you can always test if the text that has fired the trigger has a certain color and react accordingly. This function is faster than using getFgColor() and then handling the color comparison in Lua.

Also note that the color code numbers are Mudlet specific, though they do represent the colors in the 16 ANSI color-set for the main console they are not in the same order and they additionally have the default foreground color in the zeroth position.

loadWindowLayout

loadWindowLayout()
Resets the layout of userwindows (floating miniconsoles) to the last saved state.
See also: saveWindowLayout(), openUserWindow()
Mudlet VersionAvailable in Mudlet3.2+
Example
loadWindowLayout()

lowerWindow

lowerWindow(labelName)
Moves the referenced label/console below all other labels/consoles. For the opposite effect, see: raiseWindow().
Parameters
  • labelName:
the name of the label/console you wish to move below the rest.
Mudlet VersionAvailable in Mudlet3.1+
Example
createLabel("blueLabel", 300, 300, 100, 100, 1)   --creates a blue label
setBackgroundColor("blueLabel", 50, 50, 250, 255)

createLabel("redLabel", 350, 350, 100, 100, 1)    --creates a red label which is placed on TOP of the blue label, as the last made label will sit at the top of the rest
setBackgroundColor("redLabel", 250, 50, 50, 255)

lowerWindow("redLabel")                          --lowers redLabel, causing blueLabel to be back on top

moveCursor

moveCursor([windowName], x, y)
Moves the user cursor of the window windowName, or the main window, to the absolute point (x,y). This function returns false if such a move is impossible e.g. the coordinates don’t exist. To determine the correct coordinates use getLineNumber(), getColumnNumber() and getLastLineNumber(). The trigger engine will always place the user cursor at the beginning of the current line before the script is run. If you omit the windowName argument, the main screen will be used.
Returns true or false depending on if the cursor was moved to a valid position. Check this before doing further cursor operations - because things like deleteLine() might invalidate this.
Parameters
  • windowName:
(optional) The window you are going to move the cursor in.
  • x:
The horizontal axis in the window - that is, the letter position within the line.
  • y:
The vertical axis in the window - that is, the line number.
Example
-- move cursor to the start of the previous line and insert -<(
-- the first 0 means we want the cursor right at the start of the line,
-- and getLineNumber()-1 means we want the cursor on the current line# - 1 which
-- equals to the previous line
moveCursor(0, getLineNumber()-1)
insertText("-<(")

-- now we move the cursor at the end of the previous line. Because the
-- cursor is on the previous line already, we can use #getCurrentLine()
-- to see how long it is. We also just do getLineNumber() because getLineNumber()
-- returns the current line # the cursor is on
moveCursor(#getCurrentLine(), getLineNumber())
insertText(")>-")

-- finally, reset it to the end where it was after our shenaningans - other scripts
-- could expect the cursor to be at the end
moveCursorEnd()
-- a more complicated example showing how to work with Mudlet functions

-- set up the small system message window in the top right corner
-- determine the size of your screen
local WindowWidth, WindowHeight = getMainWindowSize()

-- define a mini console named "sys" and set its background color
createMiniConsole("sys",WindowWidth-650,0,650,300)
setBackgroundColor("sys",85,55,0,255)

-- you *must* set the font size, otherwise mini windows will not work properly
setMiniConsoleFontSize("sys", 12)
-- wrap lines in window "sys" at 65 characters per line
setWindowWrap("sys", 60)
-- set default font colors and font style for window "sys"
setTextFormat("sys",0,35,255,50,50,50,0,0,0)
-- clear the window
clearUserWindow("sys")

moveCursorEnd("sys")
setFgColor("sys", 10,10,0)
setBgColor("sys", 0,0,255)
echo("sys", "test1---line1\n<this line is to be deleted>\n<this line is to be deleted also>\n")
echo("sys", "test1---line2\n")
echo("sys", "test1---line3\n")
setTextFormat("sys",158,0,255,255,0,255,0,0,0);
--setFgColor("sys",255,0,0);
echo("sys", "test1---line4\n")
echo("sys", "test1---line5\n")
moveCursor("sys", 1,1)

-- deleting lines 2+3
deleteLine("sys")
deleteLine("sys")

-- inserting a line at pos 5,2
moveCursor("sys", 5,2)
setFgColor("sys", 100,100,0)
setBgColor("sys", 255,100,0)
insertText("sys","############## line inserted at pos 5/2 ##############")

-- inserting a line at pos 0,0
moveCursor("sys", 0,0)
selectCurrentLine("sys")
setFgColor("sys", 255,155,255)
setBold( "sys", true );
setUnderline( "sys", true )
setItalics( "sys", true )
insertText("sys", "------- line inserted at: 0/0 -----\n")

setBold( "sys", true )
setUnderline( "sys", false )
setItalics( "sys", false )
setFgColor("sys", 255,100,0)
setBgColor("sys", 155,155,0)
echo("sys", "*** This is the end. ***\n")

moveCursorDown

moveCursorDown([windowName,] [lines,] [keepHorizontal])
Moves the cursor in the given window down a specified number of lines.
See also: moveCursor(), moveCursorUp(), moveCursorEnd()
Parameters
  • windowName:
(optional) name of the miniconsole/userwindow, or "main" for the main window.
  • lines:
(optional) number of lines to move cursor down by, or 1 by default.
  • keepHorizontal:
(optional) true/false to specify if horizontal position should be retained, or reset to the start of the line otherwise.
Mudlet VersionAvailable in Mudlet3.17+
Example

Need example

moveCursorUp

moveCursorUp([windowName,] [lines,] [keepHorizontal])
Moves the cursor in the given window up a specified number of lines.
See also: moveCursor(), moveCursorDown(), moveCursorEnd()
Parameters
  • windowName:
(optional) name of the miniconsole/userwindow, or "main" for the main window.
  • lines:
(optional) number of lines to move cursor up by, or 1 by default.
  • keepHorizontal:
(optional) true/false to specify if horizontal position should be retained, or reset to the start of the line otherwise.
Mudlet VersionAvailable in Mudlet3.17+
Example

Need example

moveCursorEnd

moveCursorEnd([windowName])
Moves the cursor to the end of the buffer. "main" is the name of the main window, otherwise use the name of your user window.
See Also: moveCursor()
Returns true or false
Parameters
  • windowName:
(optional) name of the miniconsole/userwindow, or "main" for the main window.
Example

Need example

moveGauge

moveGauge(gaugeName, newX, newY)
Moves a gauge created with createGauge to the new x,y coordinates. Remember the coordinates are relative to the top-left corner of the output window.
Parameters
  • gaugeName:
The name of your gauge
  • newX:
The horizontal pixel location
  • newY:
The vertical pixel location
Example
-- This would move the health bar gauge to the location 1200, 400
moveGauge("healthBar", 1200, 400)

moveWindow

moveWindow(name, x, y)
This function moves window name to the given x/y coordinate. The main screen cannot be moved. Instead you’ll have to set appropriate border values → preferences to move the main screen e.g. to make room for chat or information mini consoles, or other GUI elements. In the future moveWindow() will set the border values automatically if the name parameter is omitted.
See Also: createMiniConsole(), createLabel(), handleWindowResizeEvent(), resizeWindow(), setBorderSizes(), openUserWindow()
Parameters
  • name:
The name of your window
  • newX:
The horizontal pixel location
  • newY:
The vertical pixel location

Note Note: Since Mudlet 3.7 this method can also be used on UserWindow consoles.

openUserWindow

openUserWindow(windowName, [restoreLayout], [autoDock], [dockingArea])
Opens a user dockable console window for user output e.g. statistics, chat etc. If a window of such a name already exists, nothing happens. You can move these windows (even to a different screen on a system with a multi-screen display), dock them on any of the four sides of the main application window, make them into notebook tabs or float them.
See also: resetUserWindowTitle(), setUserWindowTitle(), saveWindowLayout(), loadWindowLayout()
Parameters
  • windowName:
name of your window, it must be unique across ALL profiles if more than one is open (for multi-playing).
  • restoreLayout: (available in Mudlet 3.2+)
(optional) - only relevant, if false is provided. Then the window won't be restored to its last known position.
  • autoDock: (available in Mudlet 4.7+)
(optional) - only relevant, if false is provided. Then the window won't dock automatically at the corners.
  • dockingArea: (available in Mudlet 4.7+)
(optional) - the area your UserWindow will be docked at. possible docking areas your UserWindow will be created in (f" floating "t" top "b" bottom "r" right and "l" left). Docking area is "right" if not given any value.

Note Note: Since Mudlet version 3.2, Mudlet will automatically remember the window's last position.

Examples
openUserWindow("My floating window")
cecho("My floating window", "<red>hello <blue>bob!")

-- if you don't want Mudlet to remember its last position:
openUserWindow("My floating window", false)

paste

paste(windowName)
Pastes the previously copied text including all format codes like color, font etc. at the current user cursor position. The copy() and paste() functions can be used to copy formated text from the main window to a user window without losing colors e. g. for chat windows, map windows etc.
Parameters
  • windowName:
The name of your window

pauseMovie

pauseMovie(label name)
Pauses the gif animation on the label
Returns true
See also: setMovie(), startMovie(), setMovieFrame(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--stops the animation
pauseMovie("myMovie")

prefix

prefix(text, [writingFunction], [foregroundColor], [backgroundColor], [windowName])
Prefixes text at the beginning of the current line when used in a trigger.
Parameters
  • text:
the information you want to prefix
  • "writingFunction:"
optional parameter, allows the selection of different functions to be used to write the text, valid options are: echo, cecho, decho, and hecho.
  • "foregroundColor:"
optional parameter, allows a foreground color to be specified if using the echo function using a color name, as with the fg() function
  • "backgroundColor:"
optional parameter, allows a background color to be specified if using the echo function using a color name, as with the bg() function
  • "windowName:"
optional parameter, allows the selection a miniconsole or the main window for the line that will be prefixed
Example
-- Prefix the hours, minutes and seconds onto our prompt even though Mudlet has a button for that
prefix(os.date("%H:%M:%S "))
-- Prefix the time in red into a miniconsole named "my_console"
prefix(os.date("<red>%H:%M:%S<reset>"), cecho, nil, nil, "my_console")
See also: suffix()

print

print(text, some more text, ...)
Prints text to the main window. Similar to echo(), but does not require a "\n" at the end for a newline and can print several items given to it. It cannot print whole tables - use display() for those. This function works similarly to the print() you will see in guides for Lua.
Parameters
  • text:
The information you want to display.
Example
print("hi!")
print(1,2,3)
print(myvariable, someothervariable, yetanothervariable)

raiseWindow

raiseWindow(labelName)
Raises the referenced label/console above all over labels/consoles. For the opposite effect, see: lowerWindow().
Parameters
  • labelName:
the name of the label/console you wish to bring to the top of the rest.
Mudlet VersionAvailable in Mudlet3.1+
Example
createLabel("blueLabel", 300, 300, 100, 100, 1)   --creates a blue label
setBackgroundColor("blueLabel", 50, 50, 250, 255)

createLabel("redLabel", 350, 350, 100, 100, 1)    --creates a red label which is placed on TOP of the bluewindow, as the last made label will sit at the top of the rest
setBackgroundColor("redLabel", 250, 50, 50, 255)

raiseWindow("blueLabel")                          --raises blueLabel back at the top, above redLabel

removeCommandLineMenuEvent

removeCommandLineMenuEvent([window,] label)
Removes an existing command line menu event.
Parameters
  • window:
Window that item is associated with. Optional, defaults to "main" (main window console).
  • label:
Label under which element is registered
Returns
  • Returns True If the mouse event was removed successfully.

removeMouseEvent

removeMouseEvent(uniqueName)
Removes an existing mouse event. Returns True If the event exists and was removed successfully, throws a warning if the event doesn't exist.
Mudlet VersionAvailable in Mudlet4.13+
See also
getMouseEvents(), addMouseEvent()
Parameters
  • uniqueName:
A unique identifier that the mouse event was registered under.
Returns
  • Returns True If the mouse event was removed successfully.

replace

replace([windowName], with, [keepcolor])
Replaces the currently selected text with the new text. To select text, use selectString(), selectSection() or a similar function.

Note Note: If you’d like to delete/gag the whole line, use deleteLine() instead.

Note Note: when used outside of a trigger context (for example, in a timer instead of a trigger), replace() won't trigger the screen to refresh. Instead, use replace("") and insertText("new text") as insertText() does.

See also: creplace

Parameters
  • windowName:
(optional) name of window (a miniconsole)
  • with:
the new text to display.
  • keepcolor:
(optional) argument, setting this to true will keep the existing colors (since Mudlet 3.0+)
Example
-- replace word "troll" with "cute trolly"
selectString("troll",1)
replace("cute trolly")

-- replace the whole line
selectCurrentLine()
replace("Out with the old, in with the new!")

replaceAll

replaceAll(what, with, [keepcolor])
Replaces all occurrences of what in the current line with with.
Parameters
  • what:
the text to replace

Note Note: This accepts Lua patterns

  • with:
the new text to have in place
  • keepcolor:
setting this to true will keep the existing colors.

Note Note: keepcolor is available in Mudlet 4.10+

Examples
-- replace all occurrences of the word "south" in the line with "north"
replaceAll("south", "north")
-- replace all occurrences of the text that the variable "target" has
replaceAll(target, "The Bad Guy")

replaceLine

replaceLine ([window], text)
Replaces the output line from the game with your own text.

See Also: echo(), insertText()

Parameters
  • window (optional):
the window to copy the text from. Defaults to "main".
  • text:
    The text to display
Example
replaceLine("[ALERT!]: "..line)

replaceWildcard

replaceWildcard(which, replacement, [keepcolor])
Replaces the given wildcard (as a number) with the given text. Equivalent to doing:
selectString(matches[2], 1)
replace("text")
Parameters
  • which:
Wildcard to replace.
  • replacement:
Text to replace the wildcard with.
  • keepcolor:
setting this to true will keep the existing colors

Note Note: keepcolor available in Mudlet 4.10+

Example
replaceWildcard(2, "hello") -- on a perl regex trigger of ^You wave (goodbye)\.$, it will make it seem like you waved hello

resetCmdLineAction

resetCmdLineAction(commandLineName)
Resets the action on the command line so the it behaves like the main command line again.
Parameters
  • commandLineName
The name of the command line the action will be resetet.
See also: setCmdLineAction()
Mudlet VersionAvailable in Mudlet4.10+

resetBackgroundImage

resetBackgroundImage([windowName])
Resets the console background-image
Parameters
  • windowName
(optional) name of the console the image will be reset
See also: setBackgroundImage()
Mudlet VersionAvailable in Mudlet4.10+

resetFormat

resetFormat([windowName])
Resets the colour/bold/italics formatting. Always use this function when done adjusting formatting, so make sure what you've set doesn't 'bleed' onto other triggers/aliases.
Parameters
  • windowName
(optional) name of the console to reset formatting. Defaults to "main" if missing.
Example
-- select and set the 'Tommy' to red in the line
if selectString("Tommy", 1) ~= -1 then fg("red") end

-- now reset the formatting, so our echo isn't red
resetFormat()
echo(" Hi Tommy!")

-- another example: just highlighting some words
for _, word in ipairs{"he", "she", "her", "their"} do
  if selectString(word, 1) ~= -1 then
    bg("blue")
  end
end
resetFormat()

resetLabelCursor

resetLabelCursor(labelName)
Resets your mouse cursor to the default one.
See also: setLabelCursor(), setLabelCustomCursor()
Mudlet VersionAvailable in Mudlet4.8+
Parameters
  • labelName: label for which to reset the cursor for.
Example
resetLabelCursor("myLabel")
-- This will reset the mouse cursor over myLabel to the default one

resetLabelToolTip

resetLabelToolTip(labelName)
Resets the tooltip on the given label.
Mudlet VersionAvailable in Mudlet4.6.1+
Parameters
  • labelName:
The name of the label the tooltip will be reseted.
See also: setLabelToolTip()

resetMapWindowTitle

resetMapWindowTitle()
resets the title of the popped out map window to default.
Mudlet VersionAvailable in Mudlet4.8+
See also: setMapWindowTitle()

resetUserWindowTitle

resetUserWindowTitle(windowName)
resets the title of the UserWindow windowName
Parameters
  • windowName:
Name of the userwindow for which the title will be resetet
Mudlet VersionAvailable in Mudlet4.8+
See also: setUserWindowTitle(), openUserWindow()

resizeWindow

resizeWindow(windowName, width, height)
Resizes a mini console, label, or floating User Windows.
See also: createMiniConsole(), createLabel(), handleWindowResizeEvent(), resizeWindow(), setBorderSizes(), openUserWindow()
Parameters
  • windowName:
The name of your window
  • width:
The new width you want
  • height:
The new height you want

Note Note: Since Mudlet 3.7 this method can also be used on User Window consoles if they are floating.

saveWindowLayout

saveWindowLayout()
Saves the layout of userwindows (floating miniconsoles), in case you'd like to load them again later.
See also: loadWindowLayout(), openUserWindow()
Mudlet VersionAvailable in Mudlet3.2+
Example
saveWindowLayout()

scaleMovie

scaleMovie(label name, [autoscale])
Resizes the gif to fill the full size of its label
See also: setMovie(), startMovie()
Parameters
  • label name:
name of the label the gif will be scaled upon
  • autoscale:
(optional) if false the gif will only be scaled once, resizing the label won't rescale the image
Mudlet VersionAvailable in Mudlet4.15+

selectCaptureGroup

selectCaptureGroup(groupNumber)
Selects the content of the capture group number in your Perl regular expression (from matches[]). Also works with named capture group. It does not work with multimatches.
See also: selectCurrentLine()
Parameters
  • groupNumberOrName:
number of the capture group you want to select, or the name of the capture group as a string
Example
--First, set a Perl Reqular expression e.g. "you have (\d+) Euro".
--If you want to color the amount of money you have green you do:

selectCaptureGroup(2)
setFgColor(0,255,0)

-- Or perhaps instead if you were to use "you have (?<euro>\d+) Euro"
selectCaptureGroup("euro")
fg("green")

selectCmdLineText

selectCmdLineText([commandLine])
Selects the text in your command line. You can specify which one, if you got many.
See also: createCommandLine()
Mudlet VersionAvailable in Mudlet4.13+
Parameters
  • commandLine:
(optional) name of the command line you want to have selected
Example
-- First, create an extra commandline with the following lua script:
inputContainer = inputContainer or Adjustable.Container:new({
  x = 0, y = "-4c",
  name = "InputContainer", padding = 2,
  width = "100%", height = "4c",
  autoLoad = false
})
extraCmdLine = extraCmdLine or Geyser.CommandLine:new({
  name = "extraCmdLine",
  x = 0, y = 0, width = "100%", height = "100%"
}, inputContainer)
inputContainer:attachToBorder("bottom")

-- Now you can send the following lua code with your main command line.
-- It will give 2 seconds time to click around, unselect its text, etc. before selecting its text for you:
lua tempTimer(2, function() selectCmdLineText() end)

-- This will instead select the text in the command line named extraCmdLine:
lua selectCmdLineText('extraCmdLine')

-- Same as before, but using the Geyser.CommandLine function instead:
lua extraCmdLine:selectText()

selectCurrentLine

selectCurrentLine([windowName])
Selects the content of the current line that the cursor at. By default, the cursor is at the start of the current line that the triggers are processing, but you can move it with the moveCursor() function.

Note Note: This selects the whole line, including the linebreak - so it has a subtle difference from the slightly slower selectString(line, 1) selection method.

See also: selectString(), moveCursor(), getSelection(), getCurrentLine(), deselect()
Parameters
  • windowName:
(optional) name of the window in which to select text.
Example
-- color the whole line green!
selectCurrentLine()
fg("green")
deselect()
resetFormat()

-- to select the previous line, you can do this:
moveCursor(0, getLineNumber()-1)
selectCurrentLine()

-- to select two lines back, this:
moveCursor(0, getLineNumber()-2)
selectCurrentLine()

selectSection

selectSection( [windowName], fromPosition, length )
Selects the specified parts of the line starting from the left and extending to the right for however how long. The line starts from 0.
Returns true if the selection was successful, and false if the line wasn't actually long enough or the selection couldn't be done in general.
See also: selectString(), selectCurrentLine(), getSelection()
Parameters
  • "windowName:"
(optional) name of the window in which to select text. By default the main window, if no windowName is given.
Will not work if "main" is given as the windowName to try to select from the main window.
  • fromPosition:
number to specify at which position in the line to begin selecting
  • length:
number to specify the amount of characters you want to select
Example
-- select and colour the first character in the line red
if selectSection(0,1) then fg("red") end

-- select and colour the second character green (start selecting from the first character, and select 1 character)
if selectSection(1,1) then fg("green") end

-- select and colour three character after the first two grey (start selecting from the 2nd character for 3 characters long)
if selectSection(2,3) then fg("grey") end

selectString

selectString([windowName], text, number_of_match)
Selects a substring from the line where the user cursor is currently positioned - allowing you to edit selected text (apply colour, make it be a link, copy to other windows or other things).

Note Note: You can move the user cursor with moveCursor(). When a new line arrives from the game, the user cursor is positioned at the beginning of the line. However, if one of your trigger scripts moves the cursor around you need to take care of the cursor position yourself and make sure that the cursor is in the correct line if you want to call one of the select functions. To deselect text, see deselect().

See also: deselect()
Parameters
  • windowName:
(optional) name of the window in which to select text. By default the main window, if no windowName or an empty string is given.
  • text:
The text to select. It is matched as a substring match (so the text anywhere within the line will get selected).
  • number_of_match:
The occurrence of text on the line that you'd like to select. For example, if the line was "Bob and Bob", 1 would select the first Bob, and 2 would select the second Bob.

Returns position in line or -1 on error (text not found in line)

Note Note: To prevent working on random text if your selection didn't actually select anything, check the -1 return code before doing changes:

Example
if selectString("big monster", 1) > -1 then fg("red") end

setAppStyleSheet

setAppStyleSheet(stylesheet [, tag])
Sets a stylesheet for the entire Mudlet application and every open profile. Because it affects other profiles that might not be related to yours, it's better to use setProfileStyleSheet() instead of this function.
Raises the sysAppStyleSheetChange event which comes with two arguments in addition to the event name. The first is the optional tag which was passed into the function, or "" if nothing was given. The second is the profile which made the stylesheet changes.
See also: setProfileStyleSheet()
Parameters
  • stylesheet:
The entire stylesheet you'd like to use.
  • tag: (available in Mudlet 3.19+)
(optional) string tag or identifier that will be passed as a second argument in the sysAppStyleSheetChange event
References
See Qt Style Sheets Reference for the list of widgets you can style and CSS properties you can apply on them.
See also QDarkStyleSheet, a rather extensive stylesheet that shows you all the different configuration options you could apply, available as an mpackage here.
Example
-- credit to Akaya @ http://forums.mudlet.org/viewtopic.php?f=5&t=4610&start=10#p21770
local background_color = "#26192f"
local border_color = "#b8731b"

setAppStyleSheet([[
  QMainWindow {
     background: ]]..background_color..[[;
  }
  QToolBar {
     background: ]]..background_color..[[;
  }
  QToolButton {
     background: ]]..background_color..[[;
     border-style: solid;
     border-width: 2px;
     border-color: ]]..border_color..[[;
     border-radius: 5px;
     font-family: BigNoodleTitling;
     color: white;
     margin: 2px;
     font-size: 12pt;
  }
  QToolButton:hover { background-color: grey;}
  QToolButton:focus { background-color: grey;}
]])
Mudlet VersionAvailable in Mudlet3.0+

Note Note: Enhanced in Mudlet version 3.19.0 to generate an event that profiles/packages can utilise to redraw any parts of the UI that they themselves had previously styled so their effects can be re-applied to the new application style.

It is anticipated that the Mudlet application itself will make further use of application styling effects and two strings are provisionally planned for the second parameter in the sysAppStyleSheetChange event: "mudlet-theme-dark" and "mudlet-theme-light"; it will also set the third parameter to "system".

setBackgroundColor

setBackgroundColor([windowName], r, g, b, [transparency])
Sets the background for the given label, miniconsole, or userwindow. Colors are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
Parameters
  • windowName:
(optional) name of the label/miniconsole/userwindow to change the background color on, or "main" for the main window.
  • r:
Amount of red to use, from 0 (none) to 255 (full).
  • g:
Amount of green to use, from 0 (none) to 255 (full).
  • b:
Amount of red to use, from 0 (none) to 255 (full).
  • transparency:
(optional) amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Defaults to 255 if omitted.

Note Note: Transparency also available for main/miniconsoles in Mudlet 4.10+

Example
-- make a red label that's somewhat transparent
setBackgroundColor("some label",255,0,0,200)

setBackgroundImage

setBackgroundImage(labelName, imageLocation)
setBackgroundImage([windowname], imageLocation, [mode])
Loads an image file (png) as a background image for a label or console. This can be used to display clickable buttons in combination with setLabelClickCallback() and such.

Note Note: You can also load images on labels via setLabelStyleSheet().

Parameters (label)
  • labelName:
The name of the label to change it's background color.
  • imageLocation:
The full path to the image location. It's best to use [[ ]] instead of "" for it - because for Windows paths, backslashes need to be escaped.
Parameters (consoles)
  • windowName:
(optional) name of the miniconsole/userwindow to change the background image on, or "main" for the main window.
  • imageLocation:
The full path to the image location. It's best to use [[ ]] instead of "" for it - because for Windows paths, backslashes need to be escaped.
  • mode:
(optional) allows different modes for drawing the background image. Possible modes areː
    • border - the background image is stretched (1)
    • center - the background image is in the center (2),
    • tile - the background image is 'tiled' (3)
    • style - choose your own background image stylesheet, see example below (4)
See also: resetBackgroundImage()
Example (label)
-- give the top border a nice look
setBackgroundImage("top bar", [[/home/vadi/Games/Mudlet/games/top_bar.png]])
Example (main/miniconsole)
-- give the main window a background image
setBackgroundImage("main", [[:/Mudlet_splashscreen_development.png]], "center")

-- or use your own for the main window:
setBackgroundImage("main", [[C:\Documents and Settings\bub\Desktop\mypicture.png]], "center")

-- give my_miniconsole a nice background image and put it in the center
setBackgroundImage("my_miniconsole", [[:/Mudlet_splashscreen_development.png]], "center")

-- give my_miniconsole a nice background image with own stylesheet option
setBackgroundImage("my_miniconsole", [[background-image: url(:/Mudlet_splashscreen_development.png); background-repeat: no-repeat; background-position: right;]], "style")

Note Note: setBackgroundImage for main/miniconsoles and userwindows available in Mudlet 4.10+

setBgColor

setBgColor([windowName], r, g, b, [transparency])
Sets the current text background color in the main window unless windowName parameter given. If you have selected text prior to this call, the selection will be highlighted otherwise the current text background color will be changed. If you set a foreground or background color, the color will be used until you call resetFormat() on all further print commands.
If you'd like to change the background color of a window, see setBackgroundColor().
See also: cecho(), setBackgroundColor()
Parameters
  • windowName:
(optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
  • r:
The red component of the gauge color. Passed as an integer number from 0 to 255
  • g:
The green component of the gauge color. Passed as an integer number from 0 to 255
  • b:
The blue component of the gauge color. Passed as an integer number from 0 to 255
  • transparency:
Amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Optional, if not used color is fully opaque


Note Note: Transparency parameter available in Mudlet 4.10+

Example
--highlights the first occurrence of the string "Tom" in the current line with a red background color.
selectString( "Tom", 1 )
setBgColor( 255,0,0 )
--prints "Hello" on red background and "You" on blue.
setBgColor(255,0,0)
echo("Hello")
setBgColor(0,0,255)
echo(" You!")
resetFormat()

setBold

setBold(windowName, boolean)
Sets the current text font to bold (true) or non-bold (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be bolded. Any text you add after with echo() or insertText() will be bolded until you use resetFormat().
  • windowName:
Optional parameter set the current text background color in windowname given.
  • boolean:
A true or false that enables or disables bolding of text
Example
-- enable bold formatting
setBold(true)
-- the following echo will be bolded
echo("hi")
-- turns off bolding, italics, underlines and colouring. It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
resetFormat()

setBorderBottom

setBorderBottom(size)
Sets the size of the bottom border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
See Also: setBorderSizes(), setBorderColor(), getBorderBottom()
Parameters
  • size:
Height of the border in pixels - with 0 indicating no border.
Example
setBorderBottom(150)

setBorderColor

setBorderColor(red, green, blue)
Sets the color of the main windows border that you can create either with lua commands, or via the main window settings.
See Also: setBorderSizes()
Parameters
  • red:
Amount of red color to use, from 0 to 255.
  • green:
Amount of green color to use, from 0 to 255.
  • blue:
Amount of blue color to use, from 0 to 255.
Example
-- set the border to be completely blue
setBorderColor(0, 0, 255)

-- or red, using a name
setBorderColor( unpack(color_table.red) )

setBorderLeft

setBorderLeft(size)
Sets the size of the left border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
See Also: setBorderSizes(), setBorderColor(), getBorderLeft()
Parameters
  • size:
Width of the border in pixels - with 0 indicating no border.
Example
setBorderLeft(5)

setBorderRight

setBorderRight(size)
Sets the size of the right border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
See Also: setBorderSizes(), setBorderColor(), getBorderRight()
Parameters
  • size:
Width of the border in pixels - with 0 indicating no border.
Example
setBorderRight(50)

setBorderSizes

setBorderSizes(top, right, bottom, left)
Sets the size of all borders of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
The exact result of this function depends on how many numbers you give to it as arguments.
See also: getBorderSizes(), setBorderTop(), setBorderRight(), setBorderBottom(), setBorderLeft(), setBorderColor()
Mudlet VersionAvailable in Mudlet4.0+
Arguments
  • setBorderSizes(top, right, bottom, left)
4 arguments: All borders will be set to their new given size.
  • setBorderSizes(top, width, bottom)
3 arguments: Top and bottom borders will be set to their new given size, and right and left will gain the same width.
  • setBorderSizes(height, width)
2 arguments: Top and bottom borders will gain the same height, and right and left borders gain the same width.
  • setBorderSizes(size)
1 argument: All borders will be set to the same size.
  • setBorderSizes()
0 arguments: All borders will be hidden or set to size of 0 = no border.
Example
setBorderSizes(100, 50, 150, 0) 
-- big border at the top, bigger at the bottom, small at the right, none at the left

setBorderSizes(100, 50, 150) 
-- big border at the top, bigger at the bottom, small at the right and the left

setBorderSizes(100, 50) 
-- big border at the top and the bottom, small at the right and the left

setBorderSizes(100) 
-- big borders at all four sides

setBorderSizes() 
-- no borders at all four sides

setBorderTop

setBorderTop(size)
Sets the size of the top border of the main window in pixels. A border means that the game text won't go on it, so this gives you room to place your graphical elements there.
See Also: setBorderSizes(), setBorderColor(), getBorderTop()
Parameters
  • size:
Height of the border in pixels - with 0 indicating no border.
Example
setBorderTop(100)

setFgColor

setFgColor([windowName], red, green, blue)
Sets the current text foreground color in the main window unless windowName parameter given.
  • windowName:
(optional) either be none or "main" for the main console, or a miniconsole / userwindow name.
  • red:
The red component of the gauge color. Passed as an integer number from 0 to 255
  • green:
The green component of the gauge color. Passed as an integer number from 0 to 255
  • blue:
The blue component of the gauge color. Passed as an integer number from 0 to 255
See also: setBgColor(), setHexFgColor(), setHexBgColor(), resetFormat()
Example
--highlights the first occurrence of the string "Tom" in the current line with a red foreground color.
selectString( "Tom", 1 )
setFgColor( 255, 0, 0 )

setButtonStyleSheet

setButtonStyleSheet(button, markup)
Applies Qt style formatting to a button via a special markup language.
Parameters
  • button:
The name of the button to be formatted.
  • markup:
The string instructions, as specified by the Qt Style Sheet reference.
Note: You can instead use QWidget { markup }. QWidget will reference 'button', allowing the use of pseudostates like QWidget:hover and QWidget:selected
References
https://doc.qt.io/qt-5/stylesheet-reference.html
Example
setButtonStyleSheet("my test button", [[
  QWidget {
    background-color: #999999;
    border: 3px #777777;
  }
  QWidget:hover {
    background-color: #bbbbbb;
  }
  QWidget:checked {
    background-color: #77bb77;
    border: 3px #559955;
  }
  QWidget:hover:checked {
    background-color: #99dd99;
  } ]])

setClipboardText

setClipboardText(textContent)
Sets the value of the computer's clipboard to the string data provided.
See also: getClipboardText()
Parameters
  • textContent:
The text to be put into the clipboard.
Note Note: Note: Available in Mudlet 4.10+
Example
setClipboardText("New Clipboard Contents")
echo("Clipboard: " .. getClipboardText()) -- should echo "Clipboard: New Clipboard Contents"

setCmdLineAction

setCmdLineAction(commandLineName, luaFunctionName, [any arguments])
Specifies a Lua function to be called if the user sends text to the command line. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the command line action. Additionally, this function passes the command line input text as the final argument.

Note Note: If no action is set the command line behaves like the main command line and sends commands directly to the game or alias engine.

The function specified in luaFunctionName is called like so:

luaFuncName(optional number of arguments, text)
See also: resetCmdLineAction()
Parameters
  • commandLineName:
The name of the command line to attach the action function to.
  • luaFunctionName:
The Lua function name to call, as a string.
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.

Note Note: You can also pass a function directly instead of using a string

Mudlet VersionAvailable in Mudlet4.10+
Example
function sendTextToMiniConsole(miniConsoleName, cmdLineText)
  echo(miniConsoleName, cmdLineText.."\n")
end

setCmdLineAction("myCmdLine", "sendTextToMiniConsole", "myMiniConsole")

setCmdLineStyleSheet

setCmdLineStyleSheet([commandLineName], markup)
Applies Qt style formatting to a command line via a special markup language.
Parameters
  • commandLineName:
(optional) Name of the command line (or miniconsole the command line is in). If not given the stylesheet will be applied to the main command line.
  • markup
The string instructions, as specified by the Qt Style Sheet reference.

Note Note: Moving the command line over can adjust the other elements on the same horizontal axis, such as the search feature, buttons and network latency monitor. These additional components can take up to 30% of the screen size (400px when getMainWindowSize() was returning 1216px width). Don't go too aggressive with the numbers at first otherwise it will push elements off screen. Moving the command line over 250px on the above monitor also needed modifying of the width and max-width CSS properties. setCmdLineStyleSheet("main", [[QPlainTextEdit {margin-left: 250px; max-width: 562px; width: 562px}]])

Mudlet VersionAvailable in Mudlet4.10+
See also: enableCommandLine(), createCommandLine()
Examples
-- move the main command line over to the right
setCmdLineStyleSheet("main", [[
  QPlainTextEdit {
    margin-left: 100px; /* change 100 to your number */
    background-color: black; /* change it to your background color */
  }
]])

--only change font-size of your main command line
setCmdLineStyleSheet("main", [[
  QPlainTextEdit {
    font-sizeː20pt; 
  }
]])

--change the border colour of your main command line to a nice blue
setCmdLineStyleSheet("main", "QPlainTextEdit {background-color: #000000; border: 1px solid #4987d2;}")

--change bg/fg color of your miniconsole command line (name of the miniconsole is 'myMiniconsole'
--the command line in the miniconsole has to be enabled
setCmdLineStyleSheet("myMiniConsole", [[
  QPlainTextEdit {
    background: rgb(0,100,0);
    color: rgb(0,200,255);
    font-size: 10pt;
  }
]])

setFont

setFont(name, font)
Sets the font on the given window or console name. Can be used to change font of the main console, miniconsoles, and userwindows. Prefer a monospaced font - those work best with text games. See here for more.
See also: getFont(), setFontSize(), getFontSize(), openUserWindow(), getAvailableFonts()
Parameters
  • name:
Optional - the window name to set font size of - can either be none or "main" for the main console, or a miniconsole / userwindow name.
  • font:
The font to use.
Mudlet VersionAvailable in Mudlet3.9+
Example
-- The following will set the "main" console window font to Ubuntu Mono, another font included in Mudlet.
setFont("Ubuntu Mono")
setFont("main", "Ubuntu Mono")

-- This will set the font size of a miniconsole named "combat" to Ubuntu Mono.
setFont("combat", "Ubuntu Mono")

setFontSize

setFontSize(name, size)
Sets a font size on the given window or console name. Can be used to change font size of the Main console as well as dockable UserWindows.
See Also: getFontSize(), openUserWindow()
Parameters
  • name:
Optional - the window name to set font size of - can either be none or "main" for the main console, or a UserWindow name.
  • size:
The font size to apply to the window.
Mudlet VersionAvailable in Mudlet3.4+
Example
-- The following will set the "main" console window font to 12-point font.
setFontSize(12)
setFontSize("main", 12)

-- This will set the font size of a user window named "uw1" to 12-point font.
setFontSize("uw1", 12)

setGauge

setGauge(gaugeName, currentValue, maxValue, gaugeText)
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.
See also: moveGauge(), createGauge(), setGaugeText()
Example
-- create a gauge
createGauge("healthBar", 300, 20, 30, 300, nil, "green")

--Change the looks of the gauge named healthBar and make it
--fill to half of its capacity. The height is always remembered.
setGauge("healthBar", 200, 400)
--If you wish to change the text on your gauge, you’d do the following:
setGauge("healthBar", 200, 400, "some text")

setGaugeStyleSheet

setGaugeStyleSheet(gaugeName, css, cssback, csstext)
Sets the CSS stylesheets on a gauge - one on the front (the part that resizes according to the values on the gauge) and one in the back. You can use Qt Designer to create stylesheets.
Example
setGaugeStyleSheet("hp_bar", [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f04141, stop: 0.1 #ef2929, stop: 0.49 #cc0000, stop: 0.5 #a40000, stop: 1 #cc0000);
border-top: 1px black solid;
border-left: 1px black solid;
border-bottom: 1px black solid;
border-radius: 7;
padding: 3px;]],
[[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bd3333, stop: 0.1 #bd2020, stop: 0.49 #990000, stop: 0.5 #700000, stop: 1 #990000);
border-width: 1px;
border-color: black;
border-style: solid;
border-radius: 7;
padding: 3px;]])

setGaugeText

setGaugeText(gaugename, css, ccstext )
Set the formatting of the text used inside the inserted gaugename.
Example
setGaugeText("healthBar", [[<p style="font-weight:bold;color:#C9C9C9;letter-spacing:1pt;word-spacing:2pt;font-size:12px;text-align:center;font-family:arial black, sans-serif;">]]..MY_NUMERIC_VARIABLE_HERE..[[</p>]])
Useful resources
https://www.w3schools.com/colors/colors_picker.asp - Can help you choose colors for your text!

setHexBgColor

setHexBgColor([windowName], hexColorString)
Sets the current text background color in the main window unless windowName parameter given. This function allows to specify the color as a 6 character hexadecimal string.
  • windowName:
Optional parameter set the current text background color in windowname given.
  • hexColorString
6 character long hexadecimal string to set the color to. The first two characters 00-FF represent the red part of the color, the next two the green and the last two characters stand for the blue part of the color
See also: setBgColor(), setHexFgColor()
Example
--highlights the first occurrence of the string "Tom" in the current line with a red Background color.
selectString( "Tom", 1 )
setHexBgColor( "FF0000" )

setHexFgColor

setHexFgColor([windowName], hexColorString)
Sets the current text foreground color in the main window unless windowName parameter given. This function allows to specify the color as a 6 character hexadecimal string.
  • windowName:
Optional parameter set the current text foreground color in windowname given.
  • hexColorString
6 character long hexadecimal string to set the color to. The first two characters 00-FF represent the red part of the color, the next two the green and the last two characters stand for the blue part of the color
See also: setFgColor(), setHexBgColor()
Example
--highlights the first occurrence of the string "Tom" in the current line with a red foreground color.
selectString( "Tom", 1 )
setHexFgColor( "FF0000" )

setItalics

setItalics(windowName, bool)
Sets the current text font to italics/non-italics mode. If the windowName parameters omitted, the main screen will be used.

setLabelToolTip

setLabelToolTip(labelName, text, [duration])
Sets a tooltip on the given label.
Mudlet VersionAvailable in Mudlet4.6.1+
Parameters
  • labelName:
The name of the label to set the tooltip to.
  • text:
The text to be shown. Can contain Qt rich text formats.
  • duration:
Duration of the tooltip timeout in seconds. Optional, if not set the default duration will be set.
See also: resetLabelToolTip()

setLabelClickCallback

setLabelClickCallback(labelName, luaFunctionName, [any arguments])
Specifies a Lua function to be called if the user clicks on the label/image. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument. This table contains information about the mouse button clicked, other buttons that were pressed at the time, and the mouse cursor's local (relative to the label) and global (relative to the Mudlet window) position. The function specified in luaFunctionName is called like so:
luaFuncName(optional number of arguments, event)

where event has the following structure:

event = {
  x = 100,
  y = 200,
  globalX = 300,
  globalY = 320,
  button = "LeftButton",
  buttons = {"RightButton", "MidButton"},
}
See also: setLabelDoubleClickCallback(), setLabelReleaseCallback(), setLabelMoveCallback(), setLabelWheelCallback(),setLabelOnEnter(), setLabelOnLeave()
Parameters
  • labelName:
The name of the label to attach a callback function to.
  • luaFunctionName:
Lua function to call, or the function name, as a string.
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.

Note Note: Event argument is available in 3.6+, and in 4.8+ you can pass a function directly instead of a string.

Note Note: While event.button may contain a single string of any listed below, event.buttons will only ever contain some combination of "LeftButton", "MidButton", and "RightButton"

The following mouse button strings are defined:
"LeftButton"        "RightButton"        "MidButton"
"BackButton"        "ForwardButton"      "TaskButton"
"ExtraButton4"      "ExtraButton5"       "ExtraButton6"
"ExtraButton7"      "ExtraButton8"       "ExtraButton9"
"ExtraButton10"     "ExtraButton11"      "ExtraButton12"
"ExtraButton13"     "ExtraButton14"      "ExtraButton15"
"ExtraButton16"     "ExtraButton17"      "ExtraButton18"
"ExtraButton19"     "ExtraButton20"      "ExtraButton21"
"ExtraButton22"     "ExtraButton23"      "ExtraButton24"
Example
createLabel("testLabel", 50, 50, 100, 100, 0)

function onClickGoNorth(event)
  if event.button == "LeftButton" then
    send("walk north")
  elseif event.button == "RightButton" then
    send("swim north")
  elseif event.button == "MidButton" then
    send("gallop north")
  end
end

setLabelClickCallback("testLabel", "onClickGoNorth")

-- you can also use them within tables:
mynamespace =
  {
    onClickGoNorth =
      function()
        echo("the north button was clicked!")
      end,
  }
setLabelClickCallback("testLabel", "mynamespace.onClickGoNorth")

-- or by passing the function directly:
setLabelClickCallback("testLabel", onClickGoNorth)

setLabelDoubleClickCallback

setLabelDoubleClickCallback(labelName, luaFunctionName, [any arguments])
Specifies a Lua function to be called if the user double clicks on the label/image. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in setLabelClickCallback()
Mudlet VersionAvailable in Mudlet3.6+
See also: setLabelClickCallback(), setLabelReleaseCallback(), setLabelMoveCallback(), setLabelWheelCallback(), setLabelOnEnter(), setLabelOnLeave()
Parameters
  • labelName:
The name of the label to attach a callback function to.
  • luaFunctionName:
The Lua function name to call, as a string.
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.

setLabelMoveCallback

setLabelMoveCallback(labelName, luaFunctionName, [any arguments])
Specifies a Lua function to be called when the mouse moves while inside the specified label/console. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in setLabelClickCallback()
See Also: setLabelClickCallback(), setLabelDoubleClickCallback(), setLabelReleaseCallback(), setLabelWheelCallback(), setLabelOnEnter(), setLabelOnLeave()
Parameters
  • labelName:
The name of the label to attach a callback function to.
  • luaFunctionName:
The Lua function name to call, as a string.
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.
Mudlet VersionAvailable in Mudlet3.6+

setLabelOnEnter

setLabelOnEnter(labelName, luaFunctionName, [any arguments])
Specifies a Lua function to be called when the mouse enters within the labels borders. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, similar to setLabelClickCallback(), but with slightly different information.
For this callback, the event argument has the following structure:
event = {
  x = 100,
  y = 200,
  globalX = 300,
  globalY = 320,
}
See Also: setLabelClickCallback(), setLabelDoubleClickCallback(), setLabelReleaseCallback(), setLabelMoveCallback(), setLabelWheelCallback(), setLabelOnLeave()
Parameters
  • labelName:
The name of the label to attach a callback function to.
  • luaFunctionName:
The Lua function name to call, as a string - it must be registered as a global function, and not inside any namespaces (tables).
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.
Example
function onMouseOver()
  echo("The mouse is hovering over the label!\n")
end

setLabelOnEnter( "compassNorthImage", "onMouseOver" )

setLabelOnLeave

setLabelOnLeave(labelName, luaFunctionName, [any arguments])
Specifies a Lua function to be called when the mouse leaves the labels borders. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button.
See Also: setLabelClickCallback(), setLabelOnEnter()
Parameters
  • labelName:
The name of the label to attach a callback function to.
  • luaFunctionName:
The Lua function name to call, as a string - it must be registered as a global function, and not inside any namespaces (tables).
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.
Example
function onMouseLeft(argument)
  echo("The mouse quit hovering over the label the label! We also got this as data on the function: "..argument)
end

setLabelOnLeave( "compassNorthImage", "onMouseLeft", "argument to pass to function" )

setLabelReleaseCallback

setLabelReleaseCallback(labelName, luaFunctionName, [any arguments])
Specifies a Lua function to be called when a mouse click ends that originated on the specified label/console. This function is called even if you drag the mouse off of the label/console before releasing the click. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, as in setLabelClickCallback()
Mudlet VersionAvailable in Mudlet3.0+
See Also: setLabelClickCallback(), setLabelDoubleClickCallback(), setLabelMoveCallback(), setLabelWheelCallback(), setLabelOnEnter(), setLabelOnLeave()
Parameters
  • labelName:
The name of the label to attach a callback function to.
  • luaFunctionName:
The Lua function name to call, as a string.
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.

Note Note: The event argument only available since Mudlet 3.6

Example
function onReleaseNorth()
  echo("the north button was released!")
end

setLabelReleaseCallback( "compassNorthImage", "onReleaseNorth" )

-- you can also use them within tables:
mynamespace = {
  onReleaseNorth = function()
    echo("the north button was released!")
  end
}

setLabelReleaseCallback( "compassNorthImage", "mynamespace.onReleaseNorth" )

setLabelStyleSheet

setLabelStyleSheet(label, markup)
Applies Qt style formatting to a label via a special markup language.
Parameters
  • label:
The name of the label to be formatted (passed when calling createLabel).
  • markup:
The string instructions, as specified by the Qt Style Sheet reference.
Note that when specifying a file path for styling purposes, forward slashes, / , must be used, even if your OS uses backslashes, \ , normally.
References
https://doc.qt.io/qt-5/stylesheet-reference.html
Example
-- This creates a label with a white background and a green border, with the text "test"
-- inside.
createLabel("test", 50, 50, 100, 100, 0)
setLabelStyleSheet("test", [[
  background-color: white;
  border: 10px solid green;
  font-size: 12px;
  ]])
echo("test", "test")
-- This creates a label with a single image, that will tile or clip depending on the
-- size of the label. To use this example, please supply your own image.
createLabel("test5", 50, 353, 164, 55, 0)
setLabelStyleSheet("test5", [[
  background-image: url("C:/Users/Administrator/.config/mudlet/profiles/Midkemia Online/Vyzor/MkO_logo.png");
  ]])
-- This creates a label with a single image, that can be resized (such as during a
-- sysWindowResizeEvent). To use this example, please supply your own image.
createLabel("test9", 215, 353, 100, 100, 0)
setLabelStyleSheet("test9", [[
  border-image: url("C:/Users/Administrator/.config/mudlet/profiles/Midkemia Online/Vyzor/MkO_logo.png");
  ]])
--This creates a label whose background changes when the users mouse hovers over it.

--putting the styleSheet in a variable allows us to easily change the styleSheet. We also are placing colors in variables that have been preset.  
local labelBackgroundColor = "#123456"
local labelHoverColor = "#654321"
local labelFontSize = 12
local labelName = "HoverLabel"
local ourLabelStyle = [[
QLabel{
	background-color: ]]..labelBackgroundColor..[[;
	font-size: ]]..labelFontSize..[[px;
	qproperty-alignment: 'AlignCenter | AlignCenter';
}
QLabel::hover{
	background-color: ]]..labelHoverColor..[[;
	font-size: ]]..labelFontSize..[[px;
	qproperty-alignment: 'AlignCenter | AlignCenter';
}
]]

--Creating the label using the labelName and ourLabelStyle variables created above.
createLabel(labelName,0,0,400,400,1)
setLabelStyleSheet(labelName, ourLabelStyle)
echo("HoverLabel","This text shows while mouse is or is not over the label.")
--Using QLabel::hover mentioned above. Lets "trick" the label into changing it's text.
--Please keep in mind that the setLabelMoveCallback allows for much more control over not just your label but your entire project.

--putting the styleSheet in a variable allows us to easily change the styleSheet. We also are placing colors in variables that have been preset.  
local labelBackgroundColor = "#123456"
local labelHoverColor = "#654321"
local labelFontSize = 12
local labelName = "HoverLabel"
--Notice we are adding a string returned from a function. In this case, the users profile directory.
local ourLabelStyle = [[
QLabel{
	border-image: url("]]..getMudletHomeDir()..[[/imagewithtext.png");
}
QLabel::hover{
	border-image: url("]]..getMudletHomeDir()..[[/imagewithhovertext.png");
}
]]

--Creating the label using the labelName and ourLabelStyle variables created above.
createLabel(labelName,0,0,400,400,1)
setLabelStyleSheet(labelName, ourLabelStyle)
--This is just to example that echos draw on top of the label. You would not want to echo onto a label you were drawing text on with images, because echos would draw on top of them.
echo("HoverLabel","This text shows while mouse is or is not over the label.")

setLabelCursor

setLabelCursor(labelName, cursorShape)
Changes how the mouse cursor looks like when over the label. To reset the cursor shape, use resetLabelCursor().
See also: resetLabelCursor(), setLabelCustomCursor()
Mudlet VersionAvailable in Mudlet4.8+
Parameters
  • labelName:
Name of the label which you want the mouse cursor change at.
  • cursorShape
Shape of the mouse cursor. List of possible cursor shapes is available here.
Example
setLabelCursor("myLabel", "Cross")
-- This will change the mouse cursor to a cross if it's over the label myLabel

setLabelCustomCursor

setLabelCustomCursor(labelName, custom cursor, [hotX, hotY])
Changes the mouse cursor shape over your label to a custom cursor. To reset the cursor shape, use resetLabelCursor().
See also: resetLabelCursor(), setLabelCursor()
Mudlet VersionAvailable in Mudlet4.8+
Parameters
  • labelName:
Name of the label which you want the mouse cursor change at.
  • custom cursor
Location of your custom cursor file. To be compatible with all systems it is recommended to use png files with size of 32x32.
  • hotX
X-coordinate of the cursors hotspot position. Optional, if not set it is set to -1 which is in the middle of your custom cursor.
  • hotY
Y-coordinate of the cursors hotspot position. Optional, if not set it is set to -1 which is in the middle of your custom cursor.
Example
setLabelCustomCursor("myLabel", getMudletHomeDir().."/custom_cursor.png")
-- This will change the mouse cursor to your custom cursor if it's over the label myLabel

setLabelWheelCallback

setLabelWheelCallback(labelName, luaFunctionName, [any arguments])
Specifies a Lua function to be called when the mouse wheel is scrolled while inside the specified label/console. This function can pass any number of string or integer number values as additional parameters. These parameters are then used in the callback - thus you can associate data with the label/button. Additionally, this function passes an event table as the final argument, similar to setLabelClickCallback(), but with slightly different information.
For this callback, the event argument has the following structure:
event = {
  x = 100,
  y = 200,
  globalX = 300,
  globalY = 320,
  buttons = {"RightButton", "MidButton"},
  angleDeltaX = 0,
  angleDeltaY = 120
}
Keys angleDeltaX and angleDeltaY correspond with the horizontal and vertical scroll distance, respectively. For most mice, these values will be multiples of 120.
See Also: setLabelClickCallback(), setLabelDoubleClickCallback(), setLabelReleaseCallback(), setLabelMoveCallback(), setLabelOnEnter(), setLabelOnLeave()
Parameters
  • labelName:
The name of the label to attach a callback function to.
  • luaFunctionName:
The Lua function name to call, as a string.
  • any arguments:
(optional) Any amount of arguments you'd like to pass to the calling function.
Mudlet VersionAvailable in Mudlet3.6+
Example
function onWheelNorth(event)
  if event.angleDeltaY > 0 then
    echo("the north button was wheeled forwards over!")
  else
    echo("the north button was wheeled backwards over!")
  end
end

setLabelWheelCallback( "compassNorthImage", "onWheelNorth" )

-- you can also use them within tables:
mynamespace = {
  onWheelNorth = function()
    echo("the north button was wheeled over!")
  end
}

setWheelReleaseCallback( "compassNorthImage", "mynamespace.onWheelNorth" )

setLink

setLink([windowName], command, tooltip)
Turns the selected text into a clickable link - upon being clicked, the link will do the command code. Tooltip is a string which will be displayed when the mouse is over the selected text.
Parameters
  • windowName:
(optional) name of a miniconsole or a userwindow in which to select the text in.
  • command:
command to do when the text is clicked, as text or Lua function.
  • tooltip:
tooltip to show when the mouse is over the text - explaining what would clicking do.
Example
-- you can clickify a lot of things to save yourself some time - for example, you can change
--  the line where you receive a message to be clickable to read it!
-- perl regex trigger:
-- ^You just received message #(\w+) from \w+\.$
-- script:
selectString(matches[2], 1)
setUnderline(true) setLink([[send("msg read ]]..matches[2]..[[")]], "Read #"..matches[2])
resetFormat()

-- example of selecting text in a miniconsole and turning it into a link:
HelloWorld = Geyser.MiniConsole:new({
  name="HelloWorld",
  x="70%", y="50%",
  width="30%", height="50%",
})
HelloWorld:echo("hi")
selectString("HelloWorld", "hi", 1)
setLink("HelloWorld", "echo'you clicked hi!'", "click me!")

setMainWindowSize

setMainWindowSize(mainWidth, mainHeight)
Changes the size of your main Mudlet window to the values given.
See Also: getMainWindowSize()
Parameters
  • mainWidth:
The new width in pixels.
  • mainHeight:
The new height in pixels.
Example
--this will resize your main Mudlet window
setMainWindowSize(1024, 768)

setMapWindowTitle

setMapWindowTitle(text)
Changes the title shown in the mapper window when it's popped out.
See also: resetMapWindowTitle()
Parameters
  • text:
New window title to set.
Mudlet VersionAvailable in Mudlet4.8+
Example
setMapWindowTitle("my cool game map")

setMiniConsoleFontSize

setMiniConsoleFontSize(name, fontSize)
Sets the font size of the mini console. see also: setFontSize(), createMiniConsole(), createLabel()

setMovie

setMovie(label name, path to gif)
Adds a gif to the selected label and animates it. Note that gifs are pretty expensive to play, so don't add too many at once.
Some websites you can get gifs from are Tenor and Giphy (not officially endorsed).
Returns true
See also: startMovie(), pauseMovie(), setMovieFrame(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the label the gif will be animated on
  • path:
path of the gif file
Example
-- download & show a gif within mudlet
local saveto = getMudletHomeDir().."/kymip.gif"
-- animation credit to https://opengameart.org/content/kymiball-ii-third-prototype-scraps
local url = "https://opengameart.org/sites/default/files/kymip_0.gif"

if downloadHandler then killAnonymousEventHandler(downloadHandler) end
downloadHandler = registerAnonymousEventHandler("sysDownloadDone",
  function(_, filename)
    if filename ~= saveto then
      return true
    end
    
    local width, height = getImageSize(saveto)

    createLabel("kymip", 300, 300, width, height, 0)
    setMovie("kymip", saveto)
    setLabelReleaseCallback("kymip", function() deleteLabel("kymip") end)
  end, true)

downloadFile(saveto, url)
local gifpath = getMudletHomeDir().."/movie.gif"

local width, height = getImageSize(gifpath)

-- create a label with the name mygif
createLabel("mygif", 0, 0, width, height,0)
-- put the gif on the label and animate it
setMovie("mygif", gifpath)

setMovieFrame

setMovieFrame(label name, frame nr)
Jump to a specific frame in the gif.
Returns true if successful, and false if frame doesn't exist.
See also: setMovie(), startMovie(), pauseMovie(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
  • frame nr:
the gif animations frame nr to jump to
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--stops the animation
pauseMovie("myMovie")
-- jumps to frame 12 of the animation
setMovieFrame("myMovie", 12)
--start the animation
startMovie("myMovie")

setMovieSpeed

setMovieSpeed(label name, speed in percent)
Set the animation speed, in percent.
Returns true
See also: setMovie(), startMovie(), pauseMovie(), setMovieFrame()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
  • speed in percent:
the gif animations speed in percent for example 50 for 50% speed
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--accelerates the animation to a speed of 150%
setMovieSpeed("myMovie",150)

setOverline

setOverline([windowName], boolean)
Sets the current text font to be overlined (true) or not overlined (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be overlined. Any text you add after with echo() or insertText() will be overlined until you use resetFormat().
  • windowName:
(optional) name of the window to set the text to be overlined or not.
  • boolean:
A true or false that enables or disables overlining of text
Example
-- enable overlined text
setOverline(true)
-- the following echo will be have an overline
echo("hi")
-- turns off bolding, italics, underlines, colouring, and strikethrough (and, after this and reverse have been added, them as well). It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
resetFormat()
Mudlet VersionAvailable in Mudlet3.17+

setPopup

setPopup([windowName], {lua code}, {hints})
Turns the selected() text into a left-clickable link, and a right-click menu for more options. The selected text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line.
Parameters
  • windowName:
the name of the console to operate on. If not using this in a miniConsole, use "main" as the name.
This argument was ignored before Mudlet 4.11.
  • {lua code}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}
  • {hints}:
a table of strings which will be shown on the popup and right-click menu. ie, {"send the hi command", "echo hi to yourself"}.


Example
-- In a `Raising your hand in greeting, you say "Hello!"` exact match trigger,
-- the following code will make left-clicking on `Hello` show you an echo, while right-clicking
-- will show some commands you can do.

selectString("Hello", 1)
setPopup("main", {function() send("bye") end, function() echo("hi!") end}, {"send 'bye' to the MUD", "click to echo 'hi!'"})

-- alternatively, put command as text (in [[ and ]] to use quotation marks inside)
setPopup("main", {[[send("bye")]], [[echo("hi!")]]}, {"send 'bye' to the MUD", "click to echo 'hi!'"})

setProfileStyleSheet

setProfileStyleSheet(stylesheet)
Sets a stylesheet for the current Mudlet profile - allowing you to customise content outside of the main window (the profile tabs, the scrollbar, and so on). This function is better than setAppStyleSheet() because it affects only the current profile and not every other one as well.
See also: setAppStyleSheet()
Parameters
  • stylesheet:
The entire stylesheet you'd like to use. See Qt Style Sheets Reference for the list of widgets you can style and CSS properties you can apply on them.
See also QDarkStyleSheet, a rather extensive stylesheet that shows you all the different configuration options you could apply, available as an mpackage here.
Example
-- credit to Akaya @ http://forums.mudlet.org/viewtopic.php?f=5&t=4610&start=10#p21770
local background_color = "#26192f"
local border_color = "#b8731b"

setProfileStyleSheet([[
  QMainWindow {
     background: ]]..background_color..[[;
  }
  QToolBar {
     background: ]]..background_color..[[;
  }
  QToolButton {
     background: ]]..background_color..[[;
     border-style: solid;
     border-width: 2px;
     border-color: ]]..border_color..[[;
     border-radius: 5px;
     font-family: BigNoodleTitling;
     color: white;
     margin: 2px;
     font-size: 12pt;
  }
  QToolButton:hover { background-color: grey;}
  QToolButton:focus { background-color: grey;}

  QTreeView {
     background: ]]..background_color..[[;
     color: white;
  }

  QMenuBar{ background-color: ]]..background_color..[[;}

  QMenuBar::item{ background-color: ]]..background_color..[[;}

  QDockWidget::title {
     background: ]]..border_color..[[;
  }
  QStatusBar {
     background: ]]..border_color..[[;
  }
  QScrollBar:vertical {
     background: ]]..background_color..[[;
     width: 15px;
     margin: 22px 0 22px 0;
  }
  QScrollBar::handle:vertical {
     background-color: ]]..background_color..[[;
     min-height: 20px;
     border-width: 2px;
     border-style: solid;
     border-color: ]]..border_color..[[;
     border-radius: 7px;
  }
  QScrollBar::add-line:vertical {
   background-color: ]]..background_color..[[;
   border-width: 2px;
   border-style: solid;
   border-color: ]]..border_color..[[;
   border-bottom-left-radius: 7px;
   border-bottom-right-radius: 7px;
        height: 15px;
        subcontrol-position: bottom;
        subcontrol-origin: margin;
  }
  QScrollBar::sub-line:vertical {
   background-color: ]]..background_color..[[;
   border-width: 2px;
   border-style: solid;
   border-color: ]]..border_color..[[;
   border-top-left-radius: 7px;
   border-top-right-radius: 7px;
        height: 15px;
        subcontrol-position: top;
        subcontrol-origin: margin;
  }
  QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
     background: white;
     width: 4px;
     height: 3px;
  }
  QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
     background: none;
  }
]])

-- if you'd like to reset it, use:
setProfileStyleSheet("")

-- to only affect scrollbars within the main window and miniconsoles, prefix them with 'TConsole':
setProfileStyleSheet[[
  TConsole QScrollBar:vertical {
      border: 2px solid grey;
      background: #32CC99;
      width: 15px;
      margin: 22px 0 22px 0;
  }
  TConsole QScrollBar::handle:vertical {
      background: white;
      min-height: 20px;
  }
  TConsole QScrollBar::add-line:vertical {
      border: 2px solid grey;
      background: #32CC99;
      height: 20px;
      subcontrol-position: bottom;
      subcontrol-origin: margin;
  }
  TConsole QScrollBar::sub-line:vertical {
      border: 2px solid grey;
      background: #32CC99;
      height: 20px;
      subcontrol-position: top;
      subcontrol-origin: margin;
  }
  TConsole QScrollBar::up-arrow:vertical, QScrollBar::down-arrow:vertical {
      border: 2px solid grey;
      width: 3px;
      height: 3px;
      background: white;
  }
  TConsole QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
      background: none;
  }
]]
Mudlet VersionAvailable in Mudlet4.6+

setReverse

setReverse([windowName], boolean)
Sets the current text to swap foreground and background color settings (true) or not (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will have it's colors swapped. Any text you add after with echo() or insertText() will have their foreground and background colors swapped until you use resetFormat().
  • windowName:
(optional) name of the window to set the text colors to be reversed or not.
  • boolean:
A true or false that enables or disables reversing of the fore- and back-ground colors of text
Example
-- enable fore/back-ground color reversal of text
setReverse(true)
-- the following echo will have the text colors reversed
echo("hi")
-- turns off bolding, italics, underlines, colouring, and strikethrough (and, after this and overline have been added, them as well). It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
resetFormat()
Mudlet VersionAvailable in Mudlet3.17+

Note Note: Although the visual effect on-screen is the same as that of text being selected if both apply to a piece of text they neutralise each other - however the effect of the reversal will be carried over in copies made by the "Copy to HTML" and in logs made in HTML format log file mode.

setStrikeOut

setStrikeOut([windowName], boolean)
Sets the current text font to be striken out (true) or not striken out (false) mode. If the windowName parameters omitted, the main screen will be used. If you've got text currently selected in the Mudlet buffer, then the selection will be bolded. Any text you add after with echo() or insertText() will be striken out until you use resetFormat().
  • windowName:
(optional) name of the window to set the text to be stricken out or not.
  • boolean:
A true or false that enables or disables striking out of text
Example
-- enable striken-out text
setStrikeOut(true)
-- the following echo will be have a strikethrough
echo("hi")
-- turns off bolding, italics, underlines, colouring, and strikethrough. It's good practice to clean up after you're done with the formatting, so other your formatting doesn't "bleed" into other echoes.
resetFormat()

setTextFormat

setTextFormat(windowName, r1, g1, b1, r2, g2, b2, bold, underline, italics, [strikeout], [overline], [reverse])
Sets current text format of selected window. This is a more convenient means to set all the individual features at once compared to using setFgColor(windowName, r,g,b), setBold(windowName, true), setItalics(windowName, true), setUnderline(windowName, true), setStrikeOut(windowName, true).
See Also: getTextFormat()
Parameters
  • windowName
Specify name of selected window. If empty string "" or "main" format will be applied to the main console
  • r1,g1,b1
To color text background, give number values in RBG style
  • r2,g2,b2
To color text foreground, give number values in RBG style
  • bold
To format text bold, set to 1 or true, otherwise 0 or false
  • underline
To underline text, set to 1 or true, otherwise 0 or false
  • italics
To format text italic, set to 1 or true, otherwise 0 or false
  • strikeout
(optional) To strike text out, set to 1 or true, otherwise 0 or false or simply no argument
  • overline
(optional) To use overline, set to 1 or true, otherwise 0 or false or simply no argument
  • reverse
(optional) To swap foreground and background colors, set to 1 or true, otherwise 0 or false or simply no argument
Example
--This script would create a mini text console and write with bold, struck-out, yellow foreground color and blue background color "This is a test".
createMiniConsole( "con1", 0,0,300,100);
setTextFormat("con1",0,0,255,255,255,0,true,0,false,1);
echo("con1","This is a test")

Note Note: In versions prior to 3.7.0 the error messages and this wiki were wrong in that they had the foreground color parameters as r1, g1 and b1 and the background ones as r2, g2 and b2.

setUnderline

setUnderline(windowName, bool)
Sets the current text font to underline/non-underline mode. If the windowName parameters omitted, the main screen will be used.

setUserWindowTitle

setUserWindowTitle(windowName, text)
sets a new title text for the UserWindow windowName
Parameters
  • windowName:
Name of the userwindow
  • text
new title text
Mudlet VersionAvailable in Mudlet4.8+
See also: resetUserWindowTitle(), openUserWindow()

setUserWindowStyleSheet

setUserWindowStyleSheet(windowName, markup)
Applies Qt style formatting to the border/title area of a userwindow via a special markup language.
Parameters
  • windowName:
Name of the userwindow
  • markup
The string instructions, as specified by the Qt Style Sheet reference.
Note that when you dock the userwindow the border style is not provided by this
Mudlet VersionAvailable in Mudlet4.10+
Example
-- changes the title area style of the UserWindow 'myUserWindow'
setUserWindowStyleSheet("myUserWindow", [[QDockWidget::title{ 
    background-color: rgb(0,255,150);
    border: 2px solid red;
    border-radius: 8px;
    text-align: center;    
    }]])
See also: openUserWindow()

setWindow

setWindow(windowName, name, [Xpos, Ypos, show])
Changes the parent window of an element.
Mudlet VersionAvailable in Mudlet4.8+
Parameters
  • windowName:
Name of the userwindow which you want the element put in. If you want to put the element into the main window, use windowName "main".
  • name
Name of the element which you want to switch the parent from. Elements can be labels, miniconsoles and the embedded mapper. If you want to move the mapper use the name "mapper"
  • Xpos:
X position of the element. Measured in pixels, with 0 being the very left. Passed as an integer number. Optional, if not given it will be 0.
  • Ypos:
Y position of the element. Measured in pixels, with 0 being the very top. Passed as an integer number. Optional, if not given it will be 0.
  • show:
true or false to decide if the element will be shown or not in the new parent window. Optional, if not given it will be true.
Example
setWindow("myuserwindow", "mapper")
-- This will put your embedded mapper in your userwindow "myuserwindow".

setWindowWrap

setWindowWrap(windowName, wrapAt)
sets at what position in the line the will start word wrap.
Parameters
  • windowName:
Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
  • wrapAt:
Number of characters at which the wrap must happen at the latest. This means, it probably will be wrapped earlier than that.
Example
setWindowWrap("main", 10)
display("This is just a test")

-- The following output will result in the main window console:
"This is
just a
test"

-- wrap to the exact amount that fits on the screen
setWindowWrap(window, getColumnCount(window))

setWindowWrapHangingIndent

setWindowWrapHangingIndent(windowName, indentSize)
Sets how many spaces the second and all subsequent line(s) of text from a wrapped line will be indented.
See also
setWindowWrap(), setWindowWrapIndent()
Mudlet VersionAvailable in Mudlet4.20+
Parameters
  • windowName:
Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
  • indentSize:
Number of spaces which hanging wrapped lines are prefixed with.
Example
-- |Make wrapped text indent
-- |  like this. (Keep going
-- |  until a linebreak.)

setWindowWrap("main", 25)
setWindowWrapIndent("main", 0)          -- First line indent
setWindowWrapHangingIndent("main", 2)   -- subsequent line(s)

setWindowWrapIndent

setWindowWrapIndent(windowName, indentSize)
Sets how many spaces the first line of text from a wrapped line will be indented.
See also
setWindowWrap(), setWindowWrapHangingIndent()
Mudlet VersionAvailable in Mudlet4.20+
Parameters
  • windowName:
Name of the "main" console or user-created miniconsole which you want to be wrapped differently. If you want to wrap the main window, use windowName "main".
  • indentSize:
Number of spaces which wrapped lines are prefixed with.
Example
-- |  Make wrapped text indent
-- |indent like this. (Only
-- |first line indented.)

setWindowWrap("main", 25)
setWindowWrapIndent("main", 2)          -- First line indent
setWindowWrapHangingIndent("main", 0)   -- subsequent line(s)

showCaptureGroups

showCaptureGroups()
Lua debug function that highlights in random colors all capture groups in your trigger regex on the screen. This is very handy if you make complex regex and want to see what really matches in the text. This function is defined in DebugTools.lua.
Example
Make a trigger with the regex (\w+) and call this function in a trigger. All words in the text will be highlighted in random colors.

showMultimatches

showMultimatches()
Lua helper function to show you what the table multimatches[n][m] contains. This is very useful when debugging multiline triggers - just doing showMultimatches() in your script will make it give the info. This function is defined in DebugTools.lua.
Example

See How to use multimatches[n][m] for a more thorough explanation including examples.

showWindow

showWindow(name)
Makes a hidden window (label or miniconsole) be shown again.
See also: hideWindow()

startMovie

startMovie(label name)
Starts the gif animation - if it was previously stopped or paused.
Returns true
See also: setMovie(), pauseMovie(), setMovieFrame(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--stops the animation
pauseMovie("myMovie")
--restart the animation
startMovie("myMovie")

showColors

showColors([columns], [filterColor], [sort])
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.
  • filterColor:
(optional) filter text. If given, the colors displayed will be limited to only show colors containing this text.
  • sort:
(optional) sort colors alphabetically.
Example
-- display as four columns:
showColors(4)

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

The output for this is:

showColors(4)

showGauge

showGauge(gaugeName)
shows the given gauge, in case it was hidden previously.
See also: hideGauge(), createGauge()
Parameters
  • gaugeName:
name of the gauge to show.
Example
hideGauge("my gauge")
showGauge("my gauge")

showToolBar

showToolBar(name)
Makes a toolbar (a button group) appear on the screen.
Parameters
  • name:
name of the button group to display
Example
showToolBar("my attack buttons")

suffix

suffix(text, [writingFunction], [foregroundColor], [backgroundColor], [windowName])
Suffixes text at the end of the current line. This is similar to echo(), which also suffixes text at the end of the line, but different - echo() makes sure to do it on the last line in the buffer, while suffix does it on the line the cursor is currently on.
Parameters
  • text
the information you want to prefix
  • writingFunction
optional parameter, allows the selection of different functions to be used to write the text, valid options are: echo, cecho, decho, and hecho.
  • foregroundColor
optional parameter, allows a foreground color to be specified if using the echo function using a color name, as with the fg() function
  • backgroundColor
optional parameter, allows a background color to be specified if using the echo function using a color name, as with the bg() function
  • windowName
optional parameter, allows the selection a miniconsole or the main window for the line that will be prefixed
See also: prefix(), echo()

setCommandBackgroundColor

setCommandBackgroundColor([windowName], r, g, b, [transparency])
Sets the background color for echo of commands. Colors are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
Parameters
  • windowName:
(optional) name of the label/miniconsole/userwindow to change the background color on, or "main" for the main window.
  • r:
Amount of red to use, from 0 (none) to 255 (full).
  • g:
Amount of green to use, from 0 (none) to 255 (full).
  • b:
Amount of red to use, from 0 (none) to 255 (full).
  • transparency:
(optional) amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Defaults to 255 if omitted.
Mudlet VersionAvailable in Mudlet4.17.0+
Example
-- make a red command background color in main console.
setCommandBackgroundColor(255,0,0,200)

setCommandForegroundColor

setCommandForegroundColor([windowName], r, g, b, [transparency])
Sets the foreground color for echo of commands. Colors are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
Parameters
  • windowName:
(optional) name of the label/miniconsole/userwindow to change the background color on, or "main" for the main window.
  • r:
Amount of red to use, from 0 (none) to 255 (full).
  • g:
Amount of green to use, from 0 (none) to 255 (full).
  • b:
Amount of red to use, from 0 (none) to 255 (full).
  • transparency:
(optional) amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Defaults to 255 if omitted.
Mudlet VersionAvailable in Mudlet4.17.0+
Example
-- make a red command foreground color in main console.
setCommandForegroundColor(255,0,0,200)

scrollDown

scrollDown([windowName,] [lines])
Scrolls down in window by a certain number of lines.
See also: getScroll, scrollTo, scrollUp
Parameters
  • windowName:
(optional) name of the window in which to scroll. Default is the main window.
  • lines:
(optional) how many lines to scroll by. Default is 1.
Mudlet VersionAvailable in Mudlet4.17.0+
Example
-- scroll down by 7 lines
scrollDown(7)

scrollUp

scrollUp([windowName,] [lines])
Scrolls up in window by a certain number of lines.
See also: getScroll, scrollTo, scrollDown
Parameters
  • windowName:
(optional) name of the window in which to scroll. Default is the main window.
  • lines:
(optional) how many lines to scroll by. Default is 1.
Mudlet VersionAvailable in Mudlet4.17.0+
Example
-- scroll up by 7 lines
scrollUp(7)

scrollTo

scrollTo([windowName,] [lineNumber])
Scrolls window to a specific line in the buffer.
Parameters
  • windowName:
(optional) name of the window in which to scroll. Default is the main window.
  • lineNumber:
(optional) target line to scroll to, counting from the top of buffer or with negative numbers to count from the end of buffer. Default is the end of the buffer, to stop scrolling.
See also: getScroll, scrollUp, scrollDown
Mudlet VersionAvailable in Mudlet4.17.0+
Example
-- scroll to line 42 in buffer
scrollTo(42)

-- start of session
scrollTo(0)

-- 20 lines ago
scrollTo(-20)

-- chat window to line 30
scrollTo("chat", 30)

-- stop scrolling main window
scrollTo()

-- stop scrolling chat window
scrollTo("chat")

windowType

typeOfWindow = windowType(windowName)
Given the name of a window, will return if it's a label, miniconsole, userwindow or a commandline.
See also
createLabel(), openUserWindow()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • windowName:
The name used to create the window element. Use "main" for the main console


Returns
  • Window type as string ("label", "miniconsole", "userwindow", or "commandline") or nil+error if it does not exist.
Example
-- Create a Geyser label and and check its type
testLabel = Geyser.Label:new({name = "testLabel"})
display(windowType(testLabel.name))  -- displays "label"

-- the main console returns "miniconsole" because it uses the same formatting functions
display(windowType("main")) -- displays "miniconsole"

-- check for the existence of a window
local windowName = "this thing does not exist"
local ok, err = windowType(windowName)
if ok then
  -- do things with it, as it does exist.
  -- the ok variable will hold the type of window it is ("label", "commandline", etc)
else
  cecho("<red>ALERT!! window does not exist")
end
Additional development notes

wrapLine

wrapLine(windowName, lineNumber)
wraps the line specified by 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 your \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 e.g.:
selectString(line,1)
replace("")

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.

See Also: replace(), deleteLine()
Parameters
  • windowName:
The miniconsole or the main window (use main for the main window)
  • lineNumber:
The line number which you'd like re-wrapped.
Example
-- re-wrap the last line in the main window
wrapLine("main", getLineCount())