Jump to content

How to tell if it's day or night from scripting for a given position?


Recommended Posts

Posted (edited)
27 minutes ago, cfrag said:

Time of day should be a dead give-away. timer.getAbsTime() gets the mission time. Convert to hours, minutes and seconds. 

that doesn't tell me if it's day or night for a given location and month / day...

Some places it will be night at 1600, others 1800 and then in winter/summer those could be flipped... 

Edited by Elphaba
Posted

🙂 -- so you mean when sunrise/sunset happen. 

Well, since you can't really change the time dynamically for a mission, I guess the easiest way is to look these times up in the weather panel, and put them in a table. I'm sure that - given your lat/lon - there are some formulas for this, but I've never done this in code. This may give you some joy.

 

Posted

So you're saying go to every map and play with the daytime slider for every day/month/year for each map and make a table of it? 

Sheesh... It's in the backend somewhere because the Carrier will tell you if it's CASE 2 or 3 when 'official night' kicks in - I just need that function / boolean.

Posted
Just now, Elphaba said:

So you're saying go to every map and play with the daytime slider for every day/month/year for each map and make a table of it? 

No, just for the day and map that you create the mission for. Sunrise and Sundown, if the current time of day is between those two, it's officially day.

Much better would of course be if you wrote some code that implemented the formula I linked to - that would work anywhere, any day. And could be shared (I'd like it as well 🙂

Actually, this may be much better

Posted
1 minute ago, cfrag said:

No, just for the day and map that you create the mission for. Sunrise and Sundown, if the current time of day is between those two, it's officially day.

Much better would of course be if you wrote some code that implemented the formula I linked to - that would work anywhere, any day. And could be shared (I'd like it as well 🙂

I love the document you found.. I'm just not convinced that ED are doing it that way... I could get the 'real' number but DCS could be off... so it wouldn't help me. 

And as I need this to work from scripting, it's not something the mission designer needs to get involved in. 

Posted

As an alternative you can also download the AIPs of the country and then look into GEN 2.7, there's the sunrise and sunset table published for certain locations of that country for each and every day.

Posted
2 minutes ago, razo+r said:

As an alternative you can also download the AIPs of the country and then look into GEN 2.7, there's the sunrise and sunset table published for certain locations of that country for each and every day.

HOW is that helpful for a SCRIPTING solution that can handle any map / time of year automatically?

Posted
Just now, razo+r said:

It could compare the position and date with the db and then tell you if you are in daytime or nighttime I guess?

I don't think you understand the problem or a proper solution. Thanks for playing. 🙂

Posted
On 2/24/2023 at 8:50 PM, buur said:

Is it acceptable or allowable to copy someone's code from say MOOSE or MIST and add it to my own Superscript? There is no place I can give 'acknowlegements to'. I don't know about the rules of software in circumstances like this. 

But I mean, if they've done the maths and its correct, then really, what good would it do me reinventing the wheel, other than ego or pride, when they've already made it work in Lua and DCS?

Should I reach out the devs or is it okay to copy functions and make them work in my own scripts?

Posted
4 hours ago, Elphaba said:

But I mean, if they've done the maths and its correct, then really, what good would it do me reinventing the wheel, other than ego or pride, when they've already made it work in Lua and DCS?

Copyright exists to protect the interests of those who invested themselves to create the work that other people copy. What good do you and I have from using their work? Obviously, we save a LOT of time and effort to investigate an issue, then analyze, design, code and test a solution. Obviously, the creators of MIST have nothing against that you use their work, provided that you respond in kind: that you publish your code that is based on theirs, that you make it accessible to anyone interested. It does not prevent you from profiting off their code - as long as you publish your code as well in the manner prescribed in the license (it's the standard GNU license, nothing special). 

5 hours ago, Elphaba said:

There is no place I can give 'acknowlegements to'.

If you copy code into your own, you usually place the source where you copied from (usually with a mention of the license) in the source's header.

Usually, when you later publish your work (all this is moot if you don't publish; if no-one else sees your work you don't have to acknowledge. Selling your work is regarded as publishing), there is some form of documentation that accompanies your work. You can use that for acknowledgements and directions on where to obtain your source. For example, if you publish on ED's User Files, you can use the Description. That's the place where you also put in all acknowledgements. Again, fairly standard stuff; it feels a bit administratory at first, I agree, but it can be done quickly. If you publish your mission, your code is automatically included, so you already comply with that part of MIST's license. If you sell your mission and the mission contains licensed material in a non-readable form (compiled, encrypted, anonymized etc.) you must make those parts of your code that fall under the license available to anyone who is interested in a readable form. Again, fairly standard compliance stuff that gets easier the more often you do it. 

  • Thanks 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...