Just thought I'd ask!

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 16 years 8 months
Location: Germantown, Ohio - USA

Just thought I'd ask!

Post #1by Bob Hegwood » 09.03.2004, 04:25

Sorry, but does anyone have any interest in new cel scripts? I know you all are having wet dreams with celx, but I simply don't like the damned things thus far.

I'd like to be able to continue writing more of my touring scripts, but if no one wants them, I'm not going to waste my time. Wanted to do Neptune and Uranus next. Yes? No?

Just thought I'd ask.

Thanks, Bob
Bob Hegwood
Windows XP-SP2, 256Meg 1024x768 Resolution
Intel Celeron 1400 MHz CPU
Intel 82815 Graphics Controller
OpenGL Version: 1.1.2 - Build 4.13.01.3196
Celestia 1.4.0 Pre6 FT1

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #2by don » 09.03.2004, 06:15

Bob,

Your tour scripts are EXCELLENT, and there is no reason to "throw in the towel".

It really doesn't matter which of the Celestia scripting languages a person uses, as long as it meets their needs. The end-user (viewer) could care less whether it's a Cel or Celx script, as long as they are entertained / educated. See what I mean?

Celx scripting doesn't replace Cel scripts. Rather, it goes above and beyond Cel by using a third-party, full-blown, object-oriented type of language plug-in (Lua). Cel is fairly straight forward and simple to grasp the basics (with a guide) for most non-programmers. Celx, on the other hand, is easy only if a person has experience in the world of OOP. Ollie Oop maybe? :lol:

The decision as to which scripting language to use is based primarily on a person's experience, either as a script writer, or as an OO programmer. So, pick the one you LIKE and use it. :D

Chris wrote in the past that new additions to Cel scripting will be limited, but that Celx additions will continue. Not sure why this is, because Cel is much easier for non-programmers to understand and use. We'll see as time goes on.

Maybe Harald will come up with a way to allow each language to call the other language. By doing this, Celx gurus could write Celx scripts as functions to be called from a Cel script.

Keep those tour scripts comin' Bob! :D

Cheers,

-Don G.

Topic author
Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 16 years 8 months
Location: Germantown, Ohio - USA

Post #3by Bob Hegwood » 09.03.2004, 06:52

Appreciate the moral support, Don...

You know, I have experimented with the celx scripts, and I've downloaded over 15 of them altogether just to see what all the fuss is about. I see that you can do some really spectacular and sexy graphics-type thingys with them, but I have yet to find one that performs as expected. Again, the only celx scripts I have downloaded which actually did what I thought they'd do are yours.

I expect a script to educate me in some manner, not to wow me with the very latest in technology. Oh well, I'm just an old geezer, so this is to be expected I guess. At any rate, I'm still playing with celx. I'd much rather be providing some more tours though.

Anybody else?

Thanks, Bob
Bob Hegwood

Windows XP-SP2, 256Meg 1024x768 Resolution

Intel Celeron 1400 MHz CPU

Intel 82815 Graphics Controller

OpenGL Version: 1.1.2 - Build 4.13.01.3196

Celestia 1.4.0 Pre6 FT1

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #4by don » 09.03.2004, 07:08

Bob Hegwood wrote:Appreciate the moral support, Don...
You are quite welcome Bob. I'm sure there are other Cel script-writers that feel just like you do. I'm no expert so I too have to learn Lua/celx one method (function) at a time. It takes time.


Bob Hegwood wrote:Anybody else?

If you keep stats on your web site activity, check the number of times your tour script files have been downloaded. LOTS of people actively seek and download new materials, but simply do not post to the forums.

Cheers!

-Don G.

Harry
Posts: 559
Joined: 05.09.2003
With us: 16 years 10 months
Location: Germany

Post #5by Harry » 09.03.2004, 10:59

don wrote:Maybe Harald will come up with a way to allow each language to call the other language. By doing this, Celx gurus could write Celx scripts as functions to be called from a Cel script.

