$definevariable: Difference between revisions
Jump to navigation
Jump to search
Note:Variables do not work within "quote blocks"!
Note: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:If you define the same variable twice, the compiler will use the first one it finds and drop the second one.
Bug:Similar tokens prefixes causes to the compiler parser: merge, swap or even ignore it variable values. This doesn't happen with
Source Filmmaker and
Garry's Mod [todo tested in ?]
(point limitations) |
m (Clarified language and provided an example of passing a variable to a macro) |
||
Line 1: | Line 1: | ||
The '''$definevariable''' [[QC command]] creates a {{wiki|variable}}. The variable's name, if surrounded by <code>$</code> | The '''$definevariable''' [[QC command]] creates a {{wiki|variable}}. The variable's name, if surrounded by <code>$</code>, will be substituted by its value whenever encountered. | ||
{{note|Variables do not work within "quote blocks"!}} | {{note|Variables do not work within "quote blocks"!}} | ||
{{note|Variables | {{note|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|If you define the same variable twice, the compiler will use the first one it finds and drop the second one.}} | {{note|If you define the same variable twice, the compiler will use the first one it finds and drop the second one.}} | ||
{{bug|Similar tokens prefixes causes to the compiler parser: merge, swap or even ignore it variable values. This doesn't happen with {{sfm|4}} and {{gmod|4}}}} | {{bug|Similar tokens prefixes causes to the compiler parser: merge, swap or even ignore it variable values. This doesn't happen with {{sfm|4}} and {{gmod|4}}}} | ||
Line 14: | Line 14: | ||
$definevariable baseFile "fighter1" | $definevariable baseFile "fighter1" | ||
$sequence attack $baseFile$_Attack | $sequence attack $baseFile$_Attack // results in -> fighter1_Attack when resolved | ||
$sequence run $baseFile$_Run | $sequence run $baseFile$_Run | ||
$sequence idle $baseFile$_Idle | $sequence idle $baseFile$_Idle | ||
</source> | |||
Here's an example of passing the variable to a macro | |||
<source lang=php highlight=1> | |||
$definevariable baseFile "fighter1" | |||
$definemacro makefighteranim fightername framerate \\ | |||
$sequence attack $baseFile$_Attack ( fps $framerate$ } \\ | |||
$sequence run $baseFile$_Run { fps $framerate$ } \\ | |||
$sequence idle $baseFile$_Idle { fps $framerate$ } \\ | |||
$makefighteranim $basefile$ 30 | |||
</source> | </source> | ||
[[Category:QC Commands|definevariable]]__NOTOC__ | [[Category:QC Commands|definevariable]]__NOTOC__ |
Revision as of 20:06, 7 March 2024
The $definevariable QC command creates a variable. The variable's name, if surrounded by
$
, will be substituted by its value whenever encountered.






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
$sequence idle $baseFile$_Idle
Here's an example of passing the variable to a macro
$definevariable baseFile "fighter1"
$definemacro makefighteranim fightername framerate \\
$sequence attack $baseFile$_Attack ( fps $framerate$ } \\
$sequence run $baseFile$_Run { fps $framerate$ } \\
$sequence idle $baseFile$_Idle { fps $framerate$ } \\
$makefighteranim $basefile$ 30