TextItemGetText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(Remove spaces)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Incomplete]]
__NOTOC__
 
{{Server function}}
__NOTOC__
This function returns the current text of the specified [[textitem]].
This fake function is for use with blah & blah and does blahblahblabhalbhl


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string textItemGetText ( textitem textitem )            
string textItemGetText ( textitem theTextitem )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''argumentName:''' description
*'''theTextitem:''' A valid [[textitem]].
 
===Optional Arguments===
{{OptionalArg}}
*'''argumentName2:''' descriptiona
*'''argumentName3:''' description


===Returns===
===Returns===
Returns ''true'' if blah, ''false'' otherwise.
Returns a [[string]] containing the text if the function was successful, ''false'' otherwise.


==Example==  
==Example==  
This example does...
Increment a score display. In real scripts it's of course better to keep a global 'score' variable which can be incremented directly.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
function givePoint ( thePlayer )
blabhalbalhb --abababa
    local scoretextitem = scoretextitems[thePlayer]    -- find the score text item that belongs to this player
--This line does this...
    local score = textItemGetText ( scoretextitem )    -- read the text (a score number)
mooo
    score = tostring(tonumber(score) + 1)              -- convert to number, add 1, convert to text
    textItemSetText ( scoretextitem, score )          -- put the new score on the text item
end
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{FunctionArea_Functions}}
{{Text functions}}

Latest revision as of 21:13, 29 October 2023

This function returns the current text of the specified textitem.

Syntax

string textItemGetText ( textitem theTextitem )

Required Arguments

Returns

Returns a string containing the text if the function was successful, false otherwise.

Example

Increment a score display. In real scripts it's of course better to keep a global 'score' variable which can be incremented directly.

function givePoint ( thePlayer )
    local scoretextitem = scoretextitems[thePlayer]    -- find the score text item that belongs to this player
    local score = textItemGetText ( scoretextitem )    -- read the text (a score number)
    score = tostring(tonumber(score) + 1)              -- convert to number, add 1, convert to text
    textItemSetText ( scoretextitem, score )           -- put the new score on the text item
end

See Also