Argh. I really looked for a technical reasons why this couldn't work. But oh horror: it does work. And as Bob already threatened to kill me, I had to do something, right?

Great, it's possible (currently for me only) to execute CEL-scripts within CELX-scripts. To be more precise: it's possible to execute any string which contains a valid CEL-script in Lua. You can even execute two (or three, four, ...) CEL-scripts at the same time. What a mess.

But wait, what would you want to do with it? This won't bring Keyboard-input or MultiViews to CEL :( It may be nice for those who already know CEL, but it does not really add functionality.

How it works:

Code: Select all

cel_source = [[
{ ... }
]]
script = celestia:createcelscript(cel_source)
while script:tick() do
  wait(0)
end

First you need a string (here: "cel_source") which contains the sourcecode of the CEL-script. Then you create a script from it, by calling celestia:createcelscript( ... ).
Then you can pass control to this script (script:tick() ), which will then do whatever it should have done in the time that has passed since you last called script:tick(). I.e. if the script would run a minute, and you wait a minute until you call tick(), the script will instantly reach it's end - so you better call tick() often, like for every frame (which is what Celestia does internally).
script:tick() will return true as long as it's running, and false once it has reached it's end.

Harald

Added Later: The code will for some time not be in CVS, I will wait until the discussion about background-scripts has come to some conclusion (changes are currently mixed).

MB
Posts: 128
Joined: 19.07.2002
With us: 17 years 11 months
Location: Paris France

Post #6by MB » 09.03.2004, 12:54

Bob,
I learned a lot with your script. I can only repeat the comment of Don. They are EXCELLENT. Please Go On,
I also wrote Cel and CELX scripts (With the help of Harry!) concerning the Galileo trip. I also agree with your feeling and the comments of Don.

So please Go on!
MB

jestr
Posts: 612
Joined: 14.09.2003
With us: 16 years 9 months
Location: Bridgwater,UK

Post #7by jestr » 09.03.2004, 13:16

Yeah,please keep the scripts coming Bob they are really cool,Jestr

Topic author
Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 16 years 8 months
Location: Germantown, Ohio - USA

Post #8by Bob Hegwood » 09.03.2004, 18:00

Jestr, MB...

Thanks for the comments. I like creating the tours, but if no one wanted them, there wouldn't be much point. :wink:

Take care, Bob
Bob Hegwood

Windows XP-SP2, 256Meg 1024x768 Resolution

Intel Celeron 1400 MHz CPU

Intel 82815 Graphics Controller

OpenGL Version: 1.1.2 - Build 4.13.01.3196

Celestia 1.4.0 Pre6 FT1

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #9by don » 10.03.2004, 06:04

Sorry guys ... spent the day in town today. So, I'm just catching up now...

Harry wrote:Great, it's possible (currently for me only) to execute CEL-scripts within CELX-scripts.
Good work Harald! Glad to know you can get it working in this direction (run cel from celx).

Have you played with the other direction at all -- running a celx script from cel? I think this would be the most-used direction, as noted in an earlier message.


Harry wrote:But wait, what would you want to do with it?
One thing that comes immediately to mind ... This direction (run cel from celx) will allow folks to create a celx menu of existing cel scripts that can be run at the press of a button -- without having to re-write the cel scripts in celx.


Harry wrote:How it works:
Looks clean and simple, thank you Harald! :D


Harry wrote:The code will for some time not be in CVS, I will wait until the discussion about background-scripts has come to some conclusion (changes are currently mixed).

Agreed. It is good to look at and play with different variations, to find what will be the safest, quickest running, most robust, etc. -- within Chris' specified constraints.

Cheers,

-Don G.

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #10by don » 10.03.2004, 06:08

Bob Hegwood wrote:I like creating the tours, but if no one wanted them, there wouldn't be much point. :wink:

Now you know there are at least three forum members who ENJOY your scripts Bob! :lol: ... But, as we all know, the REAL number is probably in the hundreds or thousands.

So ... when were you planning on releasing that Uranus tour? Or was it Neptune, my old mind forgets? :wink:

