How do I make a variable increase over in game time?

Post » Sat Nov 17, 2012 2:24 pm

I want to make it so every 5 minutes in game I increase some variables. This is normally easy but I am stumped when it comes to fast traveling, sleeping, and waiting. How do I make it so those variables continue to increase during those events?
User avatar
Big mike
 
Posts: 3423
Joined: Fri Sep 21, 2007 6:38 pm

Post » Sat Nov 17, 2012 9:38 am

Use http://www.creationkit.com/GetCurrentGameTime_-_Utility and do the math after http://www.creationkit.com/Function_for_Time_of_Day
Or look at my http://www.creationkit.com/Complete_Example_Scripts#Script_for_a_quest_with_time_limit
User avatar
Scott Clemmons
 
Posts: 3333
Joined: Sun Sep 16, 2007 5:35 pm

Post » Sat Nov 17, 2012 5:32 am

This code should also do the trick :

Int DayFloat HourFloat TimePassed; somewhere, onceDay = GameDaysPassed.GetValueInt()Hour = GameHour.GetValue(); thenif ( Day == GameDaysPassed.GetValueInt() )	 if ( Hour != GameHour.GetValue() )		  TimePassed = GameHour.GetValue() - Hour	 endifelse	 TimePassed = GameHour.GetValue() + (24.0 - Hour)endifif ( TimePassed*60 as int >= 5 )int IncreaseTime = ((TimePassed*60 as int)/5) as intYourVariable += (YourSomething)*IncreaseTimeendif
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Sat Nov 17, 2012 7:46 am

Ah, I guess its kind of a complicated thing to do... Thanks for the help. :)
User avatar
rebecca moody
 
Posts: 3430
Joined: Mon Mar 05, 2007 3:01 pm

Post » Sat Nov 17, 2012 8:40 am

Just record your starting time and then calculate the value whenever you need it. It should just be the elapsed game time (in days) multiplied by 288 (24 hours and another 12 to get the 5-minute interval).

((Utility.GetCurrentGameTime() - InitialGameTime) * 288) as int

You can either recalculate in the event where you need the value, or if you're using it for some condition, you'll probably want to have it updated regularly with something more like this.

float InitialGameTimeint FiveMinuteElapsedCountFunction GettingStarted()    InitialGameTime = Utility.GetCurrentGameTime()    RegisterForSingleUpdateGameTime(0.0833) ; approx. 5 minEndFunctionEvent OnUpdateGameTime()    FiveMinuteElapsedCount = ((Utility.GetCurrentGameTime() - InitialGameTime) * 288) as int    RegisterForSingleUpdateGameTime(0.0833) ; approx. 5 minEndEvent
User avatar
Horror- Puppe
 
Posts: 3376
Joined: Fri Apr 13, 2007 11:09 am

Post » Sat Nov 17, 2012 1:44 am

Ok thanks!
Going to try this today! One more question. Is it possible to check to see how many of these updates occurred while the player was asleep?
User avatar
LuBiE LoU
 
Posts: 3391
Joined: Sun Jun 18, 2006 4:43 pm


Return to V - Skyrim