Template Script for .cel scripts (Updated Aug 25 2003)

All about writing scripts for Celestia in Lua and the .cel system
Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Template Script for .cel scripts (Updated Aug 25 2003)

Post #1by don » 28.07.2003, 02:42

[Edited Aug 25 - updated script and link to version 1.2]

Hello Everyone,

Listed below, is what I call a "Template Script" that can be used to start a new .cel script for use in Celestia version 1.3.0 and up. It sets Celestia to a "known state", as best as .cel scripting allows.

Here are a couple of ideas on how to use this script:

* It can be used every time you start writing a new script, providing you with pre-written commands to set-up Celestia the way you want to for the new script. Just change the commands and/or parameters to the way you want them and save the script. Then, anytime you start a new script, open the template and perform a File/Save As using the name for your new script.

* You can copy and rename the script to "start.cel", then move it to the main Celestia folder/directory so that it runs every time you start Celestia.

If you find a bug, or if you know of other items that can be set to a "known state" via .cel scripting, please post a message here so the script can be updated. Thank you!

Hope you find it useful. :)

__________________
-Don Goyette
Visit my Celestia web page


* Select the text in the code box, copy it, then paste it to your own text file
--or--
* Click this link and then save the file to your computer: CelScriptTemplate_v1_2.cel.txt. When you save this file to your computer, remove the ending ".txt" from the filename. It's there in case someone left-clicks the link instead of right-clicking it.

Code: Select all

{
#****************************************************************************
#*             Template .CEL Script for Celestia (version 1.2)              *
#****************************************************************************


# How to use this template
# ------------------------
# 1. Open this file with a text editor
# 2. File/Save As the file with YOUR script file name and the .cel extension
# 3. Change any of the commands or parameters to suit your needs
# 4. Add your own Script Body code


#----------------------------------------------------------------------------
# Set Celestia to a "known state"
#----------------------------------------------------------------------------

# Cancel follow and goto commands, and set Coordinate System to Universal...
    cancel { }

# Note: cancel in ver 1.3.0 does NOT clear Track, Lock or Chase, like the ESC key does,
#       so we must do it manually (version 1.3.1 does this automatically)...
#    select { object "" } # this works
#    track  { }           # this works
#    chase  { }           # this does not work
#    lock   { }           # this does not work


# Clear the display of any left-over text from the print command...
    cls { }


# Do not render the following objects...
    renderflags { clear "boundaries|comettails|constellations|eclipseshadows" }
    renderflags { clear "markers|orbits|pointstars|ringshadows" }
    renderflags { clear "automag|grid" } # version 1.3.1+


# Render the following objects...
    renderflags { set "cloudmaps|galaxies|nightmaps|planets|stars" }
    renderflags { set "atmospheres" } # version 1.3.1+


# Do not label the following objects...
    labels { clear "planets|moons|spacecraft|asteroids|constellations" }
    labels { clear "stars|galaxies" }


# Label the following objects...
#    labels { set "planets|moons|spacecraft|asteroids|constellations" }
#    labels { set "stars|galaxies" }


# Unmark any objects that are currently Marked and disable Marker display...
    unmarkall { } # version 1.3.1+


# Set Minimum Orbit Size...
    set { name "MinOrbitSize" value 1.0 }


# Set Ambient Light Level...
# (0.0 to 1.0 is a good Lo-Hi range)...
    set { name "AmbientLightLevel" value 0.10 }


# Set Field of View...
# (Celestia 1.3.0 default value is 45)
# (Celestia 1.3.1 default value is 25)
    set { name "FOV" value 25.0 }


# Set Star Distance Limit...
# (Celestia default value is 1000000)
    set { name "StarDistanceLimit" value 1000000 }


# For the next two Magnitude settings, Selden Ball reminds us of the following:
# "A magnitude limit of 6.5 corresponds to what you can see with the naked eye
# on a very dark night away from city lights."

# Set visible star Magnitude...
# (Celestia UI: 0.8 to 15.2, default is 6.0)
    setvisibilitylimit { magnitude 6.50 }


# Set Faintest Auto-Magnitude Brightness...
# (Celestia default value is 8.5)
    setfaintestautomag45deg { magnitude 8.5 }


# Set Time Rate (1x, 100x, 1000x, etc.)...
# (A negative value = Reverse Time
#               0   = Pause Time
#               1.0 = Real Time (default)
#            1000.0 = Good moon orbit motion)
    timerate { rate 1.0 }


# Set Date and Time...
#     U.S. Navy Calendar Date/Time to Julian Date/Time converter:
#       http://aa.usno.navy.mil/data/docs/JulianDate.html
#   time { jd JulianDay.JulianTime }


#----------------------------------------------------------------------------
# Start at Earth/USA (or anywhere else you want to start). You can simply
# delete this code if you don't want to use it.
#----------------------------------------------------------------------------

# Select the Earth...
    select { object "Earth" }

    gotolonglat { time 2
                  distance 5
                  longitude -94.82394
                  latitude 35.28109 }

    print  { text "Going to Earth..."
             row -3
             column 25
             duration 3 }
    wait   { duration 3 }

    track { }

    print  { text "Now Tracking Earth."
             row -3
             column 25
             duration 3 }
    wait   { duration 3 }


#----------------------------------------------------------------------------
# Script Body - Your code goes here ...
#----------------------------------------------------------------------------







#----------------------------------------------------------------------------
# End of Script - Let the user know the script is done running ...
#----------------------------------------------------------------------------

    print  { text "The script is finished."
             row -3
             column 25
             duration 5 }
    wait   { duration 5 }

}
Last edited by don on 25.08.2003, 09:04, edited 8 times in total.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 4 months
Location: NY, USA