-Don G.

Topic author
Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 16 years 8 months
Location: Germantown, Ohio - USA

Post #11by Bob Hegwood » 10.03.2004, 06:15

don wrote:So ... when were you planning on releasing that Uranus tour? Or was it Neptune, my old mind forgets? :wink:


Started the basic research and a preliminary script for Neptune yesterday. Already run into a snag though. Seems that Neptune no longer has a Great Dark Spot... After looking for different textures, I found that we're pretty much stuck with the one we have.

Sooo... I'm thinking that I'll keep the texture as it is, and just provide an explanation to the effect that it's no longer there.

I've been researching this topic all day now. Fun stuff. :wink:

I am still surprised that no one has mentioned this before. Especially since the scientists on the forum almost certainly know that the GDS is no longer there. Where is the outcry? :lol:

Seems that you can "fake" it when it's convenient eh?

Take care, Bob
Bob Hegwood

Windows XP-SP2, 256Meg 1024x768 Resolution

Intel Celeron 1400 MHz CPU

Intel 82815 Graphics Controller

OpenGL Version: 1.1.2 - Build 4.13.01.3196

Celestia 1.4.0 Pre6 FT1

Harry
Posts: 559
Joined: 05.09.2003
With us: 16 years 10 months
Location: Germany

Post #12by Harry » 10.03.2004, 07:21

I am surprised there is any doubt about this, so:
I too like your scripts, Bob! And I really don't mind if they aren't written in Lua. :D

Harald

Harry
Posts: 559
Joined: 05.09.2003
With us: 16 years 10 months
Location: Germany

Post #13by Harry » 10.03.2004, 07:44

don wrote:Have you played with the other direction at all -- running a celx script from cel? I think this would be the most-used direction, as noted in an earlier message.

I tried to point out (must have been in some other thread) that this actually isn't needed. Say you have this CEL-script, and want to wait for a keypress after the first goto by calling some CELX-code:

Code: Select all

