Qsprintf: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
I have verified, and there is no need for use more than one single gamevar
No edit summary
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
qsprintf <quote1> <quote2> <gamevar> <gamevar> ...
'''qsprintf''' <destination quote> <source quote> <parameter 1> [parameter 2] [parameter 3] ... [parameter 32]


Copies the text of <quote2> to <quote1>, replacing all variable placeholders %ld with their gamevar values in relative order.
Copies the text of <source quote> to <destination quote>, replacing in order each instance of '''%d''' ('''%ld''' works too) with a gamevar passed in its parameter position, and each instance of '''%s''' with a quote in its parameter position.


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.
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:
<pre>
gamevar TEMP 0 1
definequote 254 PLACEHOLDER


onevent EVENT_DISPLAYREST
gamevar TEMP 0 1
getplayer[THISACTOR].actors_killed TEMP // Get the number of kills the player has
definequote 254 PLACEHOLDER
definequote  7 WASTED!
definequote 12 USED STEROIDS
onevent EVENT_DISPLAYREST
getplayer[THISACTOR].actors_killed TEMP // Get the number of kills the player has
redefinequote 254 ALIENS KILLED: %d    // Redefine a placeholder quote
'''qsprintf''' 254 254 TEMP                  // Place our variable into the %d string
gametext STARTALPHANUM 10 10 254 0 0 0 ZERO ZERO xdim ydim // And print to the upper left!
redefinequote 254 %s! %s
'''qsprintf''' 254 254 12 7
quote 254 // print: "USED STEROIDS! WASTED!"
endevent


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
</pre>


[[Category:EDuke32 specific commands]]
[[Category:EDuke32 specific commands]]
[[Category:String manipulation]]
[[Category:String manipulation]]

Latest revision as of 21:49, 12 August 2011

qsprintf <destination quote> <source quote> <parameter 1> [parameter 2] [parameter 3] ... [parameter 32]

Copies the text of <source quote> to <destination quote>, replacing in order each instance of %d (%ld works too) with a gamevar passed in its parameter position, and each instance of %s with a quote in its parameter position.

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.


gamevar TEMP 0 1
definequote 254 PLACEHOLDER
definequote  7 WASTED!
definequote 12 USED STEROIDS 

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

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

redefinequote 254 %s! %s
qsprintf 254 254 12 7
quote 254 // print: "USED STEROIDS! WASTED!"

endevent