[Resolved] Advanced Time of Day/Day of Week

Started by anagura.raziel, August 21, 2009, 12:21:06 pm

Previous topic - Next topic

anagura.raziel

August 21, 2009, 12:21:06 pm Last Edit: August 21, 2009, 03:40:56 pm by anagura.raziel
I noticed there were scripts that detect the date and time from the windows calender thing and I was wondering if it were possible to take that a step further by changing what happens depending on the time.

For example, My game has a church and I wanted there to be a set of events that only triggered if you play it on a sunday.
In future, it might be cool to have to wait until a specific hour of the day to access other areas/events as well.


If there's already a script like this out there, please send me a link. I searched the forums but "time of day script" etc. is pretty vague and wasn't very helpful.

shdwlink1993

To see if the computer says it's Sunday, you'd use a conditional branch that checks if this script is true:

Time.wday == 0


To see what hour it is, you'd use a conditional branch with this:

Time.hour == 14

(That's in military time)

For other functions and such in this class, you'll want to read this Ruby Documentation.
Stuff I've made:




"Never think you're perfect or else you'll stop improving yourself."

"Some people say the glass is half full... some half empty... I just wanna know who's been drinking my beer."

anagura.raziel

August 21, 2009, 03:38:26 pm #2 Last Edit: August 21, 2009, 03:39:28 pm by anagura.raziel
Oh, I see... Kinda feel stupid now, haha.

Thanks for your help though. I would never have figured it out.