Page 1 of 1

Spacecraft iterator in celX???

Posted: 19.01.2009, 01:10
by Chuft-Captain
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

Re: Spacecraft iterator in celX???

Posted: 19.01.2009, 19:08
by Vincent
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.

Re: Spacecraft iterator in celX???

Posted: 19.01.2009, 20:13
by SU(3)xSU(2)xU(1)
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

Re: Spacecraft iterator in celX???

Posted: 19.01.2009, 21:13
by Chuft-Captain
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

Re: Spacecraft iterator in celX???

Posted: 19.01.2009, 21:24
by Vincent
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.

Re: Spacecraft iterator in celX???

Posted: 19.01.2009, 21:44
by Chuft-Captain
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

Re: Spacecraft iterator in celX???

Posted: 19.01.2009, 23:12
by Chuft-Captain
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).

Re: Spacecraft iterator in celX???

Posted: 20.01.2009, 07:57
by Chuft-Captain
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