Deborah R. Fowler
Wrangle Node Syntax
Quick Reference for Beginners
Posted Oct 17 2018
Updated Nov 6 2020
A really excellent "cheat
sheet" by John Kunz https://mrkunz.com/blog/08_22_2018_VEX_Wrangle_Cheat_Sheet.html
For
those of you who are less familiar with C-like syntax or are
switching back and worth between languages this quick guide to
common syntax may be helpful.
Variables
|
float
randomNumber = rand(@ptnum); OR float
randomNumber = random(@ptnum); |
Notation
|
||||
Blocks
} |
If/then/else if ( condition ) { statements; } else { statements; } |
Looping
|
||||
Functions int myFunction() { statements; return 0; // return some value } (must be defined before used) |
Procedures (functions that
act on data but don't explicitly return a value) - now
mostly lumped under the word functions void myFunction() { statements; } |
Parameters/Arguments int myFunction( int x, float y ) { int resultVariable; // x and y are parameters and are local to the function // they take on the value of the argument return resultVariable; } To call a function (or procedure) you call its name, for example to run this piece of code int resultFromCalling = myfunction( 10, 12.6 ) |
||||
Arrays int myArray[]; remember counting starts at 0 myArray[0] = 5; |
Attributes @ fetch or creates attributes in vex snippets attributes can be created and are type specific For example i@myVar, v@myArray etc. @ptnum @numpt @P @Cd @P.x @Cd.r int @kermit or i@kermit creates an attribute |
List of hard to guess functions: rint - rounds a number to an integer value (similar to hscript round) getbbox_size, getbbox_max, (omin, center), also using "op:path" - equivalent to hscript bbox function sprintf - used for texture override for example |