$definemacro: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(cleanup and more info)
Line 1: Line 1:
$definemacro (macroname) [named parameters ...]
Defines a string substitution macro. A macro can be used as a short hand way to specify other QC commands. The macro creates a block a named block of text, that when referred to will virtually insert that text into the QC file, along with replacing the named parameters with the specified values.
* Defines a named macro that can be use as a short hand way to specify other QC commands. The macro creates a block a named block of text, that when referred to will virtually insert that text into the QC file, along with replacing the named parameters with the specified values.  


Example:
== Syntax ==
      $definemacro makeidlenoise idleNoiseName fileName \\
      $sequence $idleNoiseName$ {\\
          $fileName$ \\
          subtract $idleNoiseName$ 0 \\
          iklock lfoot 1 0 iklock rfoot 1 0 \\
          delta \\
          hidden \\
          realtime \\
      }
      $makeidlenoise idleNoise03 "Idle03"
      $makeidlenoise idleNoise04 "Idle04_v32"


===alternative version ...===
$definemacro (macroname) [arg_name1] [arg_name2] [...] \\


$definemacro (macroname) [arg_name1] [arg_name2] […] \\
* Defines a string substation macro.  
* Defines a string substation macro.  
* The macro definition begins on the next line, and all subsequent lines that end with \\ (two backslashes).  
* The macro definition begins on the next line, and all subsequent lines that end with \\ (two backslashes).  
* Arguments are referenced by surrounding them with $’s (i.e. $arg_name1$ ), and can be embedded inside of other words.  
* Arguments are referenced by surrounding them with $’s (i.e. <code>$arg_name1$</code> ), and can be embedded inside of other words.  
* To use the macro, type $macroname and the next N tokens will be taken as arguments.  
* To use the macro, type <code>$macroname</code> and the next N tokens will be taken as arguments.
* For example:
 
$definemacro testmacro seqname filename endframe \\
== Examples ==
$sequence $seqname$01 $filename$ { \\
 
frames 0 $endframe$ \\
$definemacro testmacro seqname filename endframe \\
subtract $seqname$ 0 delta \\
$sequence $seqname$01 $filename$ { \\
weightlist justbody \\
    frames 0 $endframe$ \\
}
    subtract $seqname$ 0 delta \\
    weightlist justbody \\
}
 
Then, to use the macro, do:
Then, to use the macro, do:
$testmacro small_flinch "npc flinch 01" 20
$testmacro small_flinch "npc flinch 01" 20


Another example:


$definemacro makeidlenoise idleNoiseName fileName \\
$sequence $idleNoiseName$ {\\
      $fileName$ \\
      subtract $idleNoiseName$ 0 \\
      iklock lfoot 1 0 iklock rfoot 1 0 \\
      delta \\
      hidden \\
      realtime \\
}
$makeidlenoise idleNoise03 "Idle03"
$makeidlenoise idleNoise04 "Idle04_v32"


== See also ==
* [[$definevariable]]


[[Category:QC Commands]]
[[Category:QC Commands|definemacro]]__NOTOC__

Revision as of 14:36, 28 April 2008

Defines a string substitution macro. A macro can be used as a short hand way to specify other QC commands. The macro creates a block a named block of text, that when referred to will virtually insert that text into the QC file, along with replacing the named parameters with the specified values.

Syntax

$definemacro (macroname) [arg_name1] [arg_name2] [...] \\
  • Defines a string substation macro.
  • The macro definition begins on the next line, and all subsequent lines that end with \\ (two backslashes).
  • Arguments are referenced by surrounding them with $’s (i.e. $arg_name1$ ), and can be embedded inside of other words.
  • To use the macro, type $macroname and the next N tokens will be taken as arguments.

Examples

$definemacro testmacro seqname filename endframe \\
$sequence $seqname$01 $filename$ { \\
    frames 0 $endframe$ \\
    subtract $seqname$ 0 delta \\
    weightlist justbody \\
}

Then, to use the macro, do:

$testmacro small_flinch "npc flinch 01" 20

Another example:

$definemacro makeidlenoise idleNoiseName fileName \\
$sequence $idleNoiseName$ {\\
     $fileName$ \\
     subtract $idleNoiseName$ 0 \\
     iklock lfoot 1 0 iklock rfoot 1 0 \\
     delta \\
     hidden \\
     realtime \\
}

$makeidlenoise idleNoise03 "Idle03"
$makeidlenoise idleNoise04 "Idle04_v32"

See also