Using change distance command in a cel script

Description: All about writing scripts for Celestia in Lua and the .cel system

fsgregs
Topic author
Avatar
fsgregs
Topic author
Posts: 1287
With us: 14 years 9 months
Location: Manassas, VA

#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

Goofy
Avatar
Goofy
Posts: 161
With us: 5 years 10 months
Location: Italy

#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!"
ASUS G75VX4007H- Intel i7 3630QM, 2.4 GHz-SSD 250GB+SSD 1TB, SATA 3-32GB DDR3 1600 MHz- Nvidia GeForce GTX 780MX 3 GB

selden
Avatar
selden
Posts: 10007
With us: 14 years 10 months
Location: NY, USA

#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

jogad
Avatar
jogad
Posts: 461
With us: 8 years 10 months
Location: Paris France

#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 }
}

fsgregs
Topic author
Avatar
fsgregs
Topic author
Posts: 1287
With us: 14 years 9 months
Location: Manassas, VA

#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

jogad
Avatar
jogad
Posts: 461
With us: 8 years 10 months
Location: Paris France

#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.

Goofy
Avatar
Goofy
Posts: 161
With us: 5 years 10 months
Location: Italy

#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 7 times
"Something is always better than nothing!"
ASUS G75VX4007H- Intel i7 3630QM, 2.4 GHz-SSD 250GB+SSD 1TB, SATA 3-32GB DDR3 1600 MHz- Nvidia GeForce GTX 780MX 3 GB


Return to “Scripting”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest