Page 1 of 1

How to choose the observer in a celx

Posted: 17.05.2005, 16:56
by Vincent
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:

Posted: 19.05.2005, 12:41
by cpotting
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.

Posted: 20.05.2005, 19:22
by Vincent
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 !