Difference between revisions of "Manual:Basic Essentials"

From Mudlet
Jump to navigation Jump to search
(add "display")
Line 1: Line 1:
 
== Basic Essentials ==
 
== Basic Essentials ==
 
These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.
 
These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.
 +
  
 
===send===
 
===send===
Line 18: Line 19:
 
send("kick "..target)
 
send("kick "..target)
 
</lua>
 
</lua>
 +
  
 
===echo===
 
===echo===
Line 32: Line 34:
 
echo( "info", "Hello this is the info window" ) -- writes text to the mini console named "info" if such a window exists
 
echo( "info", "Hello this is the info window" ) -- writes text to the mini console named "info" if such a window exists
 
</lua>
 
</lua>
 +
 +
 +
===display===
 +
;display( content )
 +
:This is much like echo, in that is will show text at your screen, not send anything to anywhere. However, it also works with other objects than just text. This way, you can easily take a look at the contents of a lua table, etc.
 +
 +
See also: [[Manual:Miscellaneous Functions#display|display()]]
 +
 +
{{note}} Do not use this to display information to end-users. It may be hard to read. It is mainly useful for developing/debugging.
 +
 +
<lua>
 +
myTable = {} -- create an empty lua table
 +
myTable.foo = "Hello there" -- add a text
 +
myTable.bar = 23 -- add a number
 +
myTable.ubar = function () echo("OK") end -- add more stuff
 +
display( myTable ) -- take a look inside the table
 +
</lua>
 +
  
 
[[Category:Mudlet API]]
 
[[Category:Mudlet API]]
 
[[Category:Mudlet Manual]]
 
[[Category:Mudlet Manual]]

Revision as of 12:52, 7 October 2014

Basic Essentials

These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.


send

send( command, show on screen )
This sends "command" directly to the network layer, skipping the alias matching. The optional second argument of type boolean (print) determines if the outgoing command is to be echoed on the screen.

See also: sendAll()

Note Note: If you want your command to be checked as if it's an alias, use expandAlias() instead - send() will ignore them.

<lua> send( "Hello Jane" ) --echos the command on the screen send( "Hello Jane", true ) --echos the command on the screen send( "Hello Jane", false ) --does not echo the command on the screen

-- use a variable in the send: send("kick "..target) </lua>


echo

echo( windowName, text )
This function appends text at the end of the current line. The current cursor position is ignored. Use moveCursor() and insertText() if you want to print at a different cursor position.
If you'd like to write to a miniconsole instead of the main window, provide its name as the first argument.

Note Note: You can use \n in an echo to insert a new line.

Examples: <lua> echo( "Hello world\n" ) -- writes "Hello world" to the main screen. echo( "info", "Hello this is the info window" ) -- writes text to the mini console named "info" if such a window exists </lua>


display

display( content )
This is much like echo, in that is will show text at your screen, not send anything to anywhere. However, it also works with other objects than just text. This way, you can easily take a look at the contents of a lua table, etc.

See also: display()

Note Note: Do not use this to display information to end-users. It may be hard to read. It is mainly useful for developing/debugging.

<lua> myTable = {} -- create an empty lua table myTable.foo = "Hello there" -- add a text myTable.bar = 23 -- add a number myTable.ubar = function () echo("OK") end -- add more stuff display( myTable ) -- take a look inside the table </lua>