Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How can I make time-based events?

Okay - my number one worry is that I put this in the wrong forum. So, please don't hit me if I should have put this somewhere else! I wasn't sure if I could do this without finding a script or not, so I put it here. Whatever works I guess.

Basically what I want to do in my project, is run certain events at a certain time - but not based on a game clock, but instead your computer clock. If you've played game's like Animal Crossing, then you should know pretty much exactly what I'm saying. I have seen this thread, but since I'm script illiterate, it didn't make a lot of sense to me.

For the sake of clarity, an example of what I want to be able to do, is at say 3:00PM on the 15th of March every year - a man walks through the village. You see what I mean?

Any assistance, I would be very thankful for. And if what I'm asking of is crazy difficult, in the wrong forum, etc. etc. - So sorry!
 

Mars

Member

This is actually quite easy-

I got this from Poccil I believe.

Basically, put these seven lines of code in a parallel common event, and of course put a wait frame of 1 or 2 to lessen lag. :]


$game_variables[1]=Time.new.mon
$game_variables[2]=Time.new.mday
$game_variables[3]=Time.new.year
$game_variables[4]=Time.new.hour
$game_variables[5]=Time.new.min
$game_variables[6]=Time.new.sec
$game_variables[7]=Time.new.wday

Here's how to use it-

First of all, in "$game_variable 
 
Sorry for bumping this topic - but I'd rather not create a new one for something that relates to pretty much this same bit.

I need to know the most efficient way of making exceptions to aforementioned time based events. For example, say I want someone to say a certain thing on all days of the year *except* a few specific ones. Of course, to do this I could specify that I want the person to say that and specify each individual day, but you can see why that would be a huge pain.
Anyone? Please and thanks =)
 
set a conditional branch checking the variables you created. If it is this specific day let him say his special stuff
else the normal stuff.

This way you don't have to check for each and every day yourself
 
Because it uses variables, you can always use the greater than/less than in a conditional branch.  It may require you going around a number (less than 3, greater than 3), but it should work.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top