Using change distance command in a cel script

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 22 years 1 month
Location: Manassas, VA

Using change distance command in a cel script

Post #1by fsgregs » 02.07.2017, 18:15

Hi all:

I am writing a simple script to display some text on the screen while Celestia is flying through space. I have an old script that sends the program through space with the"changed distance" command. An example would be:

select { object "HIP 83266" }

changedistance { duration 15.0 rate -0.01 }
print { text " Live long and prosper\n\n \n\n " row -14 column 26}
wait { duration 10.0 }

The problem with the above set of commands is timing. The script begins the program flying toward HIP 83266 slowly over a 15 second duration ... THEN the fly-in stops and the program displays the text "Live long and prosper". What I want to do is display the text simultaneously, while the fly-in is occurring.

Can that be done either in a cel or celx script?

Thanks in advance
Frank

Avatar
Goofy
Posts: 280
Joined: 30.08.2011
With us: 13 years 2 months
Location: Italy

Using change distance command in a cel script

Post #2by Goofy » 02.07.2017, 22:27

Hi Frank.
Probably I misunderstood what you need, but if I didn't, this works as I understand you requested for:

Code: Select all

[color=#008040][b]{
select {object "Sol"}
goto {time 1.0 distance 50}
wait {duration 1}
center {}
follow {}
print { text "Live long and prosper" origin "topleft" duration 15 row 5 column 3}
changedistance { duration 15.0 rate 1.7 }
wait { duration 15.0 }
} [/b][/color]

Try it, hope it works for you.
Bye
Goofy :smile:
"Something is always better than nothing!"
HP Omen 15-DC1040nl- Intel® Core i7 9750H, 2.6/4.5 GHz- 1TB PCIe NVMe M.2 SSD+ 1TB SATA 6 SSD- 32GB SDRAM DDR4 2666 MHz- Nvidia GeForce GTX 1660 Ti 6 GB-WIN 11 PRO

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

Post #3by selden » 02.07.2017, 22:42

As Goofy mentions, you might be able to fake it: use multiple "change distance" commands with the first going to some intermediate object that you've defined which is only part way to the final destination. The print statement could be in between the first and second changedistance commands, for example.

What is really needed is some kind of asynchronous event trigger which would cause the string to be emitted. I think it might be possible to do something like this from within a ScriptedOrbit or ScriptedRotation, but those declarations can only be used for SSC objects.

Lua (celx scripts) supports multitasking, but I dunno if it'll work within Celestia.
Selden

Avatar
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 2 months
Location: Paris France

Post #4by jogad » 03.07.2017, 09:39

Your script is almost correct.

- You must follow the object before the changedistance command.
In the print command the text is displayed duration seconds but the next command is processed immediately.
You just have to invoque the printcommand before the changedistance command and specify the same duration.

Here is the working code :

Code: Select all

{
select { object "HIP 83266" }
follow{}
print { text " Live long and prosper\n\n \n\n " duration 15 row -14 column 26}
changedistance { duration 15.0 rate -0.01 }
}

Avatar
Topic author
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 22 years 1 month
Location: Manassas, VA

Post #5by fsgregs » 03.07.2017, 12:53

Thanks guys for the reply. I can indeed print some text first, then start the program changing distance. I tried that and the print did occur, then the fly-in began, and nothing else happened on the screen until the fly-in was done. The print stayed on screen during the entire fly-in. It was sequential. What I meant to explain was my hope that there would be a way to display 4 or five text messages on a screen one after the other, while the fly-in is occurring. Sort of like the credits of a movie. The movie is playing in the background (the fly-in), while multiple credits appear on the screen in front of the moving scene one after the other. Both actions would have to be simultaneous.

I am hoping that we could use a "while / then" loop, or something like it. While a counter is counting or the changeddistance command is being executed, we can also print X, then print Y, then print Z, one after the other.

Is that possible in LUA?

Frank

Avatar
jogad
Posts: 458
Joined: 17.09.2008
With us: 16 years 2 months
Location: Paris France

Post #6by jogad » 03.07.2017, 13:30

I don't see any way to do that with only one changedistance instruction.
The simplest way is the one that Selden proposes : cut out the journey into several parts and display a text for each part.

Avatar
Goofy
Posts: 280
Joined: 30.08.2011
With us: 13 years 2 months
Location: Italy

Using change distance command in a cel script

Post #7by Goofy » 04.07.2017, 13:25

Hi Frank, try this cel script, it allows some text typing on the screen and changing text while action occurs.
May be it is what you wish.
Bye
Goofy :smile:

Tryme.rar
Little .cel script for text-on-screen variations
(744 Bytes) Downloaded 353 times
"Something is always better than nothing!"
HP Omen 15-DC1040nl- Intel® Core i7 9750H, 2.6/4.5 GHz- 1TB PCIe NVMe M.2 SSD+ 1TB SATA 6 SSD- 32GB SDRAM DDR4 2666 MHz- Nvidia GeForce GTX 1660 Ti 6 GB-WIN 11 PRO


Return to “Scripting”