New celx commands available in Celestia 1.5.0
Posted: 05.04.2007, 11:23
Here are the new CELX scripting features that have been added to Celestia 1.5.0, along with some examples of scripts:
----------------------------------------------------------------------------------------------
- celestia:getoverlayelements / celestia:setoverlayelements commands
----------------------------------------------------------------------------------------------
> celestia:getoverlayelements()
Return a table with all overlay elements as keys, and a boolean as value indicating whether a specific overlay element is enabled.
> celestia:setoverlayelements( table:overlayelements )
Enable/disable the rendering of overlay elements.
overlayelements is a table which contains the overlayelements Time, Velocity, Selection, Frame as keys, and booleans as values for each key.
>> Example:
------------------------------------------------------------------------------------------------
- arrows, circle, disk, filledsquare markers / marker alpha, marker label
------------------------------------------------------------------------------------------------
> new symbols to use as markers : circle, disk, filledsquare, uparrow, downarrow, leftarrow, rightarrow.
> new alpha argument to set transparency; must be between 0 (100% transparent) and 1 (100% opaque).
> new label argument to add labels to markers ; labels are added as strings using the fifth argument.
>> Examples:
------------------------------------
- star / dso iterators
------------------------------------
> celestia:stars() / celestia:dsos() [Edit on 20/05/07]
convenient for iterating over the entire star/dso databases
>> Example:
-----------------------------------------------------------------------
- celestia:getdsocount / celestia:getdso commands
-----------------------------------------------------------------------
> celestia:getdsocount()
Return number of DSOs in the used DSO catalogue.
> celestia:getdso(number:index_number)
Return a dso identified by its index number.
-----------------------------------------------------------------------------------------
- type, hubbletype, catalogNumber, absoluteMagnitude fields for DSOs
-----------------------------------------------------------------------------------------
> object:getinfo().type
Return Type of DSO among "galaxy", "nebula", or "opencluster" (instead of the generic "deepsky" previously returned)
> object:getinfo().hubbletype
Return Hubble Type of galaxies.
> object:getinfo().catalogNumber
Return Catalog Number of DSO.
> object:getinfo().absoluteMagnitude
Return Absolute Magnitude of DSO.
>> Example:
----------------------------------------------------------------------------------------------
- object:localname command [Edit on 10/04/07]
----------------------------------------------------------------------------------------------
> object:localname()
Return localized name of object.
Return "?" if no localization is available.
Note: "Sol", "Milky Way", along with the name of all other stars and DSOs are not localized.
>> Example:
----------------------------------------------------------------------------------------------
- observer:gettrackedobject command [Edit on 16/04/07]
----------------------------------------------------------------------------------------------
> observer:gettrackedobject()
Return the current tracked object for this observer.
>> Example:
----------------------------------------------------------------------------------------------
- celestia:getaltazimuthmode / celestia:setaltazimuthmodecommands [Edit on 18/05/07]
----------------------------------------------------------------------------------------------
> celestia:getaltazimuthmode()
Return true if Alt-Azimuth Mode is enabled, otherwise false.
> celestia:setaltazimuthmode(boolean:enable)
Enable/disable Alt-Azimuth Mode.
>> Example:
----------------------------------------------------------------------------------------------
- object:setradius command [Edit on 06/07/07]
----------------------------------------------------------------------------------------------
> object:setradius(number)
Set the radius of this object (in km).
>> Example:
----------------------------------------------------------------------------------------------
- celestia:getgalaxylightgain / celestia:setgalaxylightgain commands [Edit on 13/10/07]
----------------------------------------------------------------------------------------------
> celestia:getgalaxylightgain()
Return the current Galaxy Light Gain value.
> celestia:setgalaxylightgain(number)
Set the Galaxy Light Gain. Can take values between 0 and 1.
>> Example:
----------------------------------------------------------------------------------------------
- celestia:setlabelcolor / celestia:setlinecolor commands [Edit on 13/10/07]
----------------------------------------------------------------------------------------------
> celestia:setlabelcolor(string:objectclass, number:red, number:green, number:blue)
Set label colors.
objectclass: String describing the class of objects on which the label color change is applied. Must be one of stars, planets, moons, asteroids, comets, spacecraft, locations, galaxies, nebulae, openclusters, constellations, equatorialgrid.
> celestia:setlabelcolor(string:linetype, number:red, number:green, number:blue)
Set line colors.
linetype: String describing the type of lines on which the color change is applied. Must be one of starorbits, planetorbits, moonorbits, asteroidorbits, cometorbits, spacecraftorbits, constellations, boundaries, equatorialgrid.
>> Example:
----------------------------------------------------------------------------------------------
- celestia:tdbtoutc / celestia:utctotdb commands [Edit on 13/01/08]
----------------------------------------------------------------------------------------------
> celestia:tdbtoutc(number)
Convert a TDB Julian date (number) to a UTC date (table).
The UTC date is returned as a table containing the keys 'year', 'month', 'day', 'hour', 'minute', 'second' and the respective values.
> celestia:utctotdb(table)
Convert a UTC date (table) to a TDB Julian date (number).
>> Example:
----------------------------------------------------------------------------------------------
- celestia:getoverlayelements / celestia:setoverlayelements commands
----------------------------------------------------------------------------------------------
> celestia:getoverlayelements()
Return a table with all overlay elements as keys, and a boolean as value indicating whether a specific overlay element is enabled.
> celestia:setoverlayelements( table:overlayelements )
Enable/disable the rendering of overlay elements.
overlayelements is a table which contains the overlayelements Time, Velocity, Selection, Frame as keys, and booleans as values for each key.
>> Example:
Code: Select all
-- Title: Enable/disable the rendering of overlay elements.
celestia:print ("Display Time only", 3)
celestia:setoverlayelements { Time = true, Velocity = false, Selection = false, Frame = false }
wait(5)
celestia:print ("Display Velocity only", 3)
celestia:setoverlayelements { Time = false, Velocity = true, Selection = false, Frame = false }
wait (5)
celestia:print ("Display Selection Information only", 3)
celestia:setoverlayelements { Time = false, Velocity = false, Selection = true, Frame = false }
wait (5)
celestia:print ("Display Frame Information only", 3)
celestia:setoverlayelements { Time = false, Velocity = false, Selection = false, Frame = true }
wait (5)
celestia:print ("Display None", 3)
celestia:setoverlayelements { Time = false, Velocity = false, Selection = false, Frame = false }
wait (5)
celestia:print ("Display All Overlay Elements", 3)
celestia:setoverlayelements { Time = true, Velocity = true, Selection = true, Frame = true }
wait (5)
------------------------------------------------------------------------------------------------
- arrows, circle, disk, filledsquare markers / marker alpha, marker label
------------------------------------------------------------------------------------------------
> new symbols to use as markers : circle, disk, filledsquare, uparrow, downarrow, leftarrow, rightarrow.
> new alpha argument to set transparency; must be between 0 (100% transparent) and 1 (100% opaque).
> new label argument to add labels to markers ; labels are added as strings using the fifth argument.
>> Examples:
Code: Select all
-- Title: Mark Xanadu with a red left arrow 50% transparent.
obs = celestia:getobserver()
titan = celestia:find("Sol/Saturn/Titan")
xanadu = celestia:find("Sol/Saturn/Titan/XANADU")
obs:gotolonglat(titan, math.rad(-100), math.rad(-15), 2e4)
celestia:select(xanadu)
celestia:settimescale(1)
celestia:unmarkall()
xanadu:mark( "red", "leftarrow", 70, 0.5)
Code: Select all
--Title: Mark inner planets with labeled colored disks 70% transparent.
celestia:setrenderflags{planets = true, orbits = true}
celestia:setlabelflags{planets = true}
obs = celestia:getobserver()
sol = celestia:find("Sol")
obs:follow(sol)
obs:gotolonglat(sol, math.rad(0), math.rad(90), 1e9)
mercury = celestia:find("Sol/Mercury")
venus = celestia:find("Sol/Venus")
earth = celestia:find("Sol/Earth")
mars = celestia:find("Sol/Mars")
celestia:unmarkall()
mercury:mark( "yellow", "disk", 24, 0.7, mercury:name()..": Planet type = Telluric")
venus:mark( "white", "disk", 60, 0.7, venus:name()..": Planet type = Telluric")
earth:mark( "blue", "disk", 64, 0.7, earth:name()..": Planet type = Telluric")
mars:mark( "red", "disk", 34, 0.7, mars:name()..": Planet type = Telluric")
celestia:settimescale(1e6)
------------------------------------
- star / dso iterators
------------------------------------
> celestia:stars() / celestia:dsos() [Edit on 20/05/07]
convenient for iterating over the entire star/dso databases
>> Example:
Code: Select all
-- Title: Mark all stars of a specific spectral type
function mark_spectraltype(x)
for star in celestia:stars() do
first, last = string.find(star:spectraltype(), x, 1, true)
if first == 1 then
star:mark("#ff99ff", "circle", 10)
end
end
end
spectral = "O"
celestia:flash("Marking all " .. spectral .. " stars.")
mark_spectraltype(spectral)
-----------------------------------------------------------------------
- celestia:getdsocount / celestia:getdso commands
-----------------------------------------------------------------------
> celestia:getdsocount()
Return number of DSOs in the used DSO catalogue.
> celestia:getdso(number:index_number)
Return a dso identified by its index number.
-----------------------------------------------------------------------------------------
- type, hubbletype, catalogNumber, absoluteMagnitude fields for DSOs
-----------------------------------------------------------------------------------------
> object:getinfo().type
Return Type of DSO among "galaxy", "nebula", or "opencluster" (instead of the generic "deepsky" previously returned)
> object:getinfo().hubbletype
Return Hubble Type of galaxies.
> object:getinfo().catalogNumber
Return Catalog Number of DSO.
> object:getinfo().absoluteMagnitude
Return Absolute Magnitude of DSO.
>> Example:
Code: Select all
-- Title: Marks all galaxies according to their Hubble Type.
function mark_galaxy_types()
for dso in celestia:dso() do
if dso:getinfo().type == "galaxy" then
hubbleType = dso:getinfo().hubbleType
if string.find(hubbleType, "E") then
dso:mark( "red", "disk", 1, 0.7 )
elseif string.find(hubbleType, "Irr") then
dso:mark( "yellow", "disk", 1, 0.7 )
elseif string.find(hubbleType, "SB") then
dso:mark( "green", "disk", 1, 0.7 )
elseif string.find(hubbleType, "S") then
dso:mark( "blue", "disk", 1, 0.7 )
end
end
end
end
celestia:unmarkall()
celestia:setrenderflags { markers = true }
mark_galaxy_types()
----------------------------------------------------------------------------------------------
- object:localname command [Edit on 10/04/07]
----------------------------------------------------------------------------------------------
> object:localname()
Return localized name of object.
Return "?" if no localization is available.
Note: "Sol", "Milky Way", along with the name of all other stars and DSOs are not localized.
>> Example:
Code: Select all
-- Title: Display the localized name of the current selection.
while true do
sel = celestia:getselection()
celestia:print(sel:getinfo().type)
wait(0)
end
----------------------------------------------------------------------------------------------
- observer:gettrackedobject command [Edit on 16/04/07]
----------------------------------------------------------------------------------------------
> observer:gettrackedobject()
Return the current tracked object for this observer.
>> Example:
Code: Select all
-- Title: Display the name of the current tracked object.
while true do
obs = celestia:getobserver()
trackedObjName = obs:gettrackedobject():name()
if trackedObjName == "?" then
celestia:print("Press the [T] key to track the current selection.")
else
celestia:print(trackedObjName.." is currently tracked.")
end
wait(0)
end
----------------------------------------------------------------------------------------------
- celestia:getaltazimuthmode / celestia:setaltazimuthmodecommands [Edit on 18/05/07]
----------------------------------------------------------------------------------------------
> celestia:getaltazimuthmode()
Return true if Alt-Azimuth Mode is enabled, otherwise false.
> celestia:setaltazimuthmode(boolean:enable)
Enable/disable Alt-Azimuth Mode.
>> Example:
Code: Select all
-- Title: Enable Alt-Azimuth Mode.
celestia:setaltazimuthmode(true)
----------------------------------------------------------------------------------------------
- object:setradius command [Edit on 06/07/07]
----------------------------------------------------------------------------------------------
> object:setradius(number)
Set the radius of this object (in km).
>> Example:
Code: Select all
-- Title: Increase the size of Planets for an educational view of our solar system.
function celestia_cleanup_callback()
sol_children = sol:getchildren()
for k, child in pairs(sol_children) do
if child:type() == "planet" then
child:setradius(iRadius[k])
end
end
end
celestia:setorbitflags( { Planet = true } )
celestia:setrenderflags( { planets = true, orbits = true, smoothlines = true } )
celestia:setlabelflags( { planets = true } )
celestia:setminorbitsize(3)
sol = celestia:find("Sol")
celestia:select(sol)
obs = celestia:getobserver()
obs:gotolonglat(sol, 0, 70, 1e10, 5)
wait(5)
sol_children = {}
iRadius = {}
sol_children = sol:getchildren()
for k, child in pairs(sol_children) do
if child:type() == "planet" then
iRadius[k] = child:radius()
child:setradius(iRadius[k] * 2e3)
end
end
while true do
wait(0)
end
----------------------------------------------------------------------------------------------
- celestia:getgalaxylightgain / celestia:setgalaxylightgain commands [Edit on 13/10/07]
----------------------------------------------------------------------------------------------
> celestia:getgalaxylightgain()
Return the current Galaxy Light Gain value.
> celestia:setgalaxylightgain(number)
Set the Galaxy Light Gain. Can take values between 0 and 1.
>> Example:
Code: Select all
-- Title: Set the Galaxy Light Gain to 50%.
celestia:setgalaxylightgain(0.50)
----------------------------------------------------------------------------------------------
- celestia:setlabelcolor / celestia:setlinecolor commands [Edit on 13/10/07]
----------------------------------------------------------------------------------------------
> celestia:setlabelcolor(string:objectclass, number:red, number:green, number:blue)
Set label colors.
objectclass: String describing the class of objects on which the label color change is applied. Must be one of stars, planets, moons, asteroids, comets, spacecraft, locations, galaxies, nebulae, openclusters, constellations, equatorialgrid.
> celestia:setlabelcolor(string:linetype, number:red, number:green, number:blue)
Set line colors.
linetype: String describing the type of lines on which the color change is applied. Must be one of starorbits, planetorbits, moonorbits, asteroidorbits, cometorbits, spacecraftorbits, constellations, boundaries, equatorialgrid.
>> Example:
Code: Select all
-- Title: Alternate Line and Label Colors from ElChristou.
celestia:setlabelcolor("stars", 0.471, 0.356, 0.682)
celestia:setlinecolor ("starorbits", 0.5, 0.5, 0.8)
celestia:setlabelcolor("planets", 0.407, 0.333, 0.964)
celestia:setlinecolor ("planetorbits", 0.3, 0.323, 0.833)
celestia:setlabelcolor("moons", 0.231, 0.733, 0.792)
celestia:setlinecolor ("moonorbits", 0.08, 0.407, 0.392)
celestia:setlabelcolor("asteroids", 0.596, 0.305, 0.164)
celestia:setlinecolor ("asteroidorbits", 0.58, 0.152, 0.08)
celestia:setlabelcolor("comets", 0.768, 0.607, 0.227)
celestia:setlinecolor ("cometorbits", 0.639, 0.487, 0.168)
celestia:setlabelcolor("spacecraft", 0.93, 0.93, 0.93)
celestia:setlinecolor ("spacecraftorbits", 0.4, 0.4, 0.4)
celestia:setlabelcolor("locations", 0.24, 0.89, 0.43)
celestia:setlabelcolor("galaxies", 0.0, 0.45, 0.5)
celestia:setlabelcolor("nebulae", 0.541, 0.764, 0.278)
celestia:setlabelcolor("openclusters", 0.239, 0.572, 0.396)
celestia:setlabelcolor("constellations", 0.125, 0.167, 0.2)
celestia:setlinecolor ("constellations", 0.0, 0.12, 0.18)
celestia:setlabelcolor("equatorialgrid", 0.095, 0.196, 0.1)
celestia:setlinecolor ("equatorialgrid", 0.07, 0.114, 0.073)
celestia:setlinecolor ("boundaries", 0.1, 0.006, 0.066)
----------------------------------------------------------------------------------------------
- celestia:tdbtoutc / celestia:utctotdb commands [Edit on 13/01/08]
----------------------------------------------------------------------------------------------
> celestia:tdbtoutc(number)
Convert a TDB Julian date (number) to a UTC date (table).
The UTC date is returned as a table containing the keys 'year', 'month', 'day', 'hour', 'minute', 'second' and the respective values.
> celestia:utctotdb(table)
Convert a UTC date (table) to a TDB Julian date (number).
>> Example:
Code: Select all
-- Title: Display UTC Julian Date
while true do
TDBjd = celestia:gettime()
UTCdate = celestia:tdbtoutc(TDBjd)
UTCjd = celestia:tojulianday(UTCdate.year, UTCdate.month, UTCdate.day, UTCdate.hour, UTCdate.minute, UTCdate.seconds)
celestia:print("UTC Julian date: "..string.format("%0.5f", UTCjd))
wait(0)
end