How to choose the observer in a celx

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

How to choose the observer in a celx

Post #1by Vincent » 17.05.2005, 16:56

Hi,

Could someone tell me how to choose the observer's window in a celx script ? I need to insert two cel scripts in a celx script, each one for a specific view.

For instance, in the celx script below, I want to have two specific views of earth. I managed to split the screen and apply my first cel script to the second view, but I don't know how to select the first view for the other cel script...

I can (try to) explain it again if that's not clear enough... 8O


-- define one single view
celestia:getobserver():singleview()
observers = celestia:getobservers()


-- split the view horizontaly
observers[1]:splitview("h", 0.5)
wait(0.5)


-- define the cel script to apply in the second view
function CEL(source)
local script = celestia:createcelscript(source)
while script:tick() do
wait(0)
end
end

CEL([[
{
select { object "Sol/Earth" }
follow {}
goto { time 5 distance 5 }
wait { duration 5 }
}
]])



-- I want to define here the cel script to apply in the other view
-- ...


Thanks a lot for any help

PS : Sorry, this topic has to be moved in the script forum... :oops:
@+
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

cpotting
Posts: 164
Joined: 18.03.2004
Age: 63
With us: 20 years 8 months
Location: Victoria, BC Canada

Post #2by cpotting » 19.05.2005, 12:41

Unfortunately, CEL scripts are only able to act on the active observer, and neither CEL nor CELX have the ability to change which is the active observer.

however, CELX does have the ability to act on each observer independently, as you can see below:

Code: Select all

EARTH = celestia:find("Sol/Earth")
LUNA  = celestia:find("Sol/Earth/Moon")
celestia:getobserver():singleview()
celestia:getobserver():splitview("h", 0.5)

obsvrs = celestia:getobservers()

obsvrs[1]:follow(EARTH)
obsvrs[2]:follow(LUNA)
obsvrs[1]:gotodistance(EARTH, EARTH:radius() * 5, 5)
obsvrs[2]:gotodistance(LUNA, LUNA:radius() * 5, 5)
wait(5)


The observers can be assigned and passed as parameters

Code: Select all

topview=obsvrs[2]
function mygoto(obj, view)
   view:gotodistance(obj, obj:radius() * 5, 5)
end

mygoto(LUNA, obsvrs[1])
mygoto(EARTH, topview)
wait(5)

Perhaps you can change your idea to use CELX commands operating on specific observers, rather than CEL commands that can only operate on the active observer.
Clive Pottinger
Victoria, BC Canada

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

Post #3by Vincent » 20.05.2005, 19:22

Cpotting,

Thanks a lot for your reply and your confirmation that the active observer can't be choosen in a script.

I knew I could use these CELX commands on specific observers, but I feel more comfortable with cel script (I have to create a rather complicated script to make the rotation axis of the earth inclination change).

Anyway, your little pieces of script will be useful for my project ! Thanks again !
@+
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


Return to “Scripting”