A script to mark all pulsars

All about writing scripts for Celestia in Lua and the .cel system
Avatar
Topic author
Cham M
Posts: 4324
Joined: 14.01.2004
Age: 60
With us: 20 years 10 months
Location: Montreal

A script to mark all pulsars

Post #1by Cham » 27.07.2007, 17:28

Here's a celx code to mark all pulsars (based on some script from Vincent).

Code: Select all

-- Title: Mark all pulsars

function mark_spectraltype(x)
    local obs = celestia:getobserver()
    local nstars = celestia:getstarcount()
    local i = 0
--    while i < nstars do
--        star = celestia:getstar(i)
    for star in celestia:stars() do
        first, last = string.find(star:spectraltype(), x, 1, true)
        if first == 1 then
            star:mark("#8000ff", "plus", 5)
        end
        i = i + 1
    end
end

spectral = "Q"
celestia:flash("Marking all " .. spectral .. " stars.")
mark_spectraltype(spectral)



This is very handy for the pulsars database update (from ANTF) that I'm doing right now.

Here's a similar script to unmark the pulsars. I don''t know if this is the shortest script that can do the same. Maybe there's annother way. Vincent ?

Code: Select all

-- Title: unmarks all the pulsars

function unmark_spectraltype(x)
    local obs = celestia:getobserver()
    local nstars = celestia:getstarcount()
    local i = 0
--    while i < nstars do
--        star = celestia:getstar(i)
    for star in celestia:stars() do
        first, last = string.find(star:spectraltype(), x, 1, true)
        if first == 1 then
            star:unmark()
        end
        i = i + 1
    end
end

spectral = "Q"
celestia:flash("unmarking all " .. spectral .. " stars.")
unmark_spectraltype(spectral)
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"

Return to “Scripting”