Difference between revisions of "User:Missionz3r0"

From Mudlet
Jump to navigation Jump to search
(Use full echo as example)
(Update flow of function view)
Line 1: Line 1:
 +
{{TOC right}}
  
 
== Current Projects/Issues ==
 
== Current Projects/Issues ==
Line 6: Line 7:
 
* [https://github.com/Mudlet/Mudlet/issues/8864 #8864] Handle db:_migrate's assertions and transactions better
 
* [https://github.com/Mudlet/Mudlet/issues/8864 #8864] Handle db:_migrate's assertions and transactions better
  
 +
== Basic Essentials ==
 +
=== echo ===
 +
This function appends text at the end of the current line.
  
== Lua Function Playground ==
+
See also: [[Manual:Lua_Functions#moveCursor|moveCursor()]], [[Manual:Lua_Functions#insertText|insertText()]], [[Manual:Lua_Functions#cecho|cecho()]], [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#hecho|hecho()]]
===echo===
 
<div class="floatright messagebox">{{MudletVersion|1.0.0}}</div>
 
:This function appends text at the end of the current line.
 
  
;Syntax
+
<div class="messagebox mw-collapsible" style="overflow:auto; max-width:100ch;">
:<code>ok, err = echo([console_or_label_name,] text)</code>
+
  <div role="heading">'''History'''</div>
 +
  <div class="mw-collapsible-content" style="box-sizing: border-box; display:grid; gap: 0px; grid-template-columns: 8ch auto; padding-left: 1.6em">
 +
    <div role="heading">v4.8.0</div>
 +
    <div>As of Mudlet 4.8+, a single line is capped to 10,000 characters (this is when ~200 at most will fit on one line on your screen).</div>
 +
    <div role="heading">v1.0.0</div>
 +
    <div>Added in: v.1.0.0</div>
 +
  </div>
 +
</div>
  
;Parameters
+
<div role="heading" style="margin-top:1em;">'''Usage'''</div>
: <span style="font-weight:bold;">console_or_label_name?</span> ''string'' - the mini-console or label to echo to.  Default: <code>"main"</code>
+
<code style="margin-left: 1.6em;">ok, err = echo([console_or_label_name,] text)</code></dd>
: <span style="font-weight:bold;">text?</span> ''string'' - text you'd like to see printed. You can use \n in an echo to insert a new line. If you're echoing this to a label, you can also use styling to color, center, increase/decrease size of text and various other formatting options [http://doc.qt.io/qt-5/richtext-html-subset.html as listed here].
 
  
;Returns
+
<div role="heading" style="margin-top:1em;">'''Parameters'''</div>
:<span style="font-weight:bold;">ok?</span> ''bool'' - If nil, echo has errored
+
<dl style="box-sizing: border-box; display:grid; gap: 0px; grid-template-columns: 30ch 8ch auto; padding-left: 1.6em; max-width:100ch;">
:<span style="font-weight:bold;">err?</span> ''string'' - Error Message
+
    <dt style="font-weight: normal;"><code>console_or_label_name?</code></dt>
 +
    <dd>''string''</dd>
 +
    <dd>The mini-console or label to echo to.  '''Default''': <code>"main"</code></dd>
  
See also: [[Manual:Lua_Functions#moveCursor|moveCursor()]], [[Manual:Lua_Functions#insertText|insertText()]], [[Manual:Lua_Functions#cecho|cecho()]], [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#hecho|hecho()]]
+
    <dt style="font-weight: normal;"><code>text?</code></dt>
 +
    <dd>''string''</dd>
 +
    <dd>Text you'd like to see printed. You can use \n in an echo to insert a new line. If you're echoing this to a label, you can also use styling to color, center, increase/decrease size of text and various other formatting options [http://doc.qt.io/qt-5/richtext-html-subset.html as listed here].</dd>
 +
</dl>
  
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
+
<div role="heading">'''Returns'''</div>
<div style="font-weight:bold;line-height:1.6;">Technical Detail</div>
+
<dl style="box-sizing: border-box; display:grid; gap: 0px; grid-template-columns: 30ch 8ch auto; padding-left: 1.6em; max-width:100ch;">
<div class="mw-collapsible-content">
+
    <dt style="font-weight: normal;"><code>ok?</code></dt>
As of Mudlet 4.8+, a single line is capped to 10,000 characters (this is when ~200 at most will fit on one line on your screen).
+
    <dd>''boolean''</dd>
</div></div></div>
+
    <dd>If nil, echo has errored</dd>
  
 +
    <dt style="font-weight: normal;"><code>err?</code></dt>
 +
    <dd>''string''</dd>
 +
    <dd>Error Message</dd>
 +
</dl>
  
;Example
+
<div role="heading" style="margin-top:1em;">'''Example: label'''</div>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- a miniconsole example
+
-- 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>]])
 +
</syntaxhighlight>
  
 +
<div role="heading" style="margin-top:1em;">'''Example: miniconsole'''</div>
 +
<syntaxhighlight lang="lua">
 
-- first, determine the size of your screen
 
-- first, determine the size of your screen
 
local windowWidth, windowHeight = getMainWindowSize()
 
local windowWidth, windowHeight = getMainWindowSize()
Line 50: Line 77:
 
cecho("sys", "<blue:OrangeRed>and this is with a blue foreground. ")
 
cecho("sys", "<blue:OrangeRed>and this is with a blue foreground. ")
 
cecho("sys", "<bisque:BlueViolet>Lastly, this is with both a foreground and a background.\n")
 
cecho("sys", "<bisque:BlueViolet>Lastly, this is with both a foreground and a background.\n")
</syntaxhighlight>
 
 
<syntaxhighlight lang="lua">
 
-- a label example
 
 
-- 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>]])
 
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 23:06, 15 February 2026

Current Projects/Issues

  • #1149 Public functions missing documentation in wiki
    • #1640 Wiki templates for easy versions
  • #7851 Bulkify db:add
  • #8864 Handle db:_migrate's assertions and transactions better

Basic Essentials

echo

This function appends text at the end of the current line.

See also: moveCursor(), insertText(), cecho(), decho(), hecho()

History
v4.8.0
As of Mudlet 4.8+, a single line is capped to 10,000 characters (this is when ~200 at most will fit on one line on your screen).
v1.0.0
Added in: v.1.0.0
Usage

ok, err = echo([console_or_label_name,] text)

Parameters
console_or_label_name?
string
The mini-console or label to echo to. Default: "main"
text?
string
Text you'd like to see printed. You can use \n in an echo to insert a new line. If you're echoing this to a label, you can also use styling to color, center, increase/decrease size of text and various other formatting options as listed here.
Returns
ok?
boolean
If nil, echo has errored
err?
string
Error Message
Example: label
-- 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>]])
Example: miniconsole
-- first, determine the size of your screen
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)

echo("sys","Hello world!\n")
cecho("sys", "<:OrangeRed>This is random spam with the same background\n")
cecho("sys", "<blue:OrangeRed>and this is with a blue foreground. ")
cecho("sys", "<bisque:BlueViolet>Lastly, this is with both a foreground and a background.\n")