Format String
Halo: Reach's scripting engine supports the display of "format strings." A format string can be a simple piece of text, but it can also include little placeholders that can be replaced with other values when the string is displayed. Up to two additional values can be provided after the format string itself.
The known format codes are:
- %p
- Placeholder for a player. Prints their gamertag.
- %n
- Placeholder for a number.
- %s
- Placeholder for any other value that should display as text.
Variables with the following types can be substituted into the string:
- number
- Displays normally.
- object
- Displays the name of the object; however, most objects don't have actual names defined and will show "unknown".
- player
- Displays the player's Xbox LIVE Gamertag.
- team
- Displays as a blank, zero-length value.
- timer
- Displays minutes and seconds, separated with a colon and each padded to two digits.
Here's an example of how to use format strings: this code, taken from Slayer, displays the number of points needed to win if the game variant has a score limit.
for each player do -- round card if game.score_to_win != 0 and game.teams_enabled == 1 then current_player.set_round_card_title("Kill players on the enemy team.\r\n%n points to win.", game.score_to_win) end if game.score_to_win != 0 and game.teams_enabled == 0 then current_player.set_round_card_title("Score points by killing other players.\r\n%n points to win.", game.score_to_win) end if game.score_to_win == 0 and game.teams_enabled == 1 then current_player.set_round_card_title("Kill players on the enemy team.") end if game.score_to_win == 0 and game.teams_enabled == 0 then current_player.set_round_card_title("Score points by killing other players.") end end