Qsprintf: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
I have verified, and there is no need for use more than one single gamevar
Line 2: Line 2:


Copies the text of <quote2> to <quote1>, replacing all variable placeholders %ld with their gamevar values in relative order.
Copies the text of <quote2> to <quote1>, replacing all variable placeholders %ld with their gamevar values in relative order.
You can use a single quote for both placeholders. Also, you can use a single quote to display many different texts at the same time, since using qsprintf in a quote doesn't alter the text displayed by a [[gametext]] command used before with that quote.


An example:
An example:
Line 7: Line 9:
gamevar TEMP 0 1
gamevar TEMP 0 1
definequote 254 PLACEHOLDER
definequote 254 PLACEHOLDER
definequote 255 PLACEHOLDER


onevent EVENT_DISPLAYREST
onevent EVENT_DISPLAYREST
getplayer[THISACTOR].actors_killed TEMP // Get the number of kills the player has
getplayer[THISACTOR].actors_killed TEMP // Get the number of kills the player has


redefinequote 255 ALIENS KILLED: %ld    // Redefine a placeholder quote
redefinequote 254 ALIENS KILLED: %ld    // Redefine a placeholder quote
qsprintf 254 255 TEMP                  // Place our variable into the %ld string
qsprintf 254 254 TEMP                  // Place our variable into the %ld string
gametext STARTALPHANUM 10 10 254 0 0 ZERO ZERO xdim ydim // And print to the upper left!
gametext STARTALPHANUM 10 10 254 0 0 ZERO ZERO xdim ydim // And print to the upper left!
endevent
endevent

Revision as of 04:56, 9 April 2008

qsprintf <quote1> <quote2> <gamevar> <gamevar> ...

Copies the text of <quote2> to <quote1>, replacing all variable placeholders %ld with their gamevar values in relative order.

You can use a single quote for both placeholders. Also, you can use a single quote to display many different texts at the same time, since using qsprintf in a quote doesn't alter the text displayed by a gametext command used before with that quote.

An example:

gamevar TEMP 0 1
definequote 254 PLACEHOLDER

onevent EVENT_DISPLAYREST
getplayer[THISACTOR].actors_killed TEMP // Get the number of kills the player has

redefinequote 254 ALIENS KILLED: %ld    // Redefine a placeholder quote
qsprintf 254 254 TEMP                   // Place our variable into the %ld string
gametext STARTALPHANUM 10 10 254 0 0 ZERO ZERO xdim ydim // And print to the upper left!
endevent