OutputChatBox: Difference between revisions
Jump to navigation
Jump to search
Line 19: | Line 19: | ||
==Example== | ==Example== | ||
This example displays a chat message to all users. | '''Example 1:''' This example displays a chat message to all users. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
x = 5 | x = 5 | ||
Line 27: | Line 27: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This example displays a chat message to a single user called ''someguy''. | '''Example 2:''' This example displays a chat message to a single user called ''someguy''. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Find the player element for the player called 'someguy' | -- Find the player element for the player called 'someguy' |
Revision as of 16:10, 18 May 2006
This outputs the specified text string to the chat window. Every player can see it - assuming they have the chat box visible at the time.
Syntax
bool outputChatBox ( string text, [ element visibleTo=getRootElement(), int r=255, int g=255, int b=255 ] )
Required Arguments
- text: The text string that you wish to send to the chat window.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- visibleTo: This specifies who the chat is visible to. Any players in this element will see the chat message. See visibility.
- r: The amount of red in the color of the text. Default value is 255.
- g: The amount of green in the color of the text. Default value is 255.
- b: The amount of blue in the color of the text. Default value is 255.
Returns
Returns true if the message was displayed successfully. Returns false if invalid arguments are specified.
Example
Example 1: This example displays a chat message to all users.
x = 5 y = 10 -- Displays the message outputChatBox ( "I have ", x, " apples and ", y, " oranges." )
Example 2: This example displays a chat message to a single user called someguy.
-- Find the player element for the player called 'someguy' myPlayer = getPlayerFromNick ( "someguy" ) -- If a player was found called 'someguy' then... if ( myPlayer ~= false ) then x = 5 y = 10 -- Display the message outputChatBox ( "I have ", x, " apples and ", y, " oranges.", myPlayer ) end