I’m building a part of my mod that requires computing time in GDT. I found several time values that GDT adapts, for example:
- GameManager.gameTime
- GameManager.company.staff[1].flags.nextVacation
The gameTime constantly increases, i’ve tried interpreting it as ticks, seconds, minutes, hours, days, weeks, and so on and never seem to get any sense out of it. I do see it increase though. For example, about 2 weeks passed and the value increased by 7500 units approx, hard to say…
@SirEverard, @JayCheetah do you have any idea how to interpret this value?
1 Like
Never mind i found it but since it’s not easy to find that information, i’ll explain for others who might need it:
GameManager.gameTime is a number of ticks (seconds * 1000) as expressed in GameManager.getCurrentWeekFractional() function. For example, i had 1534010 as gametime and this function divides the time simply by 1e3 (or 1000) multiplied by a constant number of seconds per week which is 4 right now, saved into GameManager.SECONDS_PER_WEEK.
Once you get that value, it’s simple, just modulo it by 4 weeks per month, 12 month per year and you get your fractionnal value. Note that the values are always expressed as X+1. In my previous example, i got 383,5025 weeks for 1534010 gameTime which ends up as:
- 7 years (7 * 12 * 4 = 336)
- 11 months (11 * 4 = 44)
- 3 weeks
- 0.5025 weeks
But the real value is in fact Year 8, Month 12, Week 4 because this is what we are in, while values are expressed as what has already passed.
1 Like
You made my day @WaveJones
1 Like
You can better work out the date with in game functions, removing the need to calculate anything regarding the gameTime value:
Considering:
getCurrentWeekFractional
is a 4th of a week you would need to +4perWeek that you want to calculate.
GameManager.company.getDate(fractionalWeek)
This will calculate the displayed date of the fractionalWeek.
So if I want to say something will happen in two weeks, I can do something like.
var X = GameManager.company.getDate(GameManager.getCurrentWeekFractional()+8)
"On date" + X + "this will happen."
But if i want to do computations between two gameTimes, then, i’m bugged cause we’d need a real GameManager.getCurrentWeekFractional(x) that operates on X instead of gameTime.
I might push an update later either in UltimateLib or as a seperate mod to create GameManager.getWeekFractional(x) which would fix the issue at hand!
If you are going to be doing regular computations that need to be done in between weekFractionals then you might want to consider using a tick listener:
GameManager.addTickListener( func, true );
It runs 4 times every 0.001 seconds.
1 Like
Good to know, i’m only outputting computations in a dialog, they don’t need to update since the game is pause meanwhile.
Note,. i did a pull request on UltimateLib, i’ll need you guys to merge it asap if i want my mod to work!
1 Like
Will have to wait for @alphabit to review that one. He oversees that library
reads everything ‘‘What did I just read?’’ brain blows up and lands on Wave’s
Hi @crazycodr, may I ask you what your intentions are with the changes you’ve done? What do you explicitly need for your mod in the dialog class?
You’re dead. You shouldn’t be talking. ._.
@alphabit It’s just simple mods that allow me to manipulate dialogs live instead of creating them all at once when the game loads. For example, if the staff changes, i need to be able to override the existing dialog. The functions are simple enough to allow clearing and adding sections on the fly to the dialog like discussed in the PR comment!
Why aren’t we having this discussion though on GitHub on the PR wall that i submitted?