Post #2by selden » 28.07.2003, 03:33

A quibble:

A magnitude limit of 6.5 corresponds to what you can see with the naked eye on a very dark night away from city lights.

When you set the magnitude limit to a high value, so that dimmer stars are drawn, Celestia has to do many more tests for stars being blocked by foreground objects like planets. This uses a lot more CPU time and makes it much slower.
Selden

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #3by don » 28.07.2003, 03:42

Howdy Selden,

Quibble <smile>? Then why is the Celestia default 8.5? Sounds high, based on what you are saying.

Personally, I set it even higher (fast CPU <smile>). Also, we live 50+ miles from the nearest city (Colorado Springs) and in several directions have ZERO earth-based lighting anywhere (foreground to horizon). So, our view is probably better than most. (Meteor showers are a LOT of fun to watch out here because you can actually SEE them <smile>!)

Do you think I should modify the script code above to some other value, or just let folks set it to the value they prefer, once they copy the code and paste it to their own system?

I am always open to suggestions!
-Don G.
My Celestia Scripting Resources page

Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 4 months
Location: NY, USA

Post #4by selden » 28.07.2003, 04:01

Celestia restarts with whatever magnitude limit value was set when it exited, so without an explicit setmagnitude command, the initial default is essentially meaningless. I'd suggest just adding a comment reminding people to set it to whatever they think is appropriate.
Selden

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #5by don » 28.07.2003, 04:16

Oops, I was looking at AutoMag. I forgot to lower it for the template, after I raised it for myself. Thanks Selden.

How does it look now (it's been edited)?
-Don G.

My Celestia Scripting Resources page



Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 4 months
Location: NY, USA

Post #6by selden » 28.07.2003, 11:14

looks fine to me!
Selden

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #7by don » 28.07.2003, 15:14

Thanks Selden.

Can you think of anything else that could/should go in a template, for version 1.3.0?
-Don G.

My Celestia Scripting Resources page



Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.

JackHiggins
Posts: 1034
Joined: 16.12.2002
With us: 22 years 1 month
Location: People's Republic Of Cork, Ireland

Post #8by JackHiggins » 28.07.2003, 18:35

don wrote:Can you think of anything else that could/should go in a template, for version 1.3.0?

How do I "un-track" an object? Since you've started tracking earth in the script how to I go back to the camera not tracking anything? (I don't mean make it track something else)..?
- Jack Higgins
Jack's Celestia Add-ons
And visit my Celestia Gallery too!

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #9by don » 28.07.2003, 19:07

JackHiggins wrote:How do I "un-track" an object?

This works in 1.3.1 pre6, but I'm not sure about 1.3.0 Final ...

Code: Select all

select { object "" }
track  {}
-Don G.

My Celestia Scripting Resources page



Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.

JackHiggins
Posts: 1034
Joined: 16.12.2002
With us: 22 years 1 month
Location: People's Republic Of Cork, Ireland

Post #10by JackHiggins » 28.07.2003, 19:20

Thanks- I knew it would be something simple like that... :roll: :) I'd say that should probably work in 1.3.0 as well- it doesn't use any advanced new features that I can see! :wink:
- Jack Higgins

Jack's Celestia Add-ons

And visit my Celestia Gallery too!

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #11by don » 28.07.2003, 19:33

JackHiggins wrote:Thanks- I knew it would be something simple like that... :roll: :) I'd say that should probably work in 1.3.0 as well- it doesn't use any advanced new features that I can see! :wink:

You're welcome Jack. I would also *think* it should work in 1.3.0 but I don't have it loaded right now to be *sure* <smile>.
-Don G.

My Celestia Scripting Resources page



Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 6 months
Location: Colorado, USA (7000 ft)

Post #12by don » 25.08.2003, 09:05

August 25, 2003...

Just updated the script to version 1.2.

-Don G.


Return to “Scripting”