Jump to content

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

From Wikibooks, open books for an open world

setframe

[edit | edit source]

setframe { ref <refstring> target <tarstring> coordsys <coordstring> }

Set the currently active Coordinate System.

Arguments:

ref <refstring>
Defines the reference (first) object. No default.
target <tarstring>
Is optional and defines the target (second) object, for 2-object coordinate systems, such as lock. No default.
coordsys <coordstring>
Default "universal".
Must be one of the following values:
  • 1.6.0 bodyfixed
  • chase
  • ecliptical
  • equatorial
  • geographic → (same as bodyfixed, maintained here for compatibility with older scripts)
  • lock
  • observer
  • universal


CELX equivalent:

Based on the celestia:newframe() and observer:setframe() methods.

  • Find and select the reference object with name <refstring> and store in "objectname_ref".
    Not needed for frame type "universal".
objectname_ref = celestia:find( <refstring> )
celestia:select(objectname_ref)
  • Find the target object with name <tarstring> which must be locked with "objectname_ref" and store on "objectname_tar".
    Only needed for frames of type lock.
objectname_tar = celestia:find( <tarstring> )
  • Create new reference frame and store in "frame".
    <coordstring> describs the type of frame and can be one of the following:
    • "universal", "ecliptic", "equatorial", "planetographic", "observer", "lock", "chase", 1.6.0 "bodyfixed".
    • In Celestia version 1.6.0, the name "bodyfixed" will replace "planetographic", although for compatibility reasons, the name "planetographic" will continue to work.
frame = celestia:newframe( <coordstring>, objectname_ref, objectname_tar)
  • Get observer instance of the active view and set the coordinate system of the frame of reference to "frame".
obs = celestia:getobserver()
obs:setframe(frame)

Summarized:

objectname_ref = celestia:find( <refstring> )
celestia:select(objectname_ref)
objectname_tar = celestia:find( <tarstring> )
frame = celestia:newframe( <coordstring>, objectname_ref, objectname_tar)
obs = celestia:getobserver()
obs:setframe(frame)


Example:
The following example sets the Coordinate System to lock, which locks the Earth and Moon together on the display.

CEL:

setframe { ref "Sol/Earth" target "Sol/Earth/Moon" coordsys "lock" }

CELX with the celestia:newframe() and observer:setframe() methods:

earth = celestia:find("Sol/Earth")
celestia:select(earth)
moon = celestia:find("Sol/Earth/Moon")
frame = celestia:newframe("lock", earth, moon)
obs = celestia:getobserver()
obs:setframe(frame)


Back to CEL command index