Steps for Creating a Script

Find it: Click the Script Editor button on the Action palette:

These are the general steps required to create a script. The Try It! page offers a brief case study that creates a sample script and routes to events.

  1. Create and name the script. If it is a global script, simply click Create Global. If it is a local script, select the object in the scene to attach the script to. Then click the Create Local button. (The Script node appears in the Outline Editor as soon as the script is created.) Type a name for the script in the box provided (or use the default name shown).

  2. Specify the events and fields used in your script. Choose Fields > Add. A dialog box appears, prompting you to select the Interface Type (eventIn, eventOut, or Field), as well as the field data type and name. Fields and events cannot have the same names.

    (An alternative to using the dialog box is to click the Edit Script button and type the fields using the text editor. Advanced users may prefer this technique. See Advanced: Creating a Script from Scratch for more information.)

  3. Create a trigger sensor for the script using the Create Trigger button. This step is optional.

  4. Now you're ready to program. Click the Edit Script button. Your default text editor appears on the screen, with a script template containing the events and fields you specified in step 2. Fill in the rest of the script.

    Note: while the text editor window is on the screen, the Script Editor buttons are disabled (except for Parse Script). This feature prevents conflicts between the two editor windows in determining which one currently "owns" the script.

  5. You can make intermediate saves of the script in your text editor and check the script's syntax by clicking Parse Script. Errors print in the Messages window.

  6. Save the script and close the text editor window. When you save, any new fields added with the text editor appear in the Script Editor Fields window.

  7. Open the Outline Editor to route the script to the objects you want it to affect.

Jump to: