Difference between revisions of "User:Missionz3r0"

From Mudlet
Jump to navigation Jump to search
(Add borders lines for params and returns)
(Float API details to the right)
Line 9: Line 9:
 
== Basic Essentials ==
 
== Basic Essentials ==
 
=== echo ===
 
=== echo ===
This function appends text at the end of the current line.
+
<div class="mw-collapsible" style="border:1px solid; box-sizing: border-box; float:right; min-width: min(100%, 80ch); max-width: 80ch; overflow:auto; padding:1ch">
 +
  <div role="heading">'''API'''</div>
 +
  <div class="mw-collapsible-content" style="border-top: 1px solid; margin-top:1ch; padding-top:1ch">
 +
    <div role="heading" style="margin-top:1ch;">'''Usage'''</div>
 +
    <code style="margin-left: 1.6em;">ok, err = echo([console_or_label_name,] text)</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()]]
+
    <div role="heading" style="margin-top:1ch;">'''Parameters'''</div>
 +
    <dl style="box-sizing:border-box; display:grid; grid-gap:0px; grid-template-columns:30ch 9ch auto; ">
 +
        <dt style="border-right: 1px solid; margin:0 0 8px 0; font-weight:normal; padding:0 0.8ch 1px 1.6em;"><code>console_or_label_name?</code></dt>
 +
        <dd style="border-right: 1px solid; margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">''string''</dd>
 +
        <dd style="margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">The mini-console or label to echo to.  '''Default''': <code>"main"</code></dd>
  
<div class="messagebox mw-collapsible" style="overflow:auto; max-width:100ch;">
+
        <dt style="border-right: 1px solid; margin:0; font-weight:normal; padding:0 0.8ch 1px 1.6em;"><code>text?</code></dt>
  <div role="heading">'''History'''</div>
+
        <dd style="border-right: 1px solid; margin:0 ; padding:0 0.8ch 1px 0.8ch;">''string''</dd>
  <div class="mw-collapsible-content" style="box-sizing: border-box; display:grid; grid-gap:1px; grid-template-columns: 8ch auto; padding-left: 1.6em">
+
        <dd style="margin:0; padding:0 0.8ch 1px 0.8ch;">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>
    <div role="heading">v4.8.0</div>
+
    </dl>
    <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>
 
  
<div role="heading" style="margin-top:1em;">'''Usage'''</div>
+
    <div role="heading" style="margin-top:1ch;">'''Returns'''</div>
<code style="margin-left: 1.6em;">ok, err = echo([console_or_label_name,] text)</code></dd>
+
    <dl style="box-sizing:border-box; display:grid; grid-gap:0px; grid-template-columns:30ch 9ch auto;">
 +
        <dt style="border-right: 1px solid; margin:0 0 8px 0; font-weight:normal; padding:0 0.8ch 1px 1.6em;"><code>ok?</code></dt>
 +
        <dd style="border-right: 1px solid; margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">''boolean''</dd>
 +
        <dd style="margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">If nil, echo has errored</dd>
  
<div role="heading" style="margin-top:1em;">'''Parameters'''</div>
+
        <dt style="border-right: 1px solid; margin:0; font-weight:normal; padding:0 0.8em 1px 1.6em;"><code>err?</code></dt>
<dl style="box-sizing:border-box; display:grid; grid-gap:0px; grid-template-columns:30ch 9ch auto; max-width:100ch;">
+
        <dd style="border-right: 1px solid; margin:0 ; padding:0 0.8ch 1px 0.8ch;">''string''</dd>
    <dt style="border-right: 1px solid; margin:0 0 8px 0; font-weight:normal; padding:0 0.8ch 1px 1.6em;"><code>console_or_label_name?</code></dt>
+
        <dd style="margin:0; padding-left:.8ch;">Error Message</dd>
    <dd style="border-right: 1px solid; margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">''string''</dd>
+
    </dl>
    <dd style="margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">The mini-console or label to echo to.  '''Default''': <code>"main"</code></dd>
 
  
     <dt style="border-right: 1px solid; margin:0; font-weight:normal; padding:0 0.8ch 1px 1.6em;"><code>text?</code></dt>
+
     <div role="heading" style="margin-top:1ch;">'''History'''</div>
    <dd style="border-right: 1px solid; margin:0 ; padding:0 0.8ch 1px 0.8ch;">''string''</dd>
+
    <dl style="box-sizing:border-box; display:grid; grid-gap:0px; grid-template-columns:9ch auto;">
    <dd style="margin:0; padding:0 0.8ch 1px 0.8ch;">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>
+
        <dt style="border-right: 1px solid; margin:0 0 8px 0; font-weight:normal; padding:0 0.8ch 1px 1.6em;">v4.8.0</dt>
</dl>
+
        <dd style="margin:0 0 8px 0; padding-left:.8ch;>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>
  
<div role="heading">'''Returns'''</div>
+
        <dt style="border-right: 1px solid; margin:0; font-weight:normal; padding:0 0.8em 1px 1.6em;">v1.0.0</dt>
<dl style="box-sizing:border-box; display:grid; grid-gap:0px; grid-template-columns:30ch 9ch auto; max-width:100ch;">
+
        <dd style="margin:0; padding-left:.8ch;>Added in: v.1.0.0</dd>
    <dt style="border-right: 1px solid; margin:0 0 8px 0; font-weight:normal; padding:0 0.8ch 1px 1.6em;"><code>ok?</code></dt>
+
     </dl>
    <dd style="border-right: 1px solid; margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">''boolean''</dd>
+
  </div>
     <dd style="margin:0 0 8px 0; padding:0 0.8ch 1px 0.8ch;">If nil, echo has errored</dd>
+
</div>
 +
This function appends text at the end of the current line.
  
    <dt style="border-right: 1px solid; margin:0; font-weight:normal; padding:0 0.8em 1px 1.6em;"><code>err?</code></dt>
+
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()]]
    <dd style="border-right: 1px solid; margin:0 ; padding:0 0.8ch 1px 0.8ch;">''string''</dd>
 
    <dd style="margin:0; padding-left:.8ch;">Error Message</dd>
 
</dl>
 
  
 
<div role="heading" style="margin-top:1em;">'''Example: label'''</div>
 
<div role="heading" style="margin-top:1em;">'''Example: label'''</div>

Revision as of 20:00, 17 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

API
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
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

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

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

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")