![]() |
How to obtain in-game time?
I'm still experimenting with scripting stuff for the sim and I've come across a problem I haven't found a solution for: How do I get the in-game time?
I've experimented with Mission.Time but it seems all values are just offsets from the instant when the mission started. There's the concept of "real" time but that also seems to be an offset and unless I can figure out the mission start time it's of no use (at least for what I'm trying to do). I had an idea that maybe I could read the start time from the main mission file by loading it as a section file but there doesn't seem to be a way to figure out the file name for it. Has anyone figured any of this out? |
Yes reading the section file would be possible. You have to specify the name and path of the file though.
|
Quote:
|
I'm trying to solve a similar(maybe the same objective) with real time at the moment to be able to reset a mission without reloading it. As you mention mostly we are dealing with Time.current() from the start of mission to cycle or run timers. It is not in game realtime.
In old IL2 it was tod (time of day) and you could just send a new time of day to the server or host by console or script. I have found the following, I'm not sure if they are the same as Time.current() ITime() GamePlay.gpTime() GamePlay.gpTime().current() But up to now I haven't been able to parse them to a "reporting" hud or serverlog to see what they report. They wont convert to a string, int or double. (I think I'm just doing it wrong at present due to not knowing syntax). Once we know what it is by type, in theory we should be able to alter gpTime() Another way I have been considering is to create a section file of the "TIME" set out in the mis file under [MAIN] (I already do this with a number of other things). However this may not work as new sub missions ignore sections of sub missions including the Time value. Because of this battle may need to be stopped to invoke a time change. In which case just reloading the main mission with an altered TIME may work, the catch is the CS itself, you can't run 2 occurances of the same CS and if you destroy the CS you are in you can't restart unless you monitor externally, like with clod commander....but this is clumsy just to reset the time! I'm sure it is realtively simple once we identify the syntax and gameplay code to work with. Might need help from the experienced coders on this one. |
This (needs checking), may work as to load a 6am time value by section file.
Code:
|
Quote:
|
Quote:
|
Ataros, I see 2 reasons for needing ingame "realtime" as opposed to mission run time.
1. If you want to create timelapse over shorter mission time. For example: Each hour step forward 3 hours. So during game play of 2~3hours, you could have morning, mid day, dusk and evening. 2. If you want to reset the day, which is actually how clod works. In theory you can run 24/7 on one "map" layout, which means either night missions(many can't be arsed with that) or being able to reset the time to mission start or some other time. Btw I tested tod by entering tod into the console, "Shift-Tab" type tod, enter and the console reports the game real time, as IL2 used to. But I can't find tod in clod, only the Time(), ITime(). During the IL2 series tod shifted between accessable to alter and not accessable to alter between releases. So ingame realtime is there as tod(via console), but probably not accessable or alterable by game script. btw I tested my little code snipet above to enter a new section time and this fails as I predicted. moggal, another and relatively simple way to establish ingame realtime is to gather the mission time by streamreader, then add runtime to the mission start time, there by infering the realtime. There is probably a way to check "tod" directly, just don't know the syntax to interigate the host/server for tod. |
Quote:
|
C# should be able to read file names from a given folder I think but I may be wrong.
There was a mission posted here called Mission Loader that can read mission filenames. Banks' COOP lobby can do this too IIRC. |
Moggel, I can sort that code out, Ill do it over weekend.
I have a script in development where I read data like this from mis files all over the place, a simple mod to a section I should be able to gather what you want.(doesn't help me though) But will help you. Ataros, I have includded a modified version of the missionloader(because it works well) into my current script, going to post it soon once I sort out some stuff...stuff is of course never finished ;) |
1 Attachment(s)
Ok here is a mission timer (Attached)
Reports Mission design TIME value by reading mis data directly. Reports Ingame run timer, Mins, Seconds,Ticks Reports Time from Mission TIME + run time(in decimal mins) Note Config in system folder, Config: "timeIO", "ON" "timevalue", "15" set "timeIO", "ON" = runs timer, set "timeIO", "OFF" = turns off timer, set "timevalue", "15" = seconds between count and screen reporting. Rerun mission to activate new time values note download the attached Mistimer.zip, as it contains correct setup Note: drop MisTimer into missions folder and run from there. here is the script for those interested, Please report bugs if found. seems to work though. enjoy. Code:
|
Quote:
But since I don't know which file is the one containing the current main mission I don't have much use for it. Hard coding the name of the mission into every mission file is not the way I want it to work since that would force the server operator to open up the mission .cs files and fiddle with its content. That, in turn, requires coding skills and presents a big risk he/she will corrupt the mission. Instead, I'm aiming for a solution where all "extensions" (like "Fighter Command") can be installed from installation packages using a graphical installer, just like we're used to install normal desktop applications. I wrote the coding framework for this (and the installer) a few week back and "Fighter Command" will be the first extension for it followed by "Live Map" (which automatically populates the landscape with traffic, livestock etc as the player flies over the map). The "framework", which I call "IL2X" right now seems to be stable and allows the coder to write code like he/she is used to, splitting up all code into libraries which can be reused and distributes automatically. Also, you can use normal runtime debugging in Visual Studio, setting up breakpoints or tracepoints to figure out how the sim works and for hunting down bugs in the code if need be. It works fine right now but needs more testing before I present it to the forums (hopefully within a week or two :rolleyes:) So (sorry for the digression), what I'm really looking for here would be something like: "myMission.GamePlay.gpCurentFileName()" or something similar to it. I have not been able to find it though... |
There is no way to get the MissionfileName from a script (i am looking for it too), via CloDo - API
It would be possible (i think) if we can create Addins for Multiplayer, to get the current directory. IGame: gameInterface.ToFileSystemPath(..) |
Quote:
|
I call the managed Dlls CloDo-API. Cliffs of Dover Application Programming Interface ;)
|
Quote:
|
Quote:
I then performed the exact same test running a server thinking that maybe a "battle" is what gets started when you type "battle start" in the server console but ... no. When are those methods called anyway? By the way: I think we should set up a scripting WIKI... |
If a server owner starts his mission via script (TAB-4) or a Server Commander, the script or the commander will 'know' which file the server owner started I guess.
|
Quote:
|
If you can figure out how to call the console( As per in game pilot manual Shift-tab enter tod) and enter "tod" you can gather the "time of day" which is the mission time at that point from mission start.
It is currently hard coded, that is, cannot be altered as per IL2-46(although this was un alterable between patches even for 46) |
All times are GMT. The time now is 06:51 AM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.