CELX Script trip from earth to the sun

All about writing scripts for Celestia in Lua and the .cel system
Topic author
Dandelion
Posts: 8
Joined: 23.06.2009
With us: 15 years 4 months

CELX Script trip from earth to the sun

Post #1by Dandelion » 23.09.2009, 11:48

Hello,

I need a celx script that takes me from the earth to the sun at a given speed in real time. I don't need anything fancy just as simple as possible. I thought that this would do the trick

Code: Select all

obs = celestia:getobserver()

sol = celestia:find("Sol")
celestia:select(sol)
obs:center(sol)

obs:setspeed(0.0225)


but for some reason it takes me away from the sun and towards it.

Cheers,
Thomas

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

Re: CELX Script trip from earth to the sun

Post #2by Vincent » 23.09.2009, 12:26

Thomas,

You may want to try something like:

Code: Select all

obs = celestia:getobserver()

sol = celestia:find("Sol")
celestia:select(sol)
obs:center(sol)
wait(5)

obs:setspeed(0.5)

dist = sol:radius() * 5
while sol:getposition():distanceto(obs:getposition()) > dist do
    wait(0)
end

obs:setspeed(0.0)
@+
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

Topic author
Dandelion
Posts: 8
Joined: 23.06.2009
With us: 15 years 4 months

Re: CELX Script trip from earth to the sun

Post #3by Dandelion » 30.09.2009, 10:53

Hi Vincent,
thanks for the script its just what I needed!!

Now my next question: After reaching the sun I want to pass by it (no problem here I managed that) and than look back at it. So how can I trigger the keyboard shortcut shift + * (rear view) with in a script?

Greetings,
Thomas


Return to “Scripting”