Page 1 of 1

LUA scripting additions

Posted: 17.12.2003, 17:03
by alexibu
Hi All,

Ive added functionality to the LUA scripting interface.
Whether or not this functionality will apear in CVS im not sure, but if anyone is interested I have written code to:

- Allow Labels and Orbits to be switched on and off on a body by body basis.
- Allow scripting of multiple views
- Set field of view

Alex

Posted: 17.12.2003, 20:45
by don
Howdy Alex,

WOW, that sounds great! :D I'm going to have to learn some Lua scripting so I can play with all the new stuff Harald and you are adding.

Are you creating any how-to-use-them documentation as you are creating these new functions, so the rest of us can play with them too?

Thanks Alex!

-Don G.

Posted: 17.12.2003, 22:31
by Paolo
Hi Alex.

Your effort in lua scripting sounds very good.
Accidentally did you take a look to my Feature requests about scripting?
Please see the following pages FR36 and FR37.

Bye - Paolo

Posted: 18.12.2003, 01:59
by Harry
I got a working implementation of keyboard input for Lua-scripting, but this touches the UI and needs some discussion with the developers. Maybe in v1.3.2?

Harald

Posted: 27.01.2004, 13:22
by MB
Stupid problem: For various reasons I use to compile celestia both under Linux and Windows (MSDEV) . While I have complete access to LUA with Linux, No success with LUA under Windows. LUA being not an easy "script" I jut forgot it. BUT
- I got interested with the multi-view aspect of LUA
- Trying to compile celestia with the adequate version of celx, I got some error in the compile of celx, saying that appCore->views is "private". In fact the CELX is not defined as explained to me by Christophe in a e-mail. That is now clear for me BUT I cannot solve this problem. I even downloaded the full CVS celestia as a new project, without any success. I did not find in the forum where to get the info. Thanks for any help.
MB

Posted: 27.01.2004, 16:03
by Harry
MB wrote:- Trying to compile celestia with the adequate version of celx, I got some error in the compile of celx, saying that appCore->views is "private". In fact the CELX is not defined as explained to me by Christophe in a e-mail. That is now clear for me BUT I cannot solve this problem. I even downloaded the full CVS celestia as a new project, without any success. I did not find in the forum where to get the info. Thanks for any help.
MB

I guess celx.cpp shouldn't be compiled at all without CELX being defined. So you have two choices: either make sure CELX is defined (maybe ask someone with a similar compiler as yours), or remove celx.cpp from the files which should be compiled. I am not sure if it would make sense to enclose all of celx.cpp in a #ifdef CELX ... #endif, to make sure it doesn't get compiled if CELX is not set. Comments, anyone?

Posted: 27.01.2004, 16:39
by MB
Harry,
Thanks for you fast answer,
Defining CELX, That is my problem. I use MSDEV 6.0 specifically for celestia! My colleagues and me used to work with Borland (4.5 , then Builder..).NO POSSIBLE HELP locally. So I really don't know how to set CELX.
BTW, I was a little fast describing the various steps of my tries. I had no problem to compile celestia without celx, of course, or with celx after modifying manually the .dsb file by adding lua.lib lualib.lib (It should not be modified manually!! but everything works without LUA).
I did not get any problem before, the cvs code used to compile without additional work of my own.
MB

Posted: 27.01.2004, 17:52
by Harry
MB wrote:Defining CELX, That is my problem.

I am sure there must be some dialog where this can be set (like project settings), but as I don't have VC++ I don't know where.
AFAIR someone here simply added a "#define CELX" near the top in celestiacore.h - this probably should work, maybe this suffices for your needs 8)

Harald

Posted: 27.01.2004, 21:34
by don
MB wrote:Trying to compile celestia with the adequate version of celx, I got some error in the compile of celx, saying that appCore->views is "private".

Chris only uses the makefile files (makerelease.bat and makedebug.bat). You can use either of these to compile Celestia with Lua.

