Creating a Script for Stellarium

From Stellarium Wiki
Revision as of 07:03, 26 August 2013 by Barrykgerdes (Talk | contribs)
Jump to: navigation, search


The Script

A script is a text file that can be prepared with any text editor and read by Stellarium to display an astronomical event such as a past or future eclipse or a display of features of Stellarium with sound and video. The possibilities are extensive and only limited by what commands are available in the Stellarium core code.

Here is an example of a simple script that displays a lunar eclpse from 2006. Note that each command ends with “;” It has been modfied from the original to return the screen to the starting state when finished


//

// Name: Partial Lunar Eclispe

// License: Public Domain

// Author: Matthew Gates. Modified B.Gerdes 09/02/2009

// Description: Attempt to re-implement simple script from the old

// scripting engine. Each old style command is shown

// first as a command with OLD: at the start of the line

// to help users of the old scripting engine learn how

// to use the new one.

//

core.debug("Starting Partial Lunar Eclispe script");

core.wait(1);

core.debug("OK, let's go...");

// OLD: clear core.clear("natural");

LandscapeMgr.setFlagLandscape(false);

LandscapeMgr.setFlagAtmosphere(false);

LandscapeMgr.setFlagFog(false);

core.wait(1);

// OLD: date utc 2006:03:14T21:21:32

core.setDate("2006:03:14T21:21:32");

// OLD: select planet Moon pointer off

core.selectObjectByName("Moon", false);

StelMovementMgr.setFlagTracking(true);

// OLD: wait duration 2 core.wait(2);

// OLD: zoom auto in StelMovementMgr.autoZoomIn(2);

// OLD: wait duration 2 core.wait(2);

// OLD: timerate rate 500

// .00001157407407407407 julian days = 1 second.

// we want 500 seconds per second.

// good candidate for aforementioned include system

// function although it's not so bad now we can do

// arithmetic in scripts :-)

core.setTimeRate(500);

// core wait time is a multiple of the TimeRate that is set core.wait (60);

// set the time back to normal

StelMovementMgr.autoZoomOut(2);

core.setTimeRate(1);

core.clear("natural")

// set the date back to today

core.setDate("now");

//Return screen to original positiion so that we know the script is over

LandscapeMgr.setFlagLandscape(True);

LandscapeMgr.setFlagAtmosphere(false);

LandscapeMgr.setFlagFog(false);


This script has been programmed to store the starting position. and return at the end of the show - LandscapeMgr.xxx commands

Note: the format of each line and command. the command first “core.clear” with how the command will act with 
its options “("natural")” enclosed in  brackets followed by a ”;” A comment line is preceded with :”//”


Writing Your Own Scripts

With a little practice most users of Stellarium shold be able to write scripts using the simplified table of commands by modifying existing scripts or starting from scratch as your knowledge increases. Look at the sample script in the previous section.

Tables to be added
Personal tools
Namespaces
Variants
Actions
in this wiki
other languages
Toolbox