Page 1 of 1

predefined print/asString methods for celx objects ?

Posted: 22.04.2004, 19:45
by Rjp buisson
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

Re: predefined print/asString methods for celx objects ?

Posted: 22.04.2004, 22:07
by Harry
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

Re: predefined print/asString methods for celx objects ?

Posted: 23.04.2004, 02:42
by don
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.