TextCreateDisplay: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(18 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==Description==
__NOTOC__
A text display is like a canvas that can contain many items of text. Each display can be seen by multiple observers (players) and each player can see multiple displays. For example, you could have a display that showed a score, and a display that showed information specific to one team, such as the location of the flag. Every player would be an observer of the first display and each team would have their own display that its players would be observers of.
{{Server function}}
A [[textdisplay|text display]] is like a canvas that can contain many [[textitem|items of text]]. Each display can be seen by multiple observers (players) and each player can see multiple displays.


==Syntax==
==Syntax==
[[textdisplay]] [[textCreateDisplay]] ()
<syntaxhighlight lang="lua">textdisplay textCreateDisplay()</syntaxhighlight>
 
==Required Arguments==
''This function has no arguments.''


==Example==
==Example==
textDisplay = [[textCreateDisplay]] ();
<syntaxhighlight lang="lua">
[[textDisplayAddObserver]] ( textDisplay, player );
function showTextDisplay ( player, command )
textItem = [[textCreateTextItem]] ( "Hello world!", 0.5, 0.5 );
  local serverDisplay = textCreateDisplay()                             -- create a text display
[[textDisplayAddText]] ( textDisplay, textItem );
  textDisplayAddObserver ( serverDisplay, player )                     -- make it visible to a player
  local serverText = textCreateTextItem ( "Hello world!", 0.5, 0.5 )   -- create a text item for the display
  textDisplayAddText ( serverDisplay, serverText )                     -- add it to the display so it is displayed
end
addCommandHandler( "showText", showTextDisplay )
</syntaxhighlight>
 
==See Also==
{{Text functions}}

Latest revision as of 00:39, 21 January 2011

A text display is like a canvas that can contain many items of text. Each display can be seen by multiple observers (players) and each player can see multiple displays.

Syntax

textdisplay textCreateDisplay()

Required Arguments

This function has no arguments.

Example

function showTextDisplay ( player, command )
   local serverDisplay = textCreateDisplay()                             -- create a text display
   textDisplayAddObserver ( serverDisplay, player )                      -- make it visible to a player
   local serverText = textCreateTextItem ( "Hello world!", 0.5, 0.5 )    -- create a text item for the display
   textDisplayAddText ( serverDisplay, serverText )                      -- add it to the display so it is displayed
end
addCommandHandler( "showText", showTextDisplay )

See Also