Page 1 of 1

Preliminary Scripting FAQ

Posted: 12.03.2011, 08:07
by Guckytos
This new version replaces the old FAQ. It was compiled by Marco Klunder and myself. And it is based on Selden's previous version.

Question 1:
I want to write some scripts for Celestia. How can I do it?

Answer 1a:

Visit the WIKI pages about .CEL and .CELX scripting.
These pages contain the formal supported documentation of all available .CEL commands and .CELX methods.
These WIKI pages are actualized to the last and upcoming Celestia releases and should be considered as a primary user reference guide for scripting.

Answer 1b:

Visit the Celestia Scripting Forum
In this forum, script writers exchange their knowledge about Celestia scripting. The forum contains many example scripts and there are even lots of very sophisticated scripts available on the forum, that you can use by yourself. The forum also gives you the opportunity to ask questions and help on certain scripting topics.

Answer 1c:

Read and contribute to the Celestia Scripting Guide, which is available on the Documentation Page of the Celestia MotherLode.

Question 2:
What scripting languages are used in Celestia?

Answer 2a:
Celestia includes a very simple scripting language of its own which understands commands like "go here, look there, set flag, display text". These commands should go into a file with the file type .CEL
An actualized (for Celestia v1.6.1) summary and documentation of available .CEL commands is available at WIKI: CEL command index.

Answer 2b:
Starting with Celestia v1.3.1, the Lua programming language became available for use in .CELX scripts. This offered new control-structures and actual programming capabilities like handling keyboard input for Celestia scripting.
For information on Lua, seehttp://www.lua.org/. A Lua manual is available at http://www.lua.org/docs.html.
An actualized (for Celestia v1.6.1) summary and documentation of available .CELX objects and methods is available at WIKI: CELX object and method index.

Question 3:
Where can I find example scripts for CEL and CELX?

Answer 3:
Useful .CEL and .CELX scripts are available in Don G's Celestia Scripting Resources and many other CEL and CELX scripts can be downloaded as a formal add-on from the Celestia Motherlode.

Example CEL scripts are Celestia's own start.cel and demo.cel, which are on your computer in Celestia's main directory.
Another example is the script at http://www.shatters.net/~t00fri/images/start-pandemo.cel.
A few example CELX scripts for Celestia are available at http://www.h-schmidt.net/celestia/.
Some additional example scripts and brief documentation are available in the Celestia WikiBook.

Question 4:
What possibilities exist to start a script?

Answer 4:
You can use any language you want if it can pass commands to the operating system's command interpreter: it can run Celestia and tell it to run a .CEL Celestia script or .CELX Lua script.
When invoked from a command line, Celestia can be passed the name of a .CEL or .CELX script to run at startup:

Code: Select all

./celestia --url name-of-script.cel

When the command line includes the qualifier "--once", the command line will be passed to the running copy of Celestia instead of starting a new copy of the program. (note: two hyphens)

Code: Select all

./celestia --once --url name-of-script.celx


Question 5:
Where are the scripts stored? Where can I store scripts?

Answer 5:
As of Celestia v1.3.1, scripts may be in any folder.
There is also a special “scripts” folder available, to store your scripts and have them listed in the Celestia/File/Scripts dropdown menu.

Question 6:
Can I use all scripts from older versions of Celestia with the most current one?

Answer 6:
Keep in mind that Celestia has really improved and changed from v1.3.1 to v1.6.1. Unfortunately, this also means that not all scripts written for older Celestia versions, work fine with the newest Celestia release.
Especially CELURLs that are often used within scripts are incompatible between v1.4, v1.5 and v1.6 of Celestia. Though, running older scripts in new Celestia versions may result in strange effects and running newer scripts in an old Celestia version may result in runtime errors.

Question 7:
Are CEL and CELX scripts interchangeable?

Answer 7:
When you want to convert existing CEL scripts to CELX scripts, the documentation and explanation of .CEL commands at WIKI: CEL command index also describe the CELX programming equivalents of each Celestia .CEL command.
There are however some typical differences between CEL script and CELX scripts, which you have to keep in mind. E.g. Angles in CELX are defined in radians instead of degrees in CEL and the units of the components of a position/vector object in CELX are millionths of a light-year, so when you have position/vector components defined in km (CEL scripting) or miles, you first have to convert those components to millionths of a light year.

More differences are documented at WIKI: CEL scripting versus CELX scripting.