Search notes:

Stellarium Script

The extension for Stellarium script file is .ssc.

Installling scripts

Stellarium scripts (and related files) must be installed into the User Data Directory.
On Windows, the User Data Directory seems to be located under C:\Program Files\Stellarium\scripts.

Running scripts

F2
To run a script, open the Configuration dialog and go to the Scripts tab. A list of available scripts will be displayed in the list box on the left side. When a script name is selected by clicking on it, details about that script will be shown in the panel on the right side.
To run the selected script, click the run script button (looks like a play button found on a CD or DVD player).

runScript batch files

Use a batch file to start Stellarium and run a script in it.
@echo off

rem copy /y %1 "%programfiles%\Stellarium\scripts"  > nul
    copy /y %1 "%appdata%\Stellarium\scripts"       > nul

pushd "%programfiles%\Stellarium"
start "" stellarium --startup-script=%1 --full-screen=no
popd

rem del "%programfiles%\Stellarium\scripts\%1"
rem del "%appdata%\Stellarium\scripts\%1"
Github repository about-Stellarium, path: /runScript.bat
Same idea, but for Linux:
if [ ! -e "$1" ]; then
  echo "specify script to be run"
  exit -1
fi

if [ ! -d ~/.stellarium/scripts ]; then
  echo "~/.stellarium/scripts does not exist"
  exit -1
fi

cp $1 ~/.stellarium/scripts

stellarium --startup-script=$(basename $1)
Github repository about-Stellarium, path: /runScript.sh

Usage

P:\ath\to\script\directory> ..\..\runScript.bat theScript.ssc

Including files

The script language comes with an include() statement that allows to reference functions in other script files.
The name of included script file must be enclosed in double-quotes, not single quotes! Otherwise, the ReferenceError Can't find variable: include is thrown.
include("foo.inc"); // ok
include('bar.inc'); // NOT ok

try catch

The script language is ECMAScript, so try … catch constructs are possible:
try {
  …
}
catch (e) {
  LabelMgr.deleteAllLabels();
  LabelMgr.labelScreen(e.toString(), 20, 20, true, 20, '#ff0000');
}

See also

Stellarium script console
Some scripts that try to demonstrate Stellarium's API.
Stellarium Scripts

Index