If you want to compile from within Visual Studio then you need to update the DSP Workspace file(s) for affected project, in this case /src/celestia/Celestia.dsp. I recently did this for VC++ 6, DEBUG mode only, so I could use breakpoints and single-step operations. If you want to try my file, you can get if from here: http://s94992504.onlinehome.us/celestia/Celestia.dsp. Install it in /src/celestia/.

If you try it, please let me know if it works for you.

-Don G.

Posted: 28.01.2004, 14:28
by MB
Harry, Don
Thank you for your kind efforts: the last celestia-cvs works now WITH LUA! But some explanations and one question:

Don, I tried your .dsp without success
Actually, your .dsp is very similar to mine except you have
SOURCE=..\..\inc\lua\lua.h that I don't have
Actually this line does not seem to be not necessary in my case since I introduced such .h extra files in (from the tool bar) tools/options/directories/includes
C:\PROGRAM FILES\GNU\NEW_LIB\INC\LIBJPEG
C:\PROGRAM FILES\GNU\NEW_LIB\INC\LIBZ
C:\PROGRAM FILES\GNU\NEW_LIB\INC\LIBPNG
C:\PROGRAM FILES\GNU\NEW_LIB\INC\LUA
and libs in tools/options/directories/libraries:
C:\PROGRAM FILES\GNU\NEW_LIB\LIB
BTW, I did not see that CELX be defined neither in the .dsp NOR in any place in the whole GNU folder !
I thought it was defined through the CVS procedure.
then I switched to the Harry suggestion:

"#define CELX" near the top in celestiacore.h" allows to compile the celx file and provides an .exe file that works well and allows me to run at least the basic .celx scripts, I should find the recent scripts of Harryin the Forum, I hope, to proceed further!
Actually I made a stupid error by defining CELX in celx.h. Of course its compile well but does not allow to run LUA scripts.
Then, my question to Don for my full understanding : did you also define CELX in celestiacore.h as suggested to me by Harry? Again thanks a lot
MB

Posted: 28.01.2004, 15:33
by Harry
MB wrote:then I switched to the Harry suggestion:

"#define CELX" near the top in celestiacore.h" allows to compile the celx file
Of course I never would suggest to do such an ugly thing - I just wrote that it should work :wink:

MB wrote:and provides an .exe file that works well and allows me to run at least the basic .celx scripts, I should find the recent scripts of Harryin the Forum, I hope, to proceed further!

My scripts are at http://www.h-schmidt.net/celestia/, except for some variants of the solarsystem-tour which only are linked from somewhere here in the forum.

Harald

Posted: 28.01.2004, 16:06
by MB
Yes, I found It works very well.

I have to learn LUA now, Do you make some write-up of your many lua functions? otherwise I will study them with the celx.cpp file
MB

Posted: 28.01.2004, 16:32
by Harry
MB wrote:I have to learn LUA now, Do you make some write-up of your many lua functions? otherwise I will study them with the celx.cpp file
MB

The objects and methods specific to celestia-scripting are (tersely) documented in the summary on the same webpage - to learn Lua itself you probably have to refer to other documentation, maybe on http://www.lua.org/

Harald

Posted: 29.01.2004, 02:03
by don
Sorry about that MB. I could have sworn I had it working the other night. I just tried it now, and get the same errors you did <frown>. Maybe I gave up the other night and just copied the output from makedebug instead? Who knows.

When adding something to a source file (celestiacore.h), will this change be overwritten the next time this file is changed on CVS? Or does that depend on the utility one uses to synchronize local files?

-Don G.

Posted: 29.01.2004, 10:55
by MB
Don,
I just update CVS a few minutes ago and I got this:
....
M celestia/src/celengine/celengine.dsp
P celestia/src/celengine/universe.cpp
cvs server: Updating celestia/src/celestia
M celestia/src/celestia/Celestia.dsp
M celestia/src/celestia/celestiacore.h
RCS file: /cvsroot/celestia/celestia/src/celestia/celx.cpp,v
retrieving revision 1.46
retrieving revision 1.47
Merging differences between 1.46 and 1.47 into celx.cpp
M celestia/src/celestia/celx.cpp
M celestia/src/celestia/celx.h
P celestia/src/celestia/gtkmain.cpp
...

