Page 1 of 1

Multiple LuaHooks? Time of LuaHook initialization?

Posted: 25.06.2007, 15:35
by selden
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.

Posted: 25.06.2007, 16:20
by t00fri
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

Re: Multiple LuaHooks? Time of LuaHook initialization?

Posted: 25.06.2007, 16:46
by hank
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

Posted: 25.06.2007, 16:49
by selden
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.)