TextItemSetText: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 7: | Line 7: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theTextitem:''' An existing text item that was previously created with [[ | *'''theTextitem:''' An existing text item that was previously created with [[textCreateTextItem]] | ||
*'''text:''' The new text for the text item | *'''text:''' The new text for the text item | ||
Line 13: | Line 13: | ||
Here, it is being used to update a scoreboard: | Here, it is being used to update a scoreboard: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function | function updateScoreOnWasted ( ammo, killer, weapon ) | ||
if ( killer ~= false) then | if ( killer ~= false) then -- Check to see if anything killed the player | ||
local killerTeam = getTeamName ( getPlayerTeam(killer) ) | local killerTeam = getTeamName ( getPlayerTeam(killer) ) | ||
if ( killerTeam == "grove" ) then | if ( killerTeam == "grove" ) then -- if a Grove player scored the kill | ||
groveteamscore = groveteamscore + 1 -- Grove gets 1 point | groveteamscore = groveteamscore + 1 -- Grove gets 1 point | ||
textItemSetText ( scoregrove, tostring(groveteamscore) ) -- Update scoreboard. | textItemSetText ( scoregrove, tostring(groveteamscore) ) -- Update scoreboard. | ||
elseif ( killerTeam == "balla" ) then | elseif ( killerTeam == "balla" ) then -- if a Balla player scored the kill | ||
ballateamscore = ballateamscore + 1 -- Ballas get 1 point | ballateamscore = ballateamscore + 1 -- Ballas get 1 point | ||
textItemSetText ( scoreballa, tostring(ballateamscore) ) -- Update scoreboard. | textItemSetText ( scoreballa, tostring(ballateamscore) ) -- Update scoreboard. | ||
Line 25: | Line 25: | ||
end | end | ||
end | end | ||
addEventHandler ( "onPlayerWasted", | addEventHandler ( "onPlayerWasted", root, updateScoreOnWasted ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Text functions}} | {{Text functions}} |
Latest revision as of 07:53, 4 November 2020
Overwrites a previously created text item with the specified text.
Syntax
void textItemSetText ( textitem theTextitem, string text )
Required Arguments
- theTextitem: An existing text item that was previously created with textCreateTextItem
- text: The new text for the text item
Example
Here, it is being used to update a scoreboard:
function updateScoreOnWasted ( ammo, killer, weapon ) if ( killer ~= false) then -- Check to see if anything killed the player local killerTeam = getTeamName ( getPlayerTeam(killer) ) if ( killerTeam == "grove" ) then -- if a Grove player scored the kill groveteamscore = groveteamscore + 1 -- Grove gets 1 point textItemSetText ( scoregrove, tostring(groveteamscore) ) -- Update scoreboard. elseif ( killerTeam == "balla" ) then -- if a Balla player scored the kill ballateamscore = ballateamscore + 1 -- Ballas get 1 point textItemSetText ( scoreballa, tostring(ballateamscore) ) -- Update scoreboard. end end end addEventHandler ( "onPlayerWasted", root, updateScoreOnWasted )
See Also
- textCreateDisplay
- textCreateTextItem
- textDestroyDisplay
- textDestroyTextItem
- textDisplayAddObserver
- textDisplayAddText
- textDisplayGetObservers
- textDisplayIsObserver
- textDisplayRemoveObserver
- textDisplayRemoveText
- textItemGetColor
- textItemGetPosition
- textItemGetPriority
- textItemGetScale
- textItemGetText
- textItemSetColor
- textItemSetPosition
- textItemSetPriority
- textItemSetScale
- textItemSetText