Access to math/trig libraries from celX / Lua ???

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 11 months

Access to math/trig libraries from celX / Lua ???

Post #1by Chuft-Captain » 16.01.2007, 12:57

Hi,

I know you can perform the basic operations + - / and * in celX, however is it possible to access math libraries to perform more advanced scientific math within a celX script?
I haven't seen any documentation of this anywhere, however in looking at some of the things being done with Lua, I'm almost sure this must be possible, but perhaps undocumented.
Can someone enlighten me?

The functions I would like to use are all the usual suspects:
    log10,
    ln (natural logarithm),
    pi(),
    cos, sin, tan,
    acos, asin, atan,
    e,
    y^x,
    sqrt,
    ...etc
"Is a planetary surface the right place for an expanding technological civilization?"
-- Gerard K. O'Neill (1969)

CATALOG SYNTAX HIGHLIGHTING TOOLS LAGRANGE POINTS

Toti
Developer
Posts: 338
Joined: 10.02.2004
With us: 20 years 9 months

Post #2by Toti » 16.01.2007, 13:39

Yes, it's possible: simply use the namespace math
For example:
math.pow(),
math.tan(),
math.sin(), etc.

Avatar
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Post #3by selden » 16.01.2007, 14:08

Selden

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

Post #4by Chuft-Captain » 18.01.2007, 13:14

Thanks guys. That's very helpful and has covered everything I need to do (for now anyway :wink:)
"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”