Enlarge the font size of the script editor: Ctrl+Shift+> .
Variables
int $rad=2;
sphere -radius $rad;
Number types for variables: int, float, string, vector, and matrix.
1. For string, concatenate is done by "+"; the number of characters in the string is calculated from size(string).
2. Vector variables allow you to store three floating-point values. Typically, used to store positions and directions.
sphere;
vector $p=<<10.0, 5.0, 2.5>>;
move -absolute ($p.x) ($p.y) ($p.z);
3. To access the vector component they must be enclosed in parentheses.
4. You cannot directly assign a number to a vector's component. To change x component of $p,
$p=<<3.0, $p.y, $p.z>>;
print $p;
//Result: 3.0 5.0 2.5
5. Array type: the indices are base 0. The total number of elements in the array can be got from size function. Also you can add new element directly to the array, no matter exceeding the initial size. To remove the array and free the memory, use clear function. However, no direct way to remove elements one by one from a array.
6. Array is only one-dimension, cannot be two dimensions or higher.
7. Matrix is two dimension, cannot be resized after initialised. Both the two dimensions' index must be explicitly declared.
matrix $m[2][4] = << 3 , 4 , 6 , 7 " 3 , 9 , 0 , 1 >>;
p r i n t ( $m[O][O] )" / / Result. 3
p r i n t ( $m[1][3] )" / / Result. 1
8. You can access the element outside of the initial range for array, but cannot for matrix.
9. Once a variable's type is set, either explicitly or implicitly, it cannot be changed.
1044

被折叠的 条评论
为什么被折叠?



