Celestia/Celx Scripting/CELX Lua Methods/CEL command changedistance

changedistance
changedistance { duration  rate  } 

Changes the camera's distance from the currently selected object in  seconds, with the specified , to achieve a certain .

You must first use the select command to select an object.

Note:  is NOT specified in the CEL changedistance command.

CELX equivalent:

Based on the observer:gotodistance method.

The observer:gotodistance method uses  to determine to goto and has NO ability to define the . So you first have to find out the resulting distance using the CEL: changedistance command at the specified  and then convert that distance into the  parameter of the observer:gotodistance method.


 * Find the target object with name  to go to and store in "objectname".

objectname = celestia:find(  )


 * Select "objectname" to be equivalent with CEL scripting. Actually, this step is not necessary in CELX scripting!

celestia:select(objectname)


 * Get observer instance of the active view and goto given  of "objectname" in  seconds.
 *  is the distance from the center of target where to stop in km.
 * If no  is given, the default distance = 20000 km.
 * If <distance> is smaller than the radius of the object, the goto ends within the object !!!
 * To obtain the radius of an object in km, you can use the object:radius method.
 * <duration> is the number of seconds the goto should take.
 * If no <duration> is given, the default time = 5.0 seconds !!!

obs = celestia:getobserver obs:gotodistance(objectname, <distance>, <duration> )


 * Wait <duration> seconds.

wait

Summarized:

objectname = celestia:find( <string> ) celestia:select(objectname) obs = celestia:getobserver obs:gotodistance(objectname, <distance>, <duration> ) wait( <duration> )

Example: The following example selects the Sun, travels to it, then selects Earth, travels to it, and then spends 2.5 seconds changing the display distance to be further away from the Earth.

CEL:

select { object "Sol" } goto  { time 3 } wait  { duration 5 } select { object "Sol/Earth" } goto  { time 3 } wait  { duration 5 } changedistance { duration 2.5 rate 0.5 } wait  { duration 2.5 }

CELX:

sun = celestia:find("Sol") celestia:select(sun) obs = celestia:getobserver obs:goto(sun, 3.0) wait(5.0) earth = celestia:find("Sol/Earth") celestia:select(earth) obs:goto(earth, 3.0) wait(5.0) obs:gotodistance(earth, 89048+6378, 2.5) wait(2.5)

Back to CEL command index