Xenos time system library
An advanced time system library for keeping track of the time of day in your game.
- Standard clock that can show time like "Sunday 2:15PM (Day 1)" or variants.
- Keeps a running total of total days passed.
- Can be used to trigger hourly, daily, weekly, or other events/tasks
- Time advances by 5 minutes per turn (you can adjust that) or you can make events that don't advance time at all.
- Time can be advanced by other amounts. Want to sleep 8 hours? No problem.
HOW TO USE IT
Every "turn" this will advance time by 5 minutes. If you have it show time in the task bar (see "Display Time" below) you can watch this happen every turn.
Display Time: There are many different ways that you can show the time, but I have included a simple user function called "timeShow" that you can use like any other variable. It works from the status bar, too. Just put %timeShow% in there and the time will display something like Sunday 2:15PM (Day 1)
You can change the way time displays if you are familiar with expressions. Look in the Time Functions folder for the "timeShow" Function. In there you will see how it works. (TIP: You'll also get some examples of how to make sure there is a leading zero so that 2:05 doesn't show up as 2:5. It also converts the 24 hour clock to AM/PM - so that hour 15 shows as 3:00PM.)
Tasks That Take No Time: Obviously, it is silly for every single thing you do to take five minutes. Walking around and searching - sure, that makes sense maybe, but looking at someone doesn't take that long - and if it does, you'll probably notice them calling the cops because you're staring at them so long. So, on tasks that you don't want time to advance, you can set a variable "timePause" to 1.
For example, if you don't want any time to pass when you "look" at something, edit the "Look" task (or if you don't want to mess with the library, add a new "Specific" task that "Runs Before" the "Look" task. Make an action that "Sets" variable "timePause" to "1". Repeat this for every task that you don't want to advance time.
Changing the Default Time Amount: Maybe you want each turn to take a minute. Or 10 minutes. Or, maybe you don't want time to advance automatically at all and you only want to advance time a different amount with each task. Yep. Here's how...
Look for the task "timeDoMinutes" in the Time Functions folder. Edit that and switch to the Actions tab. Change the "5" in there to however much you want it to advance each turn. TIP: Set that to 0 if you don't want time to advance automatically. If you do this, no time will pass unless you advance time manually on the tasks that you create/use that you want to take time. See "Manual Advance" below for details on this.
Manually Advance Time Want to sleep 8 hours? Want to make it so cooking supper takes 30 minutes? Driving to town takes an hour? No problem. Here's how...
The system has the following variables that you can use to change the time: timeMinute: minutes - from 0 to 59 timeHour hours - from 0 to 23
NOTE: The most you can (easily) advance time is 24 hours. Hopefully you won't need more than that.
If you want to advance time by two hours, simply "Increase" variable "timeHour" by "2". If you want to add one day, then add 24 to the timeHour variable in your task. It will update on the next turn. IMPORTANT #1: Since minutes advance by 5 every time, if you advance the "hours" and want a specific even hour increment to pass, also set the "timePause" variable to 1. IMPORTANT #2: Minutes are a little different. Simply subtract 5 from the amount you really want to advance. So, if you want to add a half hour to the time. your action should NOT pause, it should simply increase "timeMinute" by 25. This will make it advance 30 minutes (25 that you added and the 5 default). If you pause the minutes, it won't update until the following turn.
ADDED: Don't add more than 60 minutes or 24 hours to the timeMinute or timeHour variable. Things will get funky. It will ultimately work itself out and be correct, but if you add 240 minutes to the time, it will take 4 turns with the clock saying funky things like Sunday 3:180pm (Day 4). If you need to add 140 minutes, then add 2 to the hours (120 minutes) and 15 to the minutes (15, plus your default 5 = 20, plus two hours is 140 minutes). I know that's a little weird, but... what do you expect for something I cranked out in 90 minutes (or rather, 1 timeHour, 25 timeMinutes)?
Other Useful Variables Aside from the above two hours and minutes, there are the following variables that can be useful for triggering events: timeWeekDay: number from 1 to 7. Sunday is 1, Monday is 2, etc. NOTE: "timeWeekDays" (note the S at the end) is the table that spells out the days. If you want to change those to Klingon or abbreviate like Sun, Mon, Tue, etc - you can do that in there). timeDayCount: is an ongoing count of the number of days that have passed since the game started.
Changing the Game Start Time: For no obvious reason, I started this to default on Sunday at 2:15PM. If you want to change that - just edit the variables in the editor before you start the game. If you want it to start Monday morning at 8:00 am, then set "timeWeekDay" to 2 (Monday), make "timeHour" be 8, and "timeMinute" be 0. Remember - it's a 24 hour clock so if you start at an afternoon time, use the right number. 8PM would be 20, 5PM would be 17, etc.
Triggering Events At Certain Times Or Intervals
Let's say you want a task to run every hour. The "timeDoHours" event only runs if minutes are greater than 60. So... in theory this runs every hour, once an hour. So, you could simply add a new action to that "timeDoHours" executes that task. This will work most of the time, but... if you manually advance the "timeHour" variable, it won't fire until the NEXT hour comes along.
Another way to do it is to create a task called "Xyzzy" (or whatever) and a variable called "Xyzzy Last Ran". So now, if it runs every hour, your restriction on the task should be "Xyzzy Last Ran" not equals "timeHour." Then set your Xyzzy task to do what it does, then change the "Xyzzy Last Ran" variable to the current "timeHour" variable so that it won't fire again until the hour changes. You can then call this task within the "Time Resume" task, or create your own event or whatever.
You can use timeDayCount in the same way to do daily tasks. You can also have something run at 3pm by adding in the "timeHour" must be "3" to the last ran (and then use the timeDayCount variable to let you know that it ran today.
Even things that only happen on certain days of the week are possible.