Prev: Tool Scripts

8. Startup Scripts

The third type of script you can write is Startup Scripts. These must be saved in the ArtOfIllusion/Scripts/Startup folder. They are automatically executed every time Art of Illusion is launched.

Suppose you are working on a particular scene for a long time, and you want that scene to be automatically opened every time you start Art of Illusion. Create a file called OpenMyScene.groovy in the Startup directory which contains the following lines:


scene = new Scene(new File("/Users/peter/aoi/MyScene.aoi"), true);
ArtOfIllusion.newWindow(scene);

An important use for startup scripts is writing "plugins" in Groovy. The script simply creates an object that implements the appropriate interface, then registers the object with the PluginRegistry.


PluginRegistry.registerPlugin(new Plugin() {
  void processMessage(int message, Object[] args)
  {
    if (message == Plugin.SCENE_WINDOW_CREATED)
      {
        args[0].setScoreVisible(true);
        args[0].setSplitView(false);
      }
  }
});

Every time a new scene window is created, this plugin will set its Score to be visible and unsplit the view. This example shows how scripting can be used to customize the behavior of Art of Illusion.

Prev: Tool Scripts