TextCreateDisplay: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">textdisplay textCreateDisplay ()</syntaxhighlight>
<syntaxhighlight lang="lua">textdisplay textCreateDisplay()</syntaxhighlight>


==Required Arguments==
==Required Arguments==
Line 11: Line 11:
==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function MyTestTextFunction ()
function showTextDisplay ( player, command )
myTextDisplay = textCreateDisplay ()                           -- create a text display
  local serverDisplay = textCreateDisplay()                             -- create a text display
textDisplayAddObserver ( myTextDisplay, myPlayer )             -- make it visible to a player
  textDisplayAddObserver ( serverDisplay, player )                     -- make it visible to a player
myTextItem = textCreateTextItem ( "Hello world!", 0.5, 0.5 )    -- create a text item for the display
  local serverText = textCreateTextItem ( "Hello world!", 0.5, 0.5 )    -- create a text item for the display
textDisplayAddText ( myTextDisplay, myTextItem )               -- add it to the display so it is displayed
  textDisplayAddText ( serverDisplay, serverText )                     -- add it to the display so it is displayed
end
end
addCommandHandler( "showText", showTextDisplay )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Text functions}}
{{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