ID:159717
 
Just wondering what are possible ways of creating an in-game clock that cycles through 24 hours (not military time, but AM/PM). Also, what would be the best way to set up the 12 months in a year as well as days in each month? I'm going to be using these for my rent system that I have created. I'm not looking to do realistic time/days, I think every realtime minute = 1 hour, and every 24 minutes = 1 day. Appreciate the help, if given! =)
var/min = 0
var/hour = 1
var/period = "AM"

var/day = 1
var/month = "January"
var/list/months = list("January" = 31,"February" = 29)
proc/Time()
min ++
if(min > 60)
min = 0
hour ++
if(hour > 12)
hour = 1
if(period == "AM") period = "PM"
else
period = "AM"
day ++
if(day > months["[month]"])
day = 1
// etc...


Does that make sense, or do you want me to explain a little bit?
In response to Gooseheaded
I see, I see, thank you kind sir. Exactly what I was looking to do. Although, I'm gonna compact it a bit more. I'm not used to using lists quite like you did.
In response to Branks
Yeah, I'm not that good with lists either.

But, you can always create more vars to hold the info you need and then you just use the info, do the proper ifs, and... yeah, everything should work out just fine.

Also, don't forget to add a -delayed- loop to the Time() proc.

Something like,
proc/Time()
while(world)
//everything here.
sleep(10) // sleep a second.


=)
In response to Gooseheaded
Only problem I see now is single digits read as for example: 2:0 AM. I'm trying to figure out how I can add a zero in there, until it hits 2 digits.