MadKreator Posted January 9, 2024 Posted January 9, 2024 (edited) Hey all of you scripting gurus! Not sure if its possible, nor if this is this the correct place to ask, but I’m curious is theres a way to pull the time of day ( in 24 hour format) from DCS. My use case being, In a helios profile I’m building, I was hoping to be able to use a script to pull the time if day from dcs or from a mission, to use as a trigger to be able to change the background sky in the profile between morning, day, evening and night depending on the actual time in the mission. I’m pretty sure I can make the events trigger fine as far as helios goes, but I don’t know if any line of script will pull the actual time of day, to create the trigger. I can do it off of the cockpit clock, but its only 12 hour so I have no way to distinguish AM from PM doing it that way. open to any ideas or things to try. I know it’s not ME related but wasn’t sure where to start asking around. Edited January 9, 2024 by MadKreator Intel i7 13700k, ASUS rog strix z790A, 64gigs G.Skill Trident DDR5 @6400Mhz, Nvidia RTX 4080FE, 4TB, 2x 2TB, 1TB Samsung NVME, 1TB Samsung SSD, Corsair RM1000x, Corsair Titan 360 X AIO cooler, Lian Li LanCool 2, VKB Gunfighter Ultimate, VKB Custom STECS , MFG Crosswinds, Moza FFB, Virpil Collective, Track IR5, 48” LG UltraGear OLED & HP 24” touchscreen for Helios,49” Samsung Ultrawide, Streamdeck XL, Corsair Virtuoso RGB Headphones
Solution Terminator357 Posted January 9, 2024 Solution Posted January 9, 2024 (edited) The function "timer.getTime" might work. It returns elapsed game time in seconds. There's 86400 seconds in a 24 hr day. Not as ideal as 24hr time but you can still count 'x' hours worth of seconds and run whatever scripts or triggers you want off that. https://wiki.hoggitworld.com/view/DCS_func_getTime edit: Simpler approach: You can set the mission start time, then just do the math for elapsed time in seconds and add a "Time More" condition to a script when you want the background to change. Edited January 9, 2024 by Terminator357
MadKreator Posted January 9, 2024 Author Posted January 9, 2024 7 hours ago, Terminator357 said: The function "timer.getTime" might work. It returns elapsed game time in seconds. There's 86400 seconds in a 24 hr day. Not as ideal as 24hr time but you can still count 'x' hours worth of seconds and run whatever scripts or triggers you want off that. https://wiki.hoggitworld.com/view/DCS_func_getTime Thanks for the link! Just what I needed .. looks like “timer.getAbsTime() “ is probably what will work.. similar but says it returns the time of day in seconds, noon=43200 midnight=0 etc.. Intel i7 13700k, ASUS rog strix z790A, 64gigs G.Skill Trident DDR5 @6400Mhz, Nvidia RTX 4080FE, 4TB, 2x 2TB, 1TB Samsung NVME, 1TB Samsung SSD, Corsair RM1000x, Corsair Titan 360 X AIO cooler, Lian Li LanCool 2, VKB Gunfighter Ultimate, VKB Custom STECS , MFG Crosswinds, Moza FFB, Virpil Collective, Track IR5, 48” LG UltraGear OLED & HP 24” touchscreen for Helios,49” Samsung Ultrawide, Streamdeck XL, Corsair Virtuoso RGB Headphones
cfrag Posted January 9, 2024 Posted January 9, 2024 It's indeed timer.getAbsTime(). If you have a long-running mission, it may contain the seconds for the elapsed days as well. Here's a short routine that will return the current number of seconds since 0 hours: local absSecs = timer.getAbsTime() while absSecs > 86400 do absSecs = absSecs - 86400 -- subtract out all days end
MadKreator Posted January 9, 2024 Author Posted January 9, 2024 30 minutes ago, cfrag said: It's indeed timer.getAbsTime(). If you have a long-running mission, it may contain the seconds for the elapsed days as well. Here's a short routine that will return the current number of seconds since 0 hours: local absSecs = timer.getAbsTime() while absSecs > 86400 do absSecs = absSecs - 86400 -- subtract out all days end Okay that makes sense. Scripting isn’t really in my bag of tricks. But I’m slowly understanding it more and more. I was kind if wondering if it would keep counting up after 24 hrs. Thank you for the advice Intel i7 13700k, ASUS rog strix z790A, 64gigs G.Skill Trident DDR5 @6400Mhz, Nvidia RTX 4080FE, 4TB, 2x 2TB, 1TB Samsung NVME, 1TB Samsung SSD, Corsair RM1000x, Corsair Titan 360 X AIO cooler, Lian Li LanCool 2, VKB Gunfighter Ultimate, VKB Custom STECS , MFG Crosswinds, Moza FFB, Virpil Collective, Track IR5, 48” LG UltraGear OLED & HP 24” touchscreen for Helios,49” Samsung Ultrawide, Streamdeck XL, Corsair Virtuoso RGB Headphones
MadKreator Posted January 9, 2024 Author Posted January 9, 2024 I just need to find the right control to use as a trigger in Helios.. I think I can trick the version/ information control ( which is a timer of sorts) so when it does a version check every 60 seconds, that it will run that script to get the time from the game. Then I have my trigger I can set to each new image, and I can tell the action to hide or unhide each screen base on a time range the trigger pulled: if >= 0 or < 21,600 then hidden=false else hidden= true ( obviously completely incorrect syntax and totally made up) But the idea is there, just need to learn a bit more about lua to write it correctly.. I have a couple months before the project is done, plenty of time. Again, I appreciate the help and advice! Intel i7 13700k, ASUS rog strix z790A, 64gigs G.Skill Trident DDR5 @6400Mhz, Nvidia RTX 4080FE, 4TB, 2x 2TB, 1TB Samsung NVME, 1TB Samsung SSD, Corsair RM1000x, Corsair Titan 360 X AIO cooler, Lian Li LanCool 2, VKB Gunfighter Ultimate, VKB Custom STECS , MFG Crosswinds, Moza FFB, Virpil Collective, Track IR5, 48” LG UltraGear OLED & HP 24” touchscreen for Helios,49” Samsung Ultrawide, Streamdeck XL, Corsair Virtuoso RGB Headphones
cfrag Posted January 9, 2024 Posted January 9, 2024 12 minutes ago, MadKreator said: if >= 0 or < 21,600 Be careful with your guards - any number that is 0 or higher will fulfil above two constraints with OR. Try 80'000. It's >= 0. You probably meant AND, not or. Figuring out conditions can be irritating at first, but it will become natural after a while. 1
MadKreator Posted January 9, 2024 Author Posted January 9, 2024 (edited) 4 hours ago, cfrag said: Be careful with your guards - any number that is 0 or higher will fulfil above two constraints with OR. Try 80'000. It's >= 0. You probably meant AND, not or. Figuring out conditions can be irritating at first, but it will become natural after a while. Oh yes I completely made up the conditions and syntax lol I will sort that when I start actually playing with it.. But you are correct, AND would be the correct condition not OR, now that I think about it to have it anywhere in that range. I have experience with conditions and logic controls but only on things like radio control airplanes and some time controller devices. I’m still at square one of writing any sort of lua script. Edited January 9, 2024 by MadKreator Intel i7 13700k, ASUS rog strix z790A, 64gigs G.Skill Trident DDR5 @6400Mhz, Nvidia RTX 4080FE, 4TB, 2x 2TB, 1TB Samsung NVME, 1TB Samsung SSD, Corsair RM1000x, Corsair Titan 360 X AIO cooler, Lian Li LanCool 2, VKB Gunfighter Ultimate, VKB Custom STECS , MFG Crosswinds, Moza FFB, Virpil Collective, Track IR5, 48” LG UltraGear OLED & HP 24” touchscreen for Helios,49” Samsung Ultrawide, Streamdeck XL, Corsair Virtuoso RGB Headphones
MadKreator Posted January 10, 2024 Author Posted January 10, 2024 Chatting with the Helios dev, he’s not convinced the commands for mission editor will be viable.. DCS has its own set of scripts available to use for exports for “telemetry” usage. There was a couple he found related to model and mission time. Not sure still whether those are Zulu or Lima times. Not that the timer.getAbsTime() wouldn’t pull time correctly, just may not work as an “exported” trigger. Out of my realm of knowledge. I tend to trust the Helios dev’s word when it comes to Helios integration Still willing to give anything a shot. Intel i7 13700k, ASUS rog strix z790A, 64gigs G.Skill Trident DDR5 @6400Mhz, Nvidia RTX 4080FE, 4TB, 2x 2TB, 1TB Samsung NVME, 1TB Samsung SSD, Corsair RM1000x, Corsair Titan 360 X AIO cooler, Lian Li LanCool 2, VKB Gunfighter Ultimate, VKB Custom STECS , MFG Crosswinds, Moza FFB, Virpil Collective, Track IR5, 48” LG UltraGear OLED & HP 24” touchscreen for Helios,49” Samsung Ultrawide, Streamdeck XL, Corsair Virtuoso RGB Headphones
cfrag Posted January 11, 2024 Posted January 11, 2024 9 hours ago, MadKreator said: Chatting with the Helios dev, he’s not convinced the commands for mission editor will be viable.. I do not know what Helios is, nor how you planned to interface with it - IIRC your question was how to get the in-game time of day in 24 hour format. A quick check shows that "Helios" may refer to a virtual cockpit API, so I assume that you'll need (as you already did) contact the author to see how you can pass information to Helios. So it appears that you are on the right track 9 hours ago, MadKreator said: Not that the timer.getAbsTime() wouldn’t pull time correctly, just may not work as an “exported” trigger. Be advised that AFAIK DCS does not report Zulu time, but map local (a game-only concept that breaks with reality). So maps with multiple time zones (e.g. South Atlantic) will currently only return correct time if you are in the correct time zone, the one that was used to create the map. Looking at what you are trying to do, you'd probably also want to look up sunrise and sundown for the current time zone, another challenge since that's not readily available in DCS. Otherwise, you'd have unusable results for most times of the year in some maps (like previously mentioned South Atlantic - where (down South) the sun rises really late in June/July and it sets really early.
MadKreator Posted January 11, 2024 Author Posted January 11, 2024 7 hours ago, cfrag said: I do not know what Helios is, nor how you planned to interface with it - IIRC your question was how to get the in-game time of day in 24 hour format. A quick check shows that "Helios" may refer to a virtual cockpit API, so I assume that you'll need (as you already did) contact the author to see how you can pass information to Helios. So it appears that you are on the right track Be advised that AFAIK DCS does not report Zulu time, but map local (a game-only concept that breaks with reality). So maps with multiple time zones (e.g. South Atlantic) will currently only return correct time if you are in the correct time zone, the one that was used to create the map. Looking at what you are trying to do, you'd probably also want to look up sunrise and sundown for the current time zone, another challenge since that's not readily available in DCS. Otherwise, you'd have unusable results for most times of the year in some maps (like previously mentioned South Atlantic - where (down South) the sun rises really late in June/July and it sets really early. Yes you are correct, Helios Virtual Cockpits. I’ve been working with / helping the Helios dev with things for some time now and I found a real l liking in creating the virtual touchscreen cockpits. You said just as he did..the Helios API has its own set of rules to play with and the standard functions for ME triggers and things, don’t necessarily work. Valid points on the sunrise/sunset. I think maybe the best thing is for me to just keep this as a “vanity project” and not bother incorporating it into my profiles. I can always just put in a simple rotary switch to change the skyline ( not that its of any real interest to users). Thank you for your time chatting with me about this. Scripting/ coding is not my cup of tea (at least not yet), so I appreciate your patience and advise! Intel i7 13700k, ASUS rog strix z790A, 64gigs G.Skill Trident DDR5 @6400Mhz, Nvidia RTX 4080FE, 4TB, 2x 2TB, 1TB Samsung NVME, 1TB Samsung SSD, Corsair RM1000x, Corsair Titan 360 X AIO cooler, Lian Li LanCool 2, VKB Gunfighter Ultimate, VKB Custom STECS , MFG Crosswinds, Moza FFB, Virpil Collective, Track IR5, 48” LG UltraGear OLED & HP 24” touchscreen for Helios,49” Samsung Ultrawide, Streamdeck XL, Corsair Virtuoso RGB Headphones
Recommended Posts