$definevariable: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎Example: change broken example at Line 25 to one which works, along other small edits, make it readable)
m (Corrected some incorrect qc script.)
Line 19: Line 19:
</source>
</source>


Here's an example of passing the variable to a macro
Here's an example of passing the variable to a macro. We pass $basefile$ to the macro to replace instances of $fightername$


<source lang=php highlight=1>
<source lang=php highlight=1>
Line 25: Line 25:


$definemacro makefighteranim fightername framerate \\
$definemacro makefighteranim fightername framerate \\
$sequence attack $baseFile$_Attack fps $framerate$ \\
$sequence attack $fightername$_Attack fps $framerate$ \\
$sequence run    $baseFile$_Run    fps $framerate$ \\
$sequence run    $fightername$_Run    fps $framerate$ \\
$sequence idle  $baseFile$_Idle  fps $framerate$ \\
$sequence idle  $fightername$_Idle  fps $framerate$ \\


$makefighteranim $baseFile$ 30 // Here we give "fighter1" from $basefile$ to the macro to be used for $fightername$ token
$makefighteranim $baseFile$ 30 // Here we give "fighter1" from $basefile$ to the macro to be used for $fightername$ token

Revision as of 11:04, 5 May 2024

The $definevariable QC command creates a Wikipedia icon variable. The variable's name, if surrounded by $, will be substituted by its value whenever encountered.

Note.pngNote:Variables do not work within "quote blocks"!
Note.pngNote:Variables declared out of the scope of a macro can't be used within the macro. You can pass the data on to the macro by instead using it as a token of the macro and retrieving it that way.
Note.pngNote:If you define the same variable twice, the compiler will use the first one it finds and drop the second one.
Icon-Bug.pngBug:Similar tokens prefixes causes to the compiler parser: merge, swap or even ignore it variable values. This doesn't happen with Source Filmmaker Source Filmmaker and Garry's Mod Garry's Mod  [todo tested in ?]
Icon-Bug.pngBug:tokens cannot be pushed further than 3 $include levels  [todo tested in ?]

This command is like a 'lite' version of $definemacro.

Example

$definevariable baseFile "fighter1"

$sequence attack $baseFile$_Attack // results in -> fighter1_Attack when resolved
$sequence run    $baseFile$_Run    // results in -> fighter1_Run    when resolved
$sequence idle   $baseFile$_Idle   // results in -> fighter1_Idle   when resolved

Here's an example of passing the variable to a macro. We pass $basefile$ to the macro to replace instances of $fightername$

$definevariable baseFile "fighter1"

$definemacro makefighteranim fightername framerate \\
$sequence attack $fightername$_Attack fps $framerate$ \\
$sequence run    $fightername$_Run    fps $framerate$ \\
$sequence idle   $fightername$_Idle   fps $framerate$ \\

$makefighteranim $baseFile$ 30 // Here we give "fighter1" from $basefile$ to the macro to be used for $fightername$ token