Qsprintf: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
'''qsprintf''' <quote1> <quote2> <gamevar1> [gamevar2] [gamevar3] ... [gamevar32]
'''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.
Line 8: Line 8:
  gamevar TEMP 0 1
  gamevar TEMP 0 1
  definequote 254 PLACEHOLDER
  definequote 254 PLACEHOLDER
definequote  7 WASTED!
definequote 12 USED STEROIDS
   
   
  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 254 ALIENS KILLED: %ld   // Redefine a placeholder quote
  redefinequote 254 ALIENS KILLED: %d   // Redefine a placeholder quote
  '''qsprintf''' 254 254 TEMP                  // Place our variable into the %ld string
  '''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!
  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
  endevent



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