MSDEV re-compile the celengine ( new universe.cpp ) and celestia "projects" (I tried to tweak a bit my celx.cpp to solve my problems before the Harry solution, just forgetit, but I checked that celestiacore.h was not modified by CVS although I
introduced the define CELX). Finally the new .exe is OK including LUA scripts
MB

Posted: 29.01.2004, 21:01
by don
Thank you MB. That's good to know.

Posted: 29.01.2004, 22:13
by Harry
MB wrote:I just update CVS a few minutes ago and I got this:
....
Merging differences between 1.46 and 1.47 into celx.cpp
M celestia/src/celestia/celx.cpp
...

Note that merging isn't always successful with modified files, the file may not compile anymore. So it's still better to find the correct solution (make the build-tool define CELX). If you run into problems with the current solution, you should get a fresh copy of the modified files (deleting them and then updating CVS should be ok).

Harald

Posted: 30.01.2004, 09:20
by MB
Thanks, Harry, Although I don't have problems presently, I keep your warnings in mind. I agree that I should use the :
build-tool define CELX
I tried to do that, unfortunately I did not find how to do that and I don't have any help installed in my MSDEV version!
Incidently, I found in my LUA folder the write - up that you wrote some times ago about the celestia-lua functionalities. This a very clear document. We can easily update it when new functinalities are installed. Sorry for my late request, everything was already done, but with age, we forget...
However, one question bothers me, I leaned in your paper the unability of LUA to handle 128 bits data. May be you noticed that some times ago that we discussed this point with Don about the .cel scripts. To solve our problems, Christophe then introduced the seturl { url "cel://...} command that turns out to be extremely efficient to write a .cel script: we have no longer to bother with rotation, vector algebra .... The unability of LUA to handle such very big number is clearly a drawback for an astro code. Do you think the bigFix stuff written by the celestia developpers can be used in LUA?
MB

! [/quote]

Posted: 30.01.2004, 13:43
by Harry
MB wrote:However, one question bothers me, I leaned in your paper the unability of LUA to handle 128 bits data. May be you noticed that some times ago that we discussed this point with Don about the .cel scripts. To solve our problems, Christophe then introduced the seturl { url "cel://...} command that turns out to be extremely efficient to write a .cel script: we have no longer to bother with rotation, vector algebra .... The unability of LUA to handle such very big number is clearly a drawback for an astro code. Do you think the bigFix stuff written by the celestia developpers can be used in LUA?

I should clarify this:
Lua-scripting has "position"-objects, which have full 128 bits per component (i.e. they are UniversalCoords, which uses BigFix). Then there are vectors (Vec3d), which have 64 bits per component. And of course the normal numbers in Lua, which too have 64 bits per component (type double) - and this is what you get if you retrieve a single component from a position (position:getx()), so there is possibly some loss involved.

If I got the numbers right normal 64 bit numbers should be precise to less than 1cm (probably <1mm) for scales of 1 AU. I.e. if you take a position (with full 128 bits) and add a vector of about 1 AU length, the resulting position will be exact within <1 cm. You will run into problems when you are using vectors from e.g. the sun to some far away star (or even galaxy), the precision will be reduced (of course there is less chance of noting this loss of precision, as there are no small objects there to which you could compare your position).

As long as you can use short (am I just calling 1 AU short?) vectors relative to some position, there shouldn't be much of a problem. Having a seturl-command would be nice, but the current URL-code always uses the current active observer/view - which isn't nice for MultiViews. I would like to hear of any specific problem you run into with the currently available feature-set, so tell me if this will work for you as it is now.

Harald

Posted: 30.01.2004, 15:52
by MB
Harald,
Thanks for the information, You know I am just got interested in LUA recently. So I need sme time before giving you typical examples. Actually Ie don't really need a method similar to seturl { url "cel://...}. I can use the position information provided by the seturl {.... and uses them "manually" . He will play with that during the weekend.
MB