Converting a cel:URL position into a celx command

All about writing scripts for Celestia in Lua and the .cel system
Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Converting a cel:URL position into a celx command

Post #21by Vincent » 05.02.2010, 17:15

Frank,

This is still the same problem, i.e., the wait() command is not working.
So all the commands that follow the wait() command won't be taken into
consideration by the script...

Code: Select all

   obs:gotolonglat(E6, math.rad(0), math.rad(0), 1.25E19, 0)
   wait(0)

   vertical = (Sa:getposition() - SBa:getposition()):normalize()
   obs:lookat(obs:getposition(), E6:getposition(), vertical)
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Topic author
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 21 years 11 months
Location: Manassas, VA

Re: Converting a cel:URL position into a celx command

Post #22by fsgregs » 05.02.2010, 17:57

OK, I give up! I tried to incorporate Martin's great hubble class addon into the Lua Edu tools package of addons that I've put together, but I guess it is not to be! Since Martin's script does in fact go to a spot in space when activated in lua tools, I assumed that by changing the parameters, we could figure out the proper orientation for the view (instead of backwards and sideways). I regret that I have tried to begin to learn the lua language, but it is simply beyond me. I have absolutely NO idea what the commands
obs:gotolonglat(E6, math.rad(0), math.rad(0), 1.25E19, 0)

vertical = (Sa:getposition() - SBa:getposition()):normalize()
obs:lookat(obs:getposition(), E6:getposition(), vertical)

mean! I've trying fooling with them and simply cannot figure out how to turn the angle of view so it is horizontal in Lua tools, and flip the view so we are looking at it forward instead of backward. I took the Wait command out and it had no effect, so that is not the problem. I'm sure there is a simple solution, but I am just not computer lua savvy enough to figure it out.

Anyway, thanks everyone for helping, but I have no choice but to remove the addon. That's a pity, since it really is a good tool for educators. :( :( :(

Regards

Frank

Avatar
Marco Klunder
Posts: 181
Joined: 20.02.2008
Age: 61
With us: 16 years 7 months
Location: The Netherlands

Re: Converting a cel:URL position into a celx command

Post #23by Marco Klunder » 05.02.2010, 19:23

Vincent wrote:This is still the same problem, i.e., the wait() command is not working.
So all the commands that follow the wait() command won't be taken into
consideration by the script...

fsgregs wrote:OK, I give up!

Frank, probably one last try.
As I understand from Vincent, there is someting with the wait() and in a previous post he also told the same about the tick() method, that's why your CELurl was previously also not working. But the wait() function is necessary to to start rendering all things you changed during the previous celx methods. In fact, without a wait() nothing will be changed on your screen :!: :!: :!:

What I recognize in your test with Cham's script is that your first goto is about doing what is must do, but the observer orientation does not do the things specified, because they are called after the wait(), which is not working properly and that's why the following celx methods are not taken into consideration.

In the celx I posted to replace your CELurl, the same occurs, because the script contains a wait(0.0) somewhere in the middle, which is not absolutely necessary there to start rendering the changes made. So it may be deleted there, leaving just 1 final wait(0.0) as a last statement in the script.
You also can try the same with Cham's script to MOVE the wait(0.0) to the final line of code.

Probably it's wishful thinking, but I was triggered for this, because I saw your example that the distance is merely correct, but the rotation is failing. With the explanation of Vincent, this problem can probably circumvented by only having 1 wait(0.0) as the last line of code in the script.
So although wait() is probably not working correct, you need it to render and probably as a final line of code in the script it probably may still render the changes made.

Marco
Last edited by Marco Klunder on 05.02.2010, 20:42, edited 2 times in total.
Marco Klunder
email: marco.klunder@xs4all.nl
Windows10 PD 3.0 GHz, 2 GB of RAM, Nvidia GeForce 6700 XL
Celestia161 / SVN + Lua Edu Tools v1.2 Beta9, Celestia160-ED and Celestia1621

Vincent
Developer
Posts: 1356
Joined: 07.01.2005
With us: 19 years 8 months
Location: Nancy, France

Re: Converting a cel:URL position into a celx command

Post #24by Vincent » 05.02.2010, 19:46

fsgregs wrote:I took the Wait command out and it had no effect, so that is not the problem.
On the contrary, this is definitely the problem here:
Since the goto command returns immediately, you do need the wait() command.
Otherwise, the script will return control to Celestia before the goto process is done.
And the problem is precisely that the wait() command is not taken into account for
the reason I have explained previously.
@+
Vincent

Celestia Qt4 SVN / Celestia 1.6.1 + Lua Edu Tools v1.2
GeForce 8600 GT 1024MB / AMD Athlon 64 Dual Core / 4Go DDR2 / XP SP3

Avatar
Topic author
fsgregs
Posts: 1307
Joined: 07.10.2002
With us: 21 years 11 months
Location: Manassas, VA

Re: Converting a cel:URL position into a celx command

Post #25by fsgregs » 06.02.2010, 00:31

IT WORKS!!!!!!

Marco, your suggestion to add the wait command back but put it at the end, worked. When I did this, your script worked just fine. The viewer went to exactly where he needed to me. Unchecking the addon checkbox turned the addon back off! It worked!!!!!

Thank you, and thanks to Vincent, Martin and all the others for your help in this :D I will put the addon back into the Lua Edu Tools addons release. Look for the release on motherlode in a few days. :D :D :D

Frank


Return to “Scripting”