It's All About Location

All about writing scripts for Celestia in Lua and the .cel system
Topic author
hharris
Posts: 79
Joined: 23.02.2006
With us: 18 years 9 months
Location: Pasadena, CA 91104

It's All About Location

Post #1by hharris » 12.02.2008, 12:41

I'd be grateful if someone could explain the Celestia "obs:getlocationflags()". I can't get it to work, probably because I don't understand it. I would think locations would attached to an object, and not an observer. But when I make the call on the observer object as documented, I don't seem to get a table.

Also, under object:getinfo() the documentation refers to a "location object" as if some objects are a different class of object.

Please give some help to the terminally confused. :(

Henry

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: It's All About Location

Post #2by chris » 13.02.2008, 21:39

hharris wrote:I'd be grateful if someone could explain the Celestia "obs:getlocationflags()". I can't get it to work, probably because I don't understand it. I would think locations would attached to an object, and not an observer. But when I make the call on the observer object as documented, I don't seem to get a table.

Locations are attached to an object. The table of location flags returned by getlocationflags just identifies what types of locations will be visibile. For example, crater labels will not be shown unless craters is set to true in the locationflags table. There is currently no way to get the list of locations in celx, but that will be fixed very soon (as in, before the end of the week.)

Also, under object:getinfo() the documentation refers to a "location object" as if some objects are a different class of object.

Please give some help to the terminally confused. :(


There's no special Lua type for location objects--they look just like other objects. You can tell if an object is a location by checking the result of the object:type() method.

--Chris

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Post #3by chris » 13.02.2008, 23:49

The locations method is now available in the latest revision of Celestia on SVN (4123). It's a method of the object class that returns a Lua iterator. The usage is straightforward. This example code prints the names of all locations for the currently selected object:

Code: Select all

function log_locations(x)
    for loc in x:locations() do
        celestia:log(loc:name())
    end
end

log_locations(celestia:getselection())


--Chris

Topic author
hharris
Posts: 79
Joined: 23.02.2006
With us: 18 years 9 months
Location: Pasadena, CA 91104

Post #4by hharris » 14.02.2008, 11:16

Great! Can you tell me where that's available for Mac OX? I couldn't find it with an Internet search.

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #5by ElChristou » 14.02.2008, 11:29

hharris wrote:Great! Can you tell me where that's available for Mac OX? I couldn't find it with an Internet search.


I can post a fresh build if you really need it.
Image

Topic author
hharris
Posts: 79
Joined: 23.02.2006
With us: 18 years 9 months
Location: Pasadena, CA 91104

Post #6by hharris » 14.02.2008, 11:41

Well, I can appreciate this is probably not a burning issue with most users, but I believe this version may help me complete a large project I've been working on for several years .

Henry

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Post #7by ElChristou » 14.02.2008, 12:24

Image

Topic author
hharris
Posts: 79
Joined: 23.02.2006
With us: 18 years 9 months
Location: Pasadena, CA 91104

Post #8by hharris » 15.02.2008, 19:36

Uh-oh. This version crashes almost immediately without doing anything except using the arrow keys. :cry:

Henry


Return to “Scripting”