Where can I find info on how to create scripts?

All about writing scripts for Celestia in Lua and the .cel system
Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Where can I find info on how to create scripts?

Post #1by thefallenghost » 03.03.2010, 14:38

I want to create a script that displays the locations of exoplanet-host stars, but I never wrote any script in Celestia.

SiriusCG
Posts: 33
Joined: 10.03.2008
Age: 67
With us: 16 years 6 months
Location: The Smoke Ring

Re: Where can I find info on how to create scripts?

Post #2by SiriusCG » 03.03.2010, 15:19

http://www.celestiamotherlode.net/

Lots of useful information including links to documents describing CEL and CELX scripting.

Cheers.

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #3by thefallenghost » 03.03.2010, 17:31

I'm sorry, I realized I need to make some kind of plot of these objects, and not a script. I want to do something like "Galactic Redshift Survey" or "SIRAS PSCz Galaxies" on the motherlode. I haven't found any help on plotting though. Where can I get some?

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Re: Where can I find info on how to create scripts?

Post #4by selden » 03.03.2010, 19:41

What do you mean by "plotting"?

Celestia can place markers around objects, if that's what you mean. That can be done with a Cel script.

Or you can write a Lua script to write out information that Celestia has to a file and then use some separate plotting program (Excel, perhaps) to translate that information into an appropriate 2D plot.
Selden

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #5by thefallenghost » 03.03.2010, 22:09

.
Last edited by thefallenghost on 03.03.2010, 23:50, edited 1 time in total.

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #6by thefallenghost » 03.03.2010, 23:49

Well, I want to display the location of ~400 exoplanet-host stars (as dots or actual stars with planets, preferring the latter option) around Earth's location in 3D.

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Re: Where can I find info on how to create scripts?

Post #7by selden » 04.03.2010, 11:20

That can be done in Celestia when using a Cel script with a separate command for each object, placing a marker around each one specified by name, which is rather painful,

or by using a CelX script which looks at every star and marks those which have an associated planet.

I have a distinct memory of someone already having written that CelX script, although I don't remember who. Vincent, maybe?
Selden

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Where can I find info on how to create scripts?

Post #8by Vincent » 04.03.2010, 14:11

selden wrote:I have a distinct memory of someone already having written that CelX script, although I don't remember who. Vincent, maybe?
Yep!
viewtopic.php?f=9&t=14208

Note that Google returns the above link as its first match using the following key words: celestia+script+mark+stars+exoplanet
http://www.google.fr/#hl=fr&source=hp&q ... abdc2d39f4
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #9by thefallenghost » 05.03.2010, 03:22

Well, since I'm doing this for an important project, I would prefer going through the stars one by one to make sure they're all included (as they're not all in Celestia currently). Also, I looked at the mark-lg celx included in Celestia and I thought I saw some parameters to the mark function ("dso:mark( "green", "disk",10, 1 )" at line 20). Are there any parameters for the mark function in celx, and if yes, what are they?

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Where can I find info on how to create scripts?

Post #10by Vincent » 05.03.2010, 07:45

thefallenghost wrote:Well, since I'm doing this for an important project, I would prefer going through the stars one by one to make sure they're all included (as they're not all in Celestia currently). Also, I looked at the mark-lg celx included in Celestia and I thought I saw some parameters to the mark function ("dso:mark( "green", "disk",10, 1 )" at line 20). Are there any parameters for the mark function in celx, and if yes, what are they?
Well, a celx scripting tutorial is available here: http://en.wikibooks.org/wiki/Celestia/C ... ua_Methods
Well, the script shouldn't be too hard to modify to suit your specific needs.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #11by thefallenghost » 05.03.2010, 17:12

This still doesn't answer wether or not there are any arguments to the mark function (there doesn't seem to be any on your link).

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Where can I find info on how to create scripts?

Post #12by Vincent » 05.03.2010, 17:34

You may want to try adding some magic words like please and thank you...
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #13by thefallenghost » 05.03.2010, 17:44

Sorry... You're right, Thanks :)!
I think that the arguments are :
1) Color of the marker
2) Shape of the marker
3) Size of the marker
4) Number:?

However, when I run my script, it returns a fatal error:
In line 6: Argument to find must be a string.

Here is my celx:

Code: Select all

-- Title: Mark exoplanet-host stars

-- Stars with planets discovered by the radial velocity method:
markRV = function(starName)
   celestia:unmarkall()
   celestia:setrenderflags{markers = true}
   celestia:select(nil)
   myStar = celestia:find(starName)
   myStar:mark("green", "disk", 10, 1)
   end
