When I saw your code I started wondering why I assumed that star in celestia:stars() can't be used here; and went around the world via the approaches I've mentioned instead.
I modified your code to be able to reduce marking down to the stars in between two distances from the selection; 99 and 101 light years from Altair for example. To achieve the result in the thread title, radius1 needs to be set to 0 and radius2 to 40
Code: Select all
-- Title: Mark all stars inside the difference between two spheres of radius 30 and 40 LY, centered on your current selection.
function mark_star_dist(obj, radius1, radius2)
for star in celestia:stars() do
if star:getposition():distanceto(obj:getposition()) > radius1 and radius2 >= star:getposition():distanceto(obj:getposition()) then
--star:unmark()
star:mark("ffffff", "square", 9, 0.7, star:name(), true)
end
end
end
--celestia:unmarkall()
objname = ""
obj = celestia:getselection()
-- Radius of the sphere (in ly / km_to_ly):
radius1 = 30 / 0.00000000000010570
radius2 = 40 / 0.00000000000010570
while true do
obj = celestia:getselection()
if obj and objname ~= obj:name() then
objname = obj:name()
mark_star_dist(obj, radius1, radius2)
end
wait(0)
end
I've left celestia:unmarkall() commented out as to not counteract stacking
By commenting out star:mark(...) and removing the -- from star:unmark() one can swiftly undo previously made markings.