Get Sector Time in scripts

Hey,

I'm currently working on a simple script giving me the distances of a selected body to all other major bodies in a solar system. To calculate the correct orbits I need to set the current Time to the orbits of the bodies.

My question is now: Is there a way to get the current time set in the UI of Astrosynthesis in a script? If not, what's the easiest way to calculate the time value for orbits based on a date?

Thanks for the help
loofou

Comments

  • edited September 30

    I don't think there's a way to get the time that's set in the display. You may have to ask for it with a dialog popup or something.

    To calculate positions at a give time, what you need to do is call the body's GetOrbit() method. That returns an Orbit object that represents the body's orbital parameters. On that Orbit object, you'd use the SetTime() method to pass it a time. When you do that, the Orbit object's PositionX, PositionY, and PositionZ properties are updated.

    API doc, if you don't have it:
    https://www.nbos.com/support/docs/AlienAPI/index.html

  • Yes, that's what I have.

    My problem is to calculate the exact time float I have to put into the Orbit object. I don't know what the base day is it starts from, so I can't calculate an exact date. That's why I was asking for a way to get the current time from the UI or at least the formula used there to calculate the time float used in the orbits.

    To make it short: How do I get from 2100-01-01 to the time float in days for the orbits? Without knowing which date is 0 this is impossible to figure out.

    Thanks for the help so far :smile:
  • The date value is relative to whatever the epoch date is for the sector. So if you consider Jan 1st, 3000 to be your epoch, and you want the position on Jan 10th, you'd use 10 as the value for the date. The actual epoch date depends on your universe. There's no 'correct' value, basically. Its all relative around the date that you arbitrarily decide to use as the epoch date.

  • Thank you, that makes total sense. It's been years since I created this map and I totally forgot I can set the epoch year myself :smile:

Leave a Comment