How to implement a day/night cycle using ThePix's Tracking Time Library?

I want to have a day/night cycle in the game I'm working on but in the example of the IsAfter function (IsAfter("1:20:05") { the 1 indicates the day so I'm not sure if it works for causing descriptions to change every day at a certain time. Should I be using the Clock library instead? On the surface it looks like it has more of the functionality that I want IsNight but I think it's older and it looks like Tracking Time was based on it. Does it still work? Since it looks like Tracking Time has a lot of the functionality of the Clock Library I'm assuming it's possible to achieve similar time of day based if statements but I don't know how to do that.


K.V.

If you've got his latest ClockLib from GitHub, you have an object called "game _clock" which has an hours24 attribute.

You can:

Create a function named IsNight

Set the return type to: boolean

Put this for the script in code view:

sunrise = 6
sunset = 19
if ((game_clock.hours24 > sunset) and game_clock.hours24 < sunrise){
  return (true)
}
else {
  return (false)
}

Then, in a script:

if (IsNight()){
  // Do nighttime stuff.
}
else {
 // Do daytime stuff.
}

There is (in more recent versions) IsAfterDaily, which uses the time of day, but not which days it is.

if (not  IsAfterDaily("6:00") and  IsAfterDaily("19:00")) {
  msg("It is night time.")
}

Thank you! It turns out I had the most recent version but did not know about IsAfterDaily.


Just been looking at the ClockLib myself.
Is the 'Date' function, no longer a feature. There is a section concerning the Date on the tutorial page, but when trying to print out the date in a game, it throws out an error message.


Is the 'Date' function, no longer a feature.

It seems to have gotten lost in a version update, and somehow there are two versions 3.1 and two versions 3.2. I have merged them all together in a new version 3.3 which should have everything, and updated the docs too.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums