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

From Wikibooks, open books for an open world
Jump to navigation Jump to search

center[edit | edit source]

center { time <duration> }

Centers the currently selected object in the display in <duration> seconds. you must first use the select command to select an object to be centered.


time <duration>
Number of seconds to take centering the object. Default is 1.0 second.

CELX equivalent:

Based on the observer:center() method.

  • Find and select target object with name <string> to be centered and store in "objectname"
objectname = celestia:find( <string> )
  • Get observer instance of the active view and center objectname.
    If no <duration> is given, the default time = 5.0 seconds !!!
obs = celestia:getobserver()
obs:center(objectname, <duration> )
  • Wait <duration> seconds.
wait( <duration> )


objectname = celestia:find( <string> )
obs = celestia:getobserver()
obs:center(objectname, <duration> )
wait( <duration> )

The following example selects the Earth and takes 5.5 seconds to center it on the screen. If you do not see the Earth, press the [G] key on your keyboard and you should see the Earth zoom into view from the center of the display.


select { object "Sol/Earth" }
center { time 5.5 }


earth = celestia:find("Sol/Earth")
obs = celestia:getobserver()
obs:center(earth, 5.5)

Back to CEL command index