Multiple LuaHooks? Time of LuaHook initialization?

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
selden
Developer
Posts: 10192
Joined: 04.09.2002
With us: 22 years 2 months
Location: NY, USA

Multiple LuaHooks? Time of LuaHook initialization?

Post #1by selden » 25.06.2007, 15:35

1. Can multiple LuaHooks be made to work?

Having only one makes it awkward to add multiple sets of features written in Lua.

For example, one might like to include a script which checks official servers for official updates to orbital parameters while also having Vincent's LuaEdu script installed.

2. When does the initial LuaHook processing take place compared to when catalogs are loaded?

In other words, can one create catalogs from the LuaHook environment which will immediately be used? Or would Celestia have to be restarted?

NOTE I am not planning to implement any autoupdate script myself. i'm just wondering about the feasability of doing it in Lua instead of adding yet another library requirement to Celestia.
Selden

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 7 months
Location: Hamburg, Germany

Post #2by t00fri » 25.06.2007, 16:20

On this occasion of Selden's question, let me touch upon a somewhat heretic "counter"-question:

Please note, I have myself often supported the idea of delegating certain tasks to Lua. E.g. for picking and marking certain kinds of objects Lua is great and amounts to just a few lines of scripting code.

Yet, at present the Celestia specific Lua functions and thus the Lua scripting complexity keep growing strongly, while their documentation tends to stagnate.

So I ask myself, whether a piece of cleanly structured C++ code in the core wouldn't often be the better alternative for the more complex tasks of general interest!?

Certainly, Lua is the weapon of the "free-lance" add-on creators, unlike C++ code, which typically requires some arguing with the devs about usefulness etc. ;-)

I am certainly aware of a number of intrinsic advantages for doing certain tasks with Lua scripting code:

-- cross-platform
-- no compilation necessary
-- no C++ knowledge necessay

But when the arsenal of custom functions gets larger and larger, a number of the above 'pros' are loosing weight in my view.

Now we are starting to talk about multiple Lua hooks ;-)

Bye Fridger
Image

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

Re: Multiple LuaHooks? Time of LuaHook initialization?

Post #3by hank » 25.06.2007, 16:46

selden wrote:1. Can multiple LuaHooks be made to work?

Having only one makes it awkward to add multiple sets of features written in Lua.

For example, one might like to include a script which checks official servers for official updates to orbital parameters while also having Vincent's LuaEdu script installed.
Only one LuaHook init script is loaded at startup. But a master init script can be writen which loads other LuaHook scripts. So an init script could be written that updates the catalogs and also loads Vincent's LuaEdu script.

selden wrote:2. When does the initial LuaHook processing take place compared to when catalogs are loaded?

In other words, can one create catalogs from the LuaHook environment which will immediately be used? Or would Celestia have to be restarted?
I believe the LuaHook init script is loaded immediately after the configutation file is read, before the catalogs are read. So the catalogs could be updated before they're read. It wouldn't be necessary to restart.

selden wrote:NOTE I am not planning to implement any autoupdate script myself. i'm just wondering about the feasability of doing it in Lua instead of adding yet another library requirement to Celestia.

Yes, it should be feasible to use Lua for this.

I've been doing some experiments to explore the possibility a cross-platform version of Celestia using Lua to implement the application control logic (including the GUI). An autoupdate feature could easily be incorporated with this approach.

- Hank

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

Post #4by selden » 25.06.2007, 16:49

I think there are several other somewhat related reasons for using Lua:

4. adding functionality to Celestia without affecting or being affected by ongoing changes in the central repository code.

5. quick prototyping of functionality

6. private modifications that never will be made public

7. and, of course, to provide specialized functionality within Addons which are not intended to be central to the use of Celestia. (I'm thinking primarily of ScriptedOrbits and ScriptedRotations used to move, orient and animate individual spacecraft.)

I agree that appropriate documentation does need to be included when scripts are released for public use. (I tried to include appropriate inline comments in my script 6view.celx, for example, but it has a relatively limited purpose.)
Selden


Return to “Scripting”