How to make an active add-on switch off based on my location?

Have a question about using Celestia? Check here first for FAQs and helpful advice.
Forum rules
Please help to make this forum more useful by checking the FAQs before posting! Keep it clean, keep it civil, keep it truthful, stay on topic, be responsible, share your knowledge.
Topic author
john71
Posts: 1004
Joined: 10.08.2016
With us: 7 years 9 months

How to make an active add-on switch off based on my location?

Post #1by john71 » 13.01.2022, 12:39

Maybe it's my fault but I can't find any clue how to do it.

I want to switch off an add-on (make it invisible), when I'm inside of the Milky Way.

Is it possible?

How to make an active add-on switch off when I'm inside of the Milky Way, but switch on, when I'm outside of it?

Avatar
SevenSpheres
Moderator
Posts: 822
Joined: 08.10.2019
With us: 4 years 7 months

Post #2by SevenSpheres » 13.01.2022, 15:41

You can use a celx script to toggle an object's visibility, like this:

Code: Select all

if not celestia:find("MW"):visible() then
    celestia:find("MW"):setvisible(true)
elseif celestia:find("MW"):visible() then
    celestia:find("MW"):setvisible(false)
end


You might be able to set it up so visibility depends on whether you're in the Milky Way. Try the celx scripting guides on Wikibooks.
My Addons: viewtopic.php?f=23&t=19978 • Discord server admin
Celestia versions: 1.5.1, 1.6.1, 1.6.2, 1.7.0, and some unofficial versions like Celestia-ED

Topic author
john71
Posts: 1004
Joined: 10.08.2016
With us: 7 years 9 months

Post #3by john71 » 13.01.2022, 15:57

Thank you!

But it just toggles the "switch off", doesn't it?

What I would like to achieve is that it automatically switches on/off, depending on my location...


Return to “Help Central”