RVstars = {"HD 209458","HD 189733"}
markRV(RVstars)


Please help!

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Where can I find info on how to create scripts?

Post #14by Vincent » 05.03.2010, 18:02

This is a good start.
Now, the problem is that you're passing the RVstars table as argument to the markRV function.
You actually need to iterate over the elements contained in the table so that the string names
are successively passed as argument to the markRV function:

Code: Select all

RVstars = {"HD 209458","HD 189733"}

for k, starname in pairs(RVstars) do
    markRV(starname)
end
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #15by thefallenghost » 05.03.2010, 20:49

Thanks! I've made some progress; here's my new script:

Code: Select all

-- Title: Mark exoplanet-host stars

-- Listed in alphabetical order. The list is located at: http://www.planetary.org/exoplanets/list.php

celestia:unmarkall()
celestia:setrenderflags{markers = true}
celestia:select(nil)

-- Stars with planets discovered by the radial velocity method:
markRV = function(starName)
   myStar = celestia:find(starName)
   myStar:mark("green", "square", 10, 1)
   end
RVstars = {
"Gliese 86 A",
"14 And",
"14 Her",
"16 Cyg B",
"18 Del",
"30 Ari B",
"4 UMa",
"42 Dra",
"51 Peg",
"55 Cnc",
"6 Lyn",
"61 Vir",
"70 Vir",
"81 Cet",
"HIP 30034",
"HIP 104780"
}

for k, starname in pairs(RVstars) do
    markRV(starname)
end

---------------------------------------------------------------
-- Star with planet discovered by the astrometry method:
markAS = function(starName)
   myStar = celestia:find(starName)
   myStar:mark("green", "disk", 10, 1)
   end
ASstars = {
"VB 10"
}

for k, starname in pairs(ASstars) do
    markAS(starname)
end

---------------------------------------------------------------
-- Stars with planets discovered by the transit method:
markT = function(starName)
   myStar = celestia:find(starName)
   myStar:mark("blue", "square", 10, 1)
   end
Tstars = {
"12 And"
}

for k, starname in pairs(Tstars) do
    markT(starname)
end

---------------------------------------------------------------
-- Stars with planets discovered by the microlensing method:
markML = function(starName)
   myStar = celestia:find(starName)
   myStar:mark("white", "square", 10, 1)
   end
MLstars = {
"13 And"------
}

for k, starname in pairs(MLstars) do
    markML(starname)
end

---------------------------------------------------------------
-- Stars with planets discovered by direct imaging:
markDI = function(starName)
   myStar = celestia:find(starName)
   myStar:mark("red", "square", 10, 1)
   end
DIstars = {
"2MASSW J1207334?393254"
}

for k, starname in pairs(DIstars) do
    markDI(starname)
end
---------------------------------------------------------------
-- Stars with planets discovered by the timing method:
markTi = function(starName)
   myStar = celestia:find(starName)
   myStar:mark("yellow", "square", 10, 1)
   end
Tistars = {
"And 10"
}

for k, starname in pairs(Tistars) do
    markTi(starname)
end

However, there seems to be a problem with the last function (timing stars), as Sol is marked instead of the given star (I've tried a couple of different scenarios). Help!

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Where can I find info on how to create scripts?

Post #16by Vincent » 06.03.2010, 08:51

thefallenghost wrote:However, there seems to be a problem with the last function (timing stars), as Sol is marked instead of the given star (I've tried a couple of different scenarios). Help!
This is because "And 10" is not in your star database, so celestia:find returns Sol.
I think that making celestia:find return nil in such a case would be more coherent, though...
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #17by thefallenghost » 06.03.2010, 19:59

Ok, merci!!!

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #18by thefallenghost » 07.03.2010, 00:28

Could someone please tell me how many stars hosting exoplanets there are in Celestia by default?

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Where can I find info on how to create scripts?

Post #19by Vincent » 07.03.2010, 09:59

thefallenghost wrote:Could someone please tell me how many stars hosting exoplanets there are in Celestia by default?
There are 328 stars with exoplanets in the SVN (development) version.
I can provide a list with their names if needed, or better, a script to
extract them from the Celestia star database.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Topic author
thefallenghost
Posts: 42
Joined: 08.05.2009
With us: 15 years 4 months

Re: Where can I find info on how to create scripts?

Post #20by thefallenghost » 07.03.2010, 17:17

Thanks & wow! How did you put them on the H-R diagram?


Return to “Scripting”