Difference between revisions of "User:Missionz3r0"

From Mudlet
Jump to navigation Jump to search
(Delete Parameters and Returns sections)
(Use full echo as example)
Line 7: Line 7:
  
  
== Lua Function Infobox Playground ==
+
== Lua Function Playground ==
<div class="floatright messagebox">
+
===echo===
 +
<div class="floatright messagebox">{{MudletVersion|1.0.0}}</div>
 +
:This function appends text at the end of the current line.
 +
 
 
;Syntax
 
;Syntax
 
:<code>ok, err = echo([console_or_label_name,] text)</code>
 
:<code>ok, err = echo([console_or_label_name,] text)</code>
  
;Version
+
;Parameters
:{{MudletVersion|1.0.0}}
+
: <span style="font-weight:bold;">console_or_label_name?</span> ''string'' - the mini-console or label to echo to.  Default: <code>"main"</code>
</div>
+
: <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].
Reiciendis rerum ipsum tempora itaque est. Est doloribus quis tempora delectus voluptatum porro. Et quo reiciendis quasi. Necessitatibus cupiditate ut facere voluptatibus facere doloremque. Odit officiis atque vitae.
+
 
 +
;Returns
 +
:<span style="font-weight:bold;">ok?</span> ''bool'' - If nil, echo has errored
 +
:<span style="font-weight:bold;">err?</span> ''string'' - Error Message
 +
 
 +
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 class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
<div style="font-weight:bold;line-height:1.6;">Technical Detail</div>
 +
<div class="mw-collapsible-content">
 +
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></div>
 +
 
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- a miniconsole example
 +
 
 +
-- first, determine the size of your screen
 +
local windowWidth, windowHeight = getMainWindowSize()
  
Corrupti nam debitis corrupti accusamus occaecati reprehenderit cupiditate. Cum non voluptatum quisquam natus ratione fugit quis in. Quasi non ipsa repellendus et.
+
-- 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)
  
Cumque quod fugiat ex est laudantium ducimus numquam. Quia qui optio a. Perspiciatis ea placeat eos non iure provident. Nostrum eum iusto eos nam sapiente ducimus quidem eveniet. Eos dignissimos velit qui. Repellendus eos et ullam et nisi earum.
+
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")
 +
</syntaxhighlight>
  
Animi et beatae et at rerum. Itaque qui iste inventore. Repudiandae magni incidunt voluptatem velit. Aut neque nihil accusamus deleniti ullam fuga. Sint aliquam eveniet sunt aut. Et tempore vitae explicabo nihil.
+
<syntaxhighlight lang="lua">
 +
-- a label example
  
Quis ut eum perferendis unde rem et. Consequatur atque repellat dolor vel. Voluptatem fugit labore expedita perspiciatis suscipit rem.
+
-- 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>

Revision as of 04:09, 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


Lua Function Playground

echo

Mudlet VersionAvailable in Mudlet1.0.0+
This function appends text at the end of the current line.
Syntax
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? bool - If nil, echo has errored
err? string - Error Message

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

Technical Detail

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


Example
-- a miniconsole example

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