{
        select { object "Io" }
        goto { time 5 }
        celx { "---> Wait for keypress (Lua code)  <---" }

        select { object "Earth" }
        goto { time 5 }
        ....

It's IMHO trivial to rewrite this as:

Code: Select all

function CEL(str) { something copy & pasted }
CEL([[
{
        select { object "Io" }
        goto { time 5 }
}
]])
        ---> Wait for keypress (Lua code) <---
CEL([[
{
        select { object "Earth" }
        goto { time 5 }
        ....
]])

I know it doesn't look quite as nice. But once you try to add Lua-code within a string in a CEL-script this could quickly change.

And I just noticed there would be a serious problem: keyboard-input wouldn't work at all, because Celestia would only know it's currently executing a CEL-script (which doesn't use keyboard-input), and doesn't know there is a CELX-script hidden inside which is actually interested in keypresses.

Harald

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #14by don » 10.03.2004, 08:16

Hi Harald,

Let's just use the other thread / topic for this discussion about calling cel from celx and celx from cel, so we don't double-post. :)

-Don G.

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #15by don » 10.03.2004, 08:20

Bob Hegwood wrote:Started the basic research and a preliminary script for Neptune yesterday. Already run into a snag though. Seems that Neptune no longer has a Great Dark Spot...

Say what?! 8O ... Where did it go? The storm just plain stopped? Or maybe it was a smudge on someone's telescope lens all along? :lol:

I'm amazed that both Fridger and Grant missed this one.

When did it go away?

You are quite the explorer / researcher Bob! :D

-Don G.

Guest

Post #16by Guest » 10.03.2004, 08:32

don wrote:Where did it go? The storm just plain stopped? Or maybe it was a smudge on someone's telescope lens all along? :lol:

I'm amazed that both Fridger and Grant missed this one.

When did it go away?

You are quite the explorer / researcher Bob! :D

Has been missing from Neptune since 1994. During that year, the HST was used to do a thorough search of Neptune, and the Great Dark Spot was no longer on its surface. :wink:

How about that. You mean us dummies know something that the scientists don't? :lol: I doubt that. Probably it was just more convenient to not mention it, because of the reasons I have identified earlier. Apparently, Neptune likes to change its face frequently.

Take care, Bob

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #17by don » 10.03.2004, 08:41

It's been gone for TEN YEARS?

Amazing.

don
Posts: 1709
Joined: 12.07.2003
With us: 16 years 11 months
Location: Colorado, USA (7000 ft)

Post #18by don » 10.03.2004, 08:54

One reason why the existing texture is being used ... to replay the Voyager encounter ...

http://shatters.net/forum/viewtopic.php?t=1583

-Don G.

Toti
Developer
Posts: 338
Joined: 10.02.2004
With us: 16 years 5 months

Post #19by Toti » 10.03.2004, 14:06

Bob:
I enjoy your scripts, too. Please, keep making them.
But now that you ask, I think that you should take a look at the new Lua scripting support. Harald's work is impressive, and it will make your job easier.
I know cel scripting is tedious: you need to adjust delays so the text messages doesn't dissapear out of time, but taking care of overall script lenght, tweaking the viewer's movements so they flow smoothly, etc. In short words, a lot of trial and error testing.
With Lua, instead, you can define:
    * a constant, let's say SECONDS_PER_CHARACTER = 0.5
    * a function that takes one of your text messages and counts its characters. Then multiplies this number by the constant that you already defined and saves into a variable, say 'delaytime'
    * a function that takes your text message and the variable 'delaytime' and prints it on screen and waits 'delaytime' seconds
This way longer messages will have more time on screen than shorter ones, but without annoying manual tweaking. As you see, thanks to a few lines of code, the computer does all the job, and you are free of one boring, trial-and-error task. If you notice that the script is too fast, you only need to change SECOND_PER_CHARACTER value to, let's say 0.6
Another example:
You can define a simple structure:
    body, lat., long., altitude, message

And then fill this structure with data, regarding interesting features for certain bodies:

Code: Select all

Mars         56.875       43.893         1232          "look at this..."
Enceladus    23.234       12.192         589           "look at that..."
...
...
...

And then, using a function (that you need to define) make a tour to all this bodies, showing the interesting features specified on the list, and displaying the corresponding messages.
This function can be as complex as you want: it can do smooth, elegant moves when going from one location to another, it can signal the specified location with intermittent markers, etc.
Note how simple is to add a new location to this script: one more entry:

Code: Select all

Europa       22.773      43.761          786           "look at those..."

..and that's all.
Even more, you can add code to split the text message into small pieces, so it doesn't get cut by screen limits, etc.
As you see, a lot of added functionality. (Please note that this examples might need some extra Lua internal support within Celestia that might be not present today. Harald has the knowledge here)

Of course, learning a programming language is not an easy task, but there should be a beginner's scripting guide out there.
Anyway, keep the good job! :)

Bye

Topic author
Bob Hegwood
Posts: 1048
Joined: 19.10.2003
With us: 16 years 8 months
Location: Germantown, Ohio - USA

Post #20by Bob Hegwood » 11.03.2004, 03:01

Toti wrote:Bob:
I enjoy your scripts, too. Please, keep making them.
But now that you ask, I think that you should take a look at the new Lua scripting support.

Toti,

I have looked at celx and all it's done so far is give me a headache! :oops:

Hell, I can't even concentrate on your message long enough to understand what you're even trying to tell me. I just plain-old don't like celx. What can I tell ya? When you start defining things in terms of OOP, my mind just says "To Hell with this," and you lose me.

I'm Brain-Dead remember?

I'll keep trying to use it, but it'll have to be in small doses for now.

Take care, Bob
Bob Hegwood

Windows XP-SP2, 256Meg 1024x768 Resolution

Intel Celeron 1400 MHz CPU

Intel 82815 Graphics Controller

OpenGL Version: 1.1.2 - Build 4.13.01.3196

Celestia 1.4.0 Pre6 FT1


Return to “Scripting”

Who is online