General Questions about Scripting

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

General Questions about Scripting

Post #1by hharris » 28.02.2006, 19:41

Here are some very general questions about scripting:

(I'm running Celstia 1.4.1 (0) on a Mac OS X)

(1) What does a question mark after a parameter in the documentation indicate?
(2) I've noticed celx is very general with function parameter passing. In one case (goto) the function name is the same for two functions. Exactly how does celx work in this regard? I assume celx looks at the number and type of paramenters that are passed and then decides how to handle the input. Is this correct? What is considered an error; that is, when does it give up? Knowing this type of information will help me design my own functions.
(3) The documentation gives a distance (microlightyears) for speed. I assume it's really microlightyears per some time unit. What is that time unit?

Though my comments don't show it, I'm actually very impressed with celx.

Thanks!

Henry 8)

hank
Developer
Posts: 645
Joined: 03.02.2002
With us: 22 years 9 months
Location: Seattle, WA USA

Re: General Questions about Scripting

Post #2by hank » 01.03.2006, 06:15

hharris wrote:Here are some very general questions about scripting:

(I'm running Celstia 1.4.1 (0) on a Mac OS X)

(1) What does a question mark after a parameter in the documentation indicate?
I believe these indicate missing information in the documentation.

hharris wrote:(2) I've noticed celx is very general with function parameter passing. In one case (goto) the function name is the same for two functions. Exactly how does celx work in this regard? I assume celx looks at the number and type of paramenters that are passed and then decides how to handle the input. Is this correct? What is considered an error; that is, when does it give up? Knowing this type of information will help me design my own functions.
There is only one function involved, not two functions with the same name. The function recognizes the different parameter types internally. You can write such a function by specifying three dots at the end of the formal parameter list in the function definition. The actual parameters are passed in a table accessed as an implicit parameter named 'arg'. This is explained in the Lua reference manual. (The celx functions are actually implemented using the Lua C API, but the effect is the same).

hharris wrote:(3) The documentation gives a distance (microlightyears) for speed. I assume it's really microlightyears per some time unit. What is that time unit?

It's probably seconds, but that's just a guess. You could write a simple script to find out for sure.

- Hank


Return to “Scripting”