TextItemGetText: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function givePoint ( player )
function givePoint ( player )
     local textitem = scoretextitems[player]
     local scoretextitem = scoretextitems[player]
     local score = textItemGetText ( textitem )
     local score = textItemGetText ( scoretextitem )
     score = tostring(tonumber(score) + 1)
     score = tostring(tonumber(score) + 1)
     textItemSetText ( textitem, score )
     textItemSetText ( scoretextitem, score )
end
end
</syntaxhighlight>
</syntaxhighlight>

Revision as of 17:48, 15 August 2007

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 just keep a 'score' variable and only use textItemSetText.

function givePoint ( player )
    local scoretextitem = scoretextitems[player]
    local score = textItemGetText ( scoretextitem )
    score = tostring(tonumber(score) + 1)
    textItemSetText ( scoretextitem, score )
end

See Also