Best Time and Date system?

Heya all,

Looking for a way to incorporate endless passing time. It's going to be used for various elements in the game.

Being defeated will pass time, as well as some actions i.e Microwave a meal for 8 minutes or jog for an hour.

I'm thinking then it would need to be some kind of attribute that is added that has a value up to 60, then when it gets to 60 it creates an attribute of 1 hour, added to the hour count, that passes a day when it reaches 24?

Ideally being able to change some elements depending on the time, i.e looking outside and such to see the sun, or night-time. It would also be neat if I could arrange some form of calendar system with months and specific event days. I assume 30 days add 1 to a month attribute that cycles between 12 of them. I could perhaps do different weather depending on the months.

So I have a rough idea how that would work. Now, I generally work with the GUI, so has anyone get best recommendations for how this would/should work? I'm also assuming every action will need a time 'price' for completion so time went on.


I have a library here:
https://github.com/ThePix/quest/wiki/Clock-Library


Great, thanks! Also, at the expense of sounding stupid but while I have Quest open, what's the difference between a normal attribute and a status attribute?


Status attributes are ones you have told Quest to display in the status pane. So you have a time attribute on the game object, then you add that to the status attributes, telling Quest you want it displayed.

In fact for time, yo would display a string that gets updated from the time attribute, as you want it formated.


use Pixie's libraries as they're really good/useful, but if you want help on understanding the usage of this stuff better, you can take a look at these links:

if you want, here's a step by step guide walkthrough creating your own demo game, learning the basics of using Attributes, including statusattributes, here:

http://textadventures.co.uk/forum/quest/topic/5387/i-really-need-help#37375

and this is my detailed guide on Attributes and the 'if' Script usage, though it is a bit more code oriented, but it does show how to do the scripts in the GUI/Editor too:

http://textadventures.co.uk/forum/samples/topic/5559/attributes-and-if-script-guide-by-hk


ask if you got any questions and/or need help with anything


I think I've got this working now, but question - this has time, does it have a way of tracking what day it is, dates, months, etc?


not sure about Pixie's library... (haven't studied/looked-at-it, yet)


