OutputConsole: Difference between revisions
Jump to navigation
Jump to search
(→Syntax) |
|||
Line 13: | Line 13: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua">root = getRootElement () | <syntaxhighlight lang="lua">root = getRootElement () | ||
addCommandHandler ( "onPlayerConsole", root, "onConsole" ) | |||
function onConsole ( message ) | function onConsole ( message ) | ||
local command = gettok(message, 1, 32) --The varible "command" equals text a player types in the console | local command = gettok(message, 1, 32) --The varible "command" equals text a player types in the console |
Revision as of 02:26, 20 May 2006
This outputs the specified text string to the console window (accessed with F8 or ~ key). It can be specified as a message to certain player(s) or all players.
Syntax
bool outputConsole ( string text, [ element visibleTo=getrootelement() ] )
Required Arguments
- text: The text string that you wish to send to the console window
Optional Arguments
- visibleTo: This specifies who the chat is visible to. Any players in this element will see the chat message. See visibility.
Example
root = getRootElement () addCommandHandler ( "onPlayerConsole", root, "onConsole" ) function onConsole ( message ) local command = gettok(message, 1, 32) --The varible "command" equals text a player types in the console if (command == "!public") then --If players typed text equals !public outputChatBox ( "Public console message" ) --Display console message to all players elseif (command == "!private") then --If players typed text equals !private outputChatBox ( "Private console message", source ) --Send message to whoever entered the text !private end end