JMRI: Scripting
Writing and executing a "script" (program in Python/Jython or other language - see below) is a way of telling JMRI to execute commands specific to your JMRI environment and to partially or even fully automate your layout and train operations. Scripts can be as simple as telling JMRI to set a single sensor or as complex as setting up multiple objects and running multiple trains based on feedback from your layout. While there is no comprehensive JMRI scripting manual, the examples provided in the pages linked below will be a primary source of information on how to use scripting to great advantage with JMRI. The "How To" and "What-Where" sections also provide many ideas and hints gleaned from the JMRI community on scripting features and capabilities.
The following pages discuss scripting JMRI using the Jython version of Python:
- Getting started with simple scripts
- The Python/Jython language
- Example script: Setting the default state of turnouts
- Many other example scripts (Links)
- Lots of "How To..." for JMRI scripting
- "What...Where" interesting tidbits about creating Jython scripts for use with JMRI
- Modifying the GUI with Jynstruments
- Open Scripting Architecture (available for Mac)
See also the help section on Python and JMRI.
Any Java Scripting API (commonly refered to JSR-223) compliant scripting language can be added to JMRI, however, only JavaScript and Python (Jython) are directly supported in the default installation. If you want to add another scripting language, find a JSR-223 compliant interpreter and add it to the JMRI classpath as documented for your operating system (different operating systems have different launchers that are configured differently).