predefined print/asString methods for celx objects ?

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Rjp buisson
Posts: 31
Joined: 18.03.2002
With us: 22 years 8 months
Location: Paris France

predefined print/asString methods for celx objects ?

Post #1by Rjp buisson » 22.04.2004, 19:45

I am quite new to Celestia +Lua programming but I know Object language programming.
I first need lot of testing on methods availables in Celx
Is there a default method available offering a sort of 'asString' functionality:
I mean a method returning a string containing the values of the members of any instance of common objets of Celestia, which could then be printed on screen:
for exemple:
earth.getposition() asString
number asString
vector asString
observer.getposition() asString
frame asString ???
Thanks

Harry
Posts: 559
Joined: 05.09.2003
With us: 21 years 2 months
Location: Germany

Re: predefined print/asString methods for celx objects ?

Post #2by Harry » 22.04.2004, 22:07

Rjp buisson wrote:Is there a default method available offering a sort of 'asString' functionality:

No, this is not available. There is a "tostring( )" function, which will return a string for the various objects, but the string will only give the type of object (like "[observer]" etc.).

Harald

don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 4 months
Location: Colorado, USA (7000 ft)

Re: predefined print/asString methods for celx objects ?

Post #3by don » 23.04.2004, 02:42

Hi Rjp,

Welcome to Celestia scripting! :D

Rjp buisson wrote:earth.getposition() asString
number asString
vector asString
observer.getposition() asString
frame asString ???

"number asString" could use the Lua function "tostring(number)". The "string.format (formatstring, number1, number2, ...)" function provides more control over formatting a number for display.

The type(var) function returns the type of variable (userdata, string, number, etc.).

To obtain the XYZ values for a vector or position object, you can use the Celx getx(), gety(), and getz() methods for each.

Hope this helps.
-Don G.
My Celestia Scripting Resources page

Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.


Return to “Scripting”