I have written a more complex script that uses track circuit sensors to detect the locomotive position and then operates points and loco speed and direction. Sound effects are also controlled by the script. This video show the script running. In the video you will see the JMRI Sensor table status, the dynamic track diagram and the output of the script.
You will be able to see the contents of the smaller windows if you play this video in full screen mode.