Spacecraft iterator in celX???

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 6 months

Spacecraft iterator in celX???

Post #1by Chuft-Captain » 19.01.2009, 01:10

Hi,

This may be a stupid question but is there a spacecraft iterator in Lua/celX?

eg. Take this:

Code: Select all

   for dso in celestia:dsos() do
      for i,v in ipairs(LG_big_galaxies) do
           if dso:name() == v then
              dso:mark( "green", "disk",10, 1, v )
         end
      end

I want to do something like:

Code: Select all

   for spacecraft in celestia:spacecrafts() do
      for i,v in ipairs(my_list_of_spacecraft) do
           if spacecraft:name() == v then
              spacecraft:mark( "green", "disk",10, 1, v )
         end
      end


Get my drift??

Thanks in advance...
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

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

Re: Spacecraft iterator in celX???

Post #2by Vincent » 19.01.2009, 19:08

Chuft-Captain wrote:This may be a stupid question but is there a spacecraft iterator in Lua/celX?
CC,

This is not a stupid question. There's no spacecraft iterator available in celx so far.
You'll have to search for spacecraft through the list of all solar system bodies.
@+
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

SU(3)xSU(2)xU(1)
Posts: 59
Joined: 05.05.2008
With us: 16 years 1 month

Re: Spacecraft iterator in celX???

Post #3by SU(3)xSU(2)xU(1) » 19.01.2009, 20:13

Chuft-Captain wrote:I want to do something like:

Code: Select all
for spacecraft in celestia:spacecrafts() do
for i,v in ipairs(my_list_of_spacecraft) do
if spacecraft:name() == v then
spacecraft:mark( "green", "disk",10, 1, v )
end
end



Chuft-Captain,

You can use the following code:

Code: Select all

         for i,v in ipairs(my_list_of_spacecraft) do
               local w = celestia:find(v)
                w:mark( "green", "disk",10, 1, v )
          end


This should work if "my_list_of_spacecraft" is a list of strings.

Paul
"Physicists know what's important, but they don't know what is true. Mathematicians know what's true, but they don't know what is important."

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 6 months

Re: Spacecraft iterator in celX???

Post #4by Chuft-Captain » 19.01.2009, 21:13

Vincent wrote:
Chuft-Captain wrote:This may be a stupid question but is there a spacecraft iterator in Lua/celX?
CC,

This is not a stupid question. There's no spacecraft iterator available in celx so far.
You'll have to search for spacecraft through the list of all solar system bodies.
I was afraid you'd say that!! :(

Do you know how to access these in Lua, or better yet: is there a way to access all the children of a specified parent object (eg. Earth )?
This would speed things up considerably.

What I'm looking at doing is writing a script to selectively mark (according to some yet to be decided criteria) selected groups of jdavies satellites: viewtopic.php?f=6&t=13343

The current count in his addon is 2918.

Cheers
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

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

Re: Spacecraft iterator in celX???

Post #5by Vincent » 19.01.2009, 21:24

Chuft-Captain wrote:Do you know how to access these in Lua, or better yet: is there a way to access all the children of a specified parent object (eg. Earth )?
The following lines create a table containing all the children of Earth:

Code: Select all

earth = celestia:find("Sol/Earth")
earth_children = earth:getchildren()

More information is available at the Celestia Wiki celx page.
@+
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

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 6 months

Re: Spacecraft iterator in celX???

Post #6by Chuft-Captain » 19.01.2009, 21:44

SU(3)xSU(2)xU(1) wrote:

Code: Select all

         for i,v in ipairs(my_list_of_spacecraft) do
               local w = celestia:find(v)
                w:mark( "green", "disk",10, 1, v )
          end


This should work if "my_list_of_spacecraft" is a list of strings.

Paul
Thanks Paul, that seems to work nicely.
CC
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 6 months

Re: Spacecraft iterator in celX???

Post #7by Chuft-Captain » 19.01.2009, 23:12

Thanks guys,

Here's a very rudimentary test version: DELETED - see next post below
This is what it does:
marked-satellites.jpg


This sort of works but needs a lot of work. Does not seem to mark all the selected objects according to the criteria. eg. Doesn't seem to mark the FENGYUN 1C Debris at all. (I think I need a better approach to pattern matching in the string.find statements).
Last edited by Chuft-Captain on 20.01.2009, 08:00, edited 2 times in total.
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Avatar
Topic author
Chuft-Captain
Posts: 1779
Joined: 18.12.2005
With us: 18 years 6 months

Re: Spacecraft iterator in celX???

Post #8by Chuft-Captain » 20.01.2009, 07:57

Here's a new improved bunch of scripts that mark a few selected types of satellites in different colours as well as the more than 2000 bits of junk from the FENGJUN 1C satellite that the Russians shot down a while ago.
(You must have jdavies satellites installed: http://shatters.net/forum/viewtopic.php?f=6&t=13343
show_satellites_v1.jpg
show_satellites_v2.zip
Just unzip into your scripts folder and you should find them in the File->Scripts menu.

This contains:
1. Mark Satellites
2. Mark FENGYUN 1C Debris
3. Mark Satellites and Debris
4. Unmark ALL

After you've run the scripts: click on this celURL
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS


Return to “Scripting”