Creating and using local variables – Apple Shake 4 User Manual

Page 938

Advertising
background image

938

Chapter 31

Expressions and Scripting

When referring to a variable from a different node, place the node name before the
variable:

node_name.width

In some cases, problems may occur. For example, in a Resize node, if you set the Resize
equal to width/2, you potentially cause a loop because it is changing width based upon
a value that is looking for the width. To solve this, Shake always refers to the input
width, height, and bit depth when you refer to these from inside of that node.
Therefore, width/2 takes the incoming width and divides it by 2. When you refer to the
width, height, and bit depth of a different node, you use that node’s output values.

At any time, you can also use the variable time, which refers to the current frame
number. For example, enter cos(time/5)*50 in the angle parameter value field in a
Rotate node for a nice “rocking” motion.

Creating and Using Local Variables

You can create additional parameters of your own, with extra sliders and text entry
fields, in order to build more complex expressions with interactive input.

To create a local variable within a node in your script:

1

Pick the node you want to add a local variable to, and open its parameters into the
Parameters tab.

2

Right-click anywhere within the Parameters tab (not directly on a field), then choose
Create Local Variable from the shortcut menu.

3

When the Local Variable Parameters window appears, define the settings that variable
will be created with.

Variable name: The name for that variable that appears in the Parameters tab.

Variable type: Whether the variable is a float (decimal places of precision), a string
(alpha-numeric text), or an integer (whole numbers).

Warning:

When renaming a node, don’t use a name that’s also used by a local

variable within that node.

Advertising