Managing scripts



At the bottom of the script panel there is a button titled 'Library' which toggles display of a set of controls above the script panel.

The New, Open, and Save buttons function in the usual way, allowing you to create, load and save scripts to file. The combobox lets you switch between scripts, similar to using tabs in a browser. Hitting F5 or clicking the Run button will execute the current script.


The scratch-pad
The scratch-pad is a script that belongs to each scene and is saved inside the .rube file of that scene. When the active scene of the workspace changes, the scratch-pad title shown in the combobox will change, and the script in the edit area will also change to that of the active scene.

When no scene document is open, the scratch-pad title in the combobox will have no scene name, and the edit area will be grayed out.


Script library entries
Unlike the scratch-pad, all other entries listed in the combobox will relate to separate script files on disk. You can add entries to the combobox by clicking the 'new' button to create a new script, the 'open' button to open an existing script, or by dragging an existing script file from the file explorer into the script panel.

Typically most users will keep commonly used scripts together, in which case you can specify a folder location to act as a script 'library'. The script library folder will be searched recursively to add all files with the *.rs extension to the combobox. This will be done each time RUBE is started, or when the folder location is changed.

You can set the folder location in the script hooks setup dialog, which is opened by clicking the button with the pencil icon.

In the bottom right corner of this dialog, you can set the folder to search for scripts in. Relative paths will be resolved starting from the location of the RUBE executable.


Naming
The title shown in the combobox can be set to a more useful description by using a special comment in the script file. If a single-line comment beginning with "Name:" exists, the rest of that line will be used as the title for the script in the combobox. As the number of scripts grows, this helps to remind the user what each script is for in an easier way than using the script filename itself, and allows for UTF8 naming:

Titles will be updated when scripts are saved.


Tagging
When the script library contains a large number of scripts, the contents of the combobox can become very long, and finding scripts to switch between becomes difficult. To help narrow down the combobox list to a subset of scripts, you can use tags. Tags are just some short text to categorize scripts with, and are set by using a special comment line in the script file.

If a single-line comment beginning with "Tags:" exists, the rest of that line will be interpreted as a comma-separated list of tags. For example, the script from the default action menu which adds a body with a circle fixture could be given the tags 'body' and 'circle' like this:

Once tags have been set, they will appear in the list of tags shown by clicking the small down-arrow on the far right of the script panel. This list will be updated when scripts are saved.

You can select multiple tags in this list, to restrict the combobox contents to show only scripts that have those tags. Toggling this restriction on and off is done with the button immediately to the right of the combobox, with the tags icon.