This function helps to draw the viewers attention to the object you are trying to point out by shrinking a marker of your description from a beginning to ending size, in x steps, repeated y times.
The code posted below is the "simple" version.
For a version that includes parameter checking, error reporting and automatic default values, download this file (9 KB): http://www.donandcarla.com/Celestia/celx_scripting/ShrinkMarker_v1-1.celx.txt.
As always, you can visit my Celestia web page for more scripting resources (http://www.donandcarla.com/Celestia/).
Enjoy!
-Don G.
Code: Select all
--***************************************************************************
-- Don G's Celx/Lua Shrink Marker Function *
-- (version 1.1) *
-- *
-- This function helps to draw the viewers attention to the object you *
-- are trying to point out by shrinking a marker of your description from *
-- a beginning to ending size, in x steps, repeated y times. *
-- *
--***************************************************************************
function shrinkMarker(yourObject, markerColor, markerType, markerSizeBegin,
markerSizeEnd, shrinkWait, shrinkSteps, shrinkRepeat,
leaveMarkerOn)
local shrinkBy = (markerSizeBegin - markerSizeEnd) / shrinkSteps
local x1, x2 = 0
yourObject:unmark() -- make sure the object is not currently marked
for x1 = 1, shrinkRepeat do
local markerSize = markerSizeBegin
for x2 = 1, shrinkSteps do
yourObject:mark ( markerColor, markerType, markerSize ) --ON
markerSize = markerSize - shrinkBy
wait(shrinkWait)
yourObject:unmark() --OFF
end
end
if (leaveMarkerOn) then
yourObject:mark ( markerColor, markerType, markerSizeEnd )
end
end
--***************************************************************************
-- Change Log *
-- *
-- Version 1.1 *
-- ----------- *
-- * Added the shrinkWait parameter to allow the user to define how long *
-- each marker will be displayed, without having to modify the actual *
-- function code. *
-- *
-- * Moved two variables out of the loop areas (suggested by Toti). *
-- *
-- * Modified the example code. *
-- *
--***************************************************************************
--***************************************************************************
-- Parameter Descriptions *
-- ---------------------- *
-- *
-- yourObject: (Object) A variable you define as an OBJECT type. *
-- Example: 'myObject = celestia:find("Sol/Earth")' creates an *
-- OBJECT type variable named 'myObject'. *
-- *
-- markerColor: (String) In hex format: "#rrggbb" where r g b = Hex *
-- 0-F *
-- Example colors... *
-- Red = "#FF0000" *
-- Green = "#00FF00" *
-- Blue = "#0000FF" *
-- White = "#FFFFFF" *
-- Black = "#000000" *
-- *
-- markerType: (String) "diamond", "triangle", "square", "plus", or *
-- "x" *
-- *
-- markerSizeBegin: (Integer) Size of beginning marker, in pixels *
-- markerSizeEnd: (Integer) Size of ending marker, in pixels *
-- shrinkWait: (Float) # of seconds to pause between drawing markers *
-- shrinkSteps: (Integer) # of steps to shrink from Begin to End size *
-- shrinkRepeat: (Integer) # of times to repeat the process *
-- leaveMarkerOn: (Boolean) true=on false=off *
-- *
----------------------------------------------------------------------------*
-- NOTES: *
-- 1. Remember to use the leading "#" in markerColor *
-- *
-- 2. Remember to perform ... celestia:show("markers") first *
-- *
-- 3. As of version 1.3.2 pre7, Celx limits the size of a marker to 100 *
-- pixels. Hopefully, a newer version will raise this limit. *
--***************************************************************************
--***************************************************************************
-- Example *
--***************************************************************************
obs = celestia:getobserver()
-- Select, Center, Follow and Goto an object (Earth, at 25K km)...
myObject = celestia:find("Sol/Earth")
celestia:select(myObject)
obs:gotodistance(myObject, (25000 + myObject:radius()), 5)
wait(5)
-- Make sure Marker display is ON...
celestia:show("markers")
-- Shrink a red, 100 pixel 'diamond' to 5 pixels, in 10 steps, pausing
-- for 0.05 seconds between drawing the markers, and repeat everything
-- three times...
shrinkMarker(myObject, "#FF0000", "diamond", 100, 5, 0.05, 10, 3, false)
--***************************************************************************
-- End of script
--***************************************************************************
celestia:print("The End.", 2, -1, -1, 1, 4)
wait(2)