Celx Flash Marker function

All about writing scripts for Celestia in Lua and the .cel system
Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 4 months
Location: Colorado, USA (7000 ft)

Celx Flash Marker function

Post #1by don » 05.03.2004, 08:53

Here is a simple Lua/Celx function that flashes the specified marker type, color and size on the specified object, for x number of times, along with a code example and explanation of the function parameters. Enjoy!

-Don G.

Code: Select all

--***************************************************************************
--                  Don G's Celx/Lua Flash Marker Function                  *
--                              (version 1.0)                               *
--                                                                          *
-- This function helps to draw the viewers attention to the object you are  *
-- trying to point out.                                                     *
--                                                                          *
--***************************************************************************
  function flashMarker(yourObject, markerColor, markerType, markerSize,
                       flashTimes, leaveMarkerOn)
    yourObject:unmark() -- make sure the object is not currently marked
   
    for x = 1, flashTimes do
      yourObject:mark ( markerColor, markerType, markerSize ) --ON
      wait(0.5)
      yourObject:unmark() --OFF
      wait(0.5)
    end

    if (leaveMarkerOn) then
      yourObject:mark ( markerColor, markerType, markerSize )
    end
  end
 

--***************************************************************************
--                                 Example
--***************************************************************************
  obs = celestia:getobserver()


  -- Select, Center, Follow and Goto an object (Earth, at 250K km)...
  myObject = celestia:find("Sol/Earth")
  celestia:select(myObject)
  obs:center(myObject)
  obs:follow(myObject)
  obs:gotodistance(myObject, (250000 + myObject:radius()), 5)
  wait(5)

 
  -- Make sure Marker display is ON...
  celestia:show("markers")

 
  -- Flash the specified marker on the object...
  flashMarker(myObject, "#7174F3", "x", 40, 3, false)

    -- flashMarker() parameters:
    --  yourObject object
    --  markerColor string (in hex format: "#rrggbb" where r,g,b = 0 to f)
    --  markerType string ("diamond", "triangle", "square", "plus", or "x")
    --  markerSize integer (in pixels)
    --  flashTimes integer (# of times to flash the marker)
    --  leaveMarkerOn boolean (true [on] or false [off])

    -- NOTES:
    --  1. Remember to use the leading "#" in markerColor
    --  2. Remember to perform ... celestia:show("markers") first
 

--***************************************************************************
--                           End of script
--***************************************************************************
  celestia:print("This script is now finished.", 2, -1, -1, 1, 10)
  wait(2)
 
Last edited by don on 24.04.2004, 07:02, edited 3 times in total.

Topic author
don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 4 months
Location: Colorado, USA (7000 ft)

Post #2by don » 24.04.2004, 05:35

Here is a more complex version, that includes parameter verification, error reporting, and automatic default values...

http://www.donandcarla.com/Celestia/celx_scripting/FlashMarker_v1-1.celx.txt
-Don G.
My Celestia Scripting Resources page

Avatar: Total Lunar Eclipse from our back yard, Oct 2004. Panasonic FZ1 digital camera (no telescope), 36X digital zoom, 8 second exposure at f6.5.


Return to “Scripting”