time and date stuff can be really simple (for example: your 'days' Integer Attribute just increases) or really complex (real life full time and date system: leap year, seasons, months, altering days in months, days, weeks, years, seconds, minutes, hours, etc)... the more I read about about time and date... I got into how to figure out the actual exact date (in just dealing with leap year and altering quantity of days in some months... I found that even leap year is more complex than I realized... if you want to be exact as you can be... lol... time and date stuff gets really complicated and math heavy if you're trying to have a full time and date system accurately... I now will NEVER EVER take the clock/time and date on a computer for granted again, lol. This is some complex stuff! Glad someone figured it out, so we can just look at see what time and date it is on our computers, watches, cell phones, etc, lol)


you might also want to understand the modulus operator as well:

modulus operator: %

the modulus operation is division, but instead of getting the quotient, it gets the REMAINDER

7 / 4 = Q:1 // using Integer Data Type / Operations, the remainder/decimal gets truncated (removed)
vs
7 % 4 = R:3

what's neat about (finding/getting) the REMAINDER is that it allows for handling cyclic and factoring (which includes finding if a number is even or odd):

// seconds (and minutes too) go from 0 to 59 to 0 to 59 ...and on and on...

game.clock_second = 0 % 60 = 0
game.clock_second = 1 % 60 = 1
game.clock_second = 59 % 60 = 59
game.clock_second = 60 % 60 = 0
game.clock_second = 61 % 60 = 1
game.clock_second = 119 % 60 = 59
game.clock_second = 120 % 60 = 0
game.clock_second = 121 % 60 = 1

// military hours: 0 to 23
// civilian hours: 0 to 11

game.clock_military_hour = 0 % 24 = 0
game.clock_civilian_hour = 0 % 12 = 0
game.clock_military_hour = 1 % 24 = 1
game.clock_civilian_hour = 1 % 12 = 1
game.clock_military_hour = 11 % 24 = 11
game.clock_civilian_hour = 11 % 12 = 11
game.clock_military_hour = 12 % 24 = 12
game.clock_civilian_hour = 12 % 12 = 0
game.clock_military_hour = 13 % 24 = 13
game.clock_civilian_hour = 13 % 12 = 1
game.clock_military_hour = 23 % 24 = 23
game.clock_civilian_hour = 23 % 12 = 11
game.clock_military_hour = 24 % 24 = 0
game.clock_civilian_hour = 24 % 12 = 0
game.clock_military_hour = 25 % 24 = 1
game.clock_civilian_hour = 25 % 12 = 1
game.clock_military_hour = 35 % 24 = 11
game.clock_civilian_hour = 35 % 12 = 11
game.clock_military_hour = 36 % 24 = 12
game.clock_civilian_hour = 36 % 12 = 0
game.clock_military_hour = 37 % 24 = 13
game.clock_civilian_hour = 37 % 12 = 1
game.clock_military_hour = 47 % 24 = 23
game.clock_civilian_hour = 47 % 12 = 11
game.clock_military_hour = 48 % 24 = 0
game.clock_civilian_hour = 48 % 12 = 0

// NUMBER = (SOME INTEGER):

if (NUMBER % 2 = 0) {
  msg (NUMBER + " is an even number")
  msg (NUMBER + " is divisible by 2, or to say it differently: 2 is a factor of " + NUMBER)
} else { // if (NUMBER % 2 = 1) {
  msg (NUMBER + " is an odd number")
}

if (NUMBER % 3 = 0) {
  msg (NUMBER + " is divisible by 3, or to say it differently: 3 is a factor of " + NUMBER)
} else {
  msg  (NUMBER + " is NOT divisible by 3, or to say it differently: 3 is NOT a factor of " + NUMBER)
}

if (NUMBER % 4 = 0) {
  msg (NUMBER + " is divisible by 4, or to say it differently: 4 is a factor of " + NUMBER)
} else {
  msg  (NUMBER + " is NOT divisible by 4, or to say it differently: 4 is NOT a factor of " + NUMBER)
}

if (NUMBER % 13 = 0) {
  msg (NUMBER + " is divisible by 13, or to say it differently: 13 is a factor of " + NUMBER)
} else {
  msg  (NUMBER + " is NOT divisible by 13, or to say it differently: 13 is NOT a factor of " + NUMBER)
}

// civilian hours: 0 to 11
not quite...
You should add 1 to the result...
game.clock_civilian_hour = 48 % 12 +1= 01

Then, just so that your clock does not show 9:1
you will need to convert the minutes to:
right("00" + game.clock_second,2) = 01 % 60 = 01


Just for clarity (sorry if it is above and I missed it)...

Do you have it working WITH the time information displayed in the status pane?

My WIP accounts for time of day into less specific sections (dawn, morning, noon, afternoon, dusk, evening, and midnight) that change ever 15 moves or after a 'wait for midnight' (noon, morning, etc) command. I would love to have the time of day displayed in the status pane as it changes but never could figure out how to do that. I'm pretty sure I can get "Time of Day:" displayed, but I do not know how to take my changeScript and apply it to the status pane.

If anyone can help, I'd much appreciate it!

And, if I did miss it above, feel free to call me whatever derogatory name you wish and tell me to re-read the thread. =)


I think I've got this working now, but question - this has time, does it have a way of tracking what day it is, dates, months, etc?

It does now!

Someone asked about this last autumn. I have just updated the library (version 3.1) to include the function I posted then, and the help file too to explain how to use it. You will need to download the library again (same link).


Just making sure, if I just rewrite the file I had before to version 3.1, I shouldn't need to change anything in game, save for refreshing the file?

Just to add, where should I be putting the SetInc(#) command? I've been trying to use it as an expression, to no avail. But I'm still experimenting - Nevermind, cracked it. Call Function.


Just making sure, if I just rewrite the file I had before to version 3.1, I shouldn't need to change anything in game, save for refreshing the file?

Correct.


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

Support

Forums