Why “sfilein” and not “filein” node, Variables and data types, Two ways to load a script into the interface – Apple Shake 4 User Manual

Page 953

Advertising
background image

Chapter 31

Expressions and Scripting

953

// Input nodes
bg = SFileIn(“bg.iff”, “Auto”, 0, 0);
sign_mask = SFileIn(“sign_mask.iff”, “Auto”, 0, 0);
truck = SFileIn(“truck.iff”, “Auto”, 0, 0);
// Processing nodes
Outside1 = Outside(truck, sign_mask, 1);
Over1 = Over(Outside1, bg, 1, 0, 0);

The first section contains controls for the script. The controls are all optional or can be
overridden on the command line. The following sections discuss the body of the script,
the sections listed under the “Input nodes” and “Processing nodes” comments.

Variables and Data Types

Shake assigns types of data to a variable name. A variable works as a sort of shopping
cart to carry around your information to be used again somewhere else. The variables
in the following code (excerpted from above) are bold.

The comment lines (lines starting with //) are omitted:

bg = SFileIn(“bg.iff”, “Auto”, 0, 0);
sign_mask = SFileIn(“sign_mask.iff”, “Auto”, 0, 0);
truck = SFileIn(“truck.iff”, “Auto”, 0, 0);
Outside1 = Outside(truck, sign_mask, 1);
Over1 = Over(Outside1, bg, 1, 0, 0);

The above code assigns three variables (bg, sign_mask, truck) to three SFileIn nodes.
These are connected to an Outside node and then to an Over node, which are also
assigned variable names, Outside1 and Over1.

A good reason to use a script is that you can quickly set the path for the images by
using copy and paste functions in a text editor.

Why “SFileIn” and Not “FileIn” Node?

The SFileIn node is an improvement on the older FileIn node. The interface button
FileIn is linked to SFileIn, but the older name is retained. The SFileIn node allows extra
subfunctions for timing to be attached.

Two Ways to Load a Script Into the Interface:

Save the script and load it into the interface with the Terminal command shake
start.shk,
or click the Load button in the interface.

Copy the script as text from the HTML browser/text editor and paste it into the
Node View (press Command-V or Control-V). When you paste it into the interface, it
points out that the filepaths are local, and probably not correct in terms of the
location of the images and where the interface expects to find the images.
Therefore, browse to the directory that contains the images, then click OK.

Advertising