Real Real Time Events

JumperEarth

Warper
Member
Joined
Apr 19, 2016
Messages
1
Reaction score
0
First Language
English/German
Primarily Uses
Hey guys, I'm relatively new to requesting in forums, so please tell me, when you need some piece of information or something to help out.


I have made a game. What I want to do, to make it finished, is content that becomes activated at a certain point of time.


My ideas:


Example 1: There is a feature, let's say a skill or a item, that can only be used once a day. And if I say "once a day", i mean a real time 24 hour day.


Example 2: On the 24th of Dezember, there is an christmas event. The world is completly snowed in an you can do some special quests.


Example 3: Some events just pop up, when it is 00:00 to 01:00.  So you really get this intense feeling of playing a game due night and get rewarded for it.


Do you have an idea, how it could be realized? I would guess that you would only be able to do something like this, if you can get the real world date and time by the computers set date.


That would mean, that it is not the play time, that matters for the events, it is the real world date an time.


Thank you, for your answers!
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
You can get the current time by using this:


Time.now


This returns the full date and time.


You can get the required data from that time object you got with the above method.


Open the help files VX Ace got, select the "Index" tab, and scroll down to the "Time" section. You will see all the stuffs you can do with the time object you got.


You can also add 2 time objects together, or subtract one from the other, which lets you make time comparison easy.


The time itself is measured in seconds, so you can store a time object, and when you want to see if the current time is later than X seconds/minutes/hours/etc, you can just subtract the stored time from the current time, and check if the result is greater than X seconds/minutes/hours. Just remember that these will be measured in seconds, so if you want to check if 30 minutes have passed or not from the last time something happened, than you would need to do something like this:


@last = Time.now # Storing the time when we need.

# In the check method (30 minutes = 30 * 60 seconds = 1800 seconds):

if Time.now - @last >= 1800
# Do stuffs if 30 minutes have passed...
end


That's all for checking if X time has passed or not.


If you want to check what hour is it, you can simply do this:


if Time.now.hour.between?(start_hour,end_hour)
# Do the stuffs which happen between the start and end hours here.
end


Just add your own start and end hours in the check, and it will do exactly what you want, check if the hour is between 00:00 to 01:00.


Note that the method above (time.hour) returns the hours in 24-hours format, so if it's 10 PM, it will return 22, not 10!


And checking for an exact date, you can simply use all the other methods you can see in the help files I mentioned. Just compare the year/month/day of the current time with the date you want.


Now, I don't know where exactly you would want these checked, in events or in custom scenes, so I can't really make any script for it without knowing that.


But the methods I used in the examples work wherever you call them, so you can experiment with them on your own if you want.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top