Time reading

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Joliplex
Prole
Posts: 7
Joined: Wed Dec 07, 2011 12:17 pm

Time reading

Post by Joliplex »

Hi there!

I am making a top-down adventure game, and when I get the normal body done, I'll do some events there. I mean time-based events.

So I'm asking that is here any kind of "time reading" from the os clock? Something like this?

Code: Select all

function love.update()
     if(love.time.readMonth() == 3) then     --If the month is March...
          if(love.time.ReadDay() == 19) then    --...and if the day is 19...
               doEventOne()     --...do event one!
          elseif(love.time.readHour == 20) then     --Else, if the hour is 20 pm (any day in March)...
               doEventTwo()     --...do event two!
          end
     end
end
Thank you! :D
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Time reading

Post by coffee »

Joliplex wrote:Hi there!

I am making a top-down adventure game, and when I get the normal body done, I'll do some events there. I mean time-based events.

So I'm asking that is here any kind of "time reading" from the os clock? Something like this?

Code: Select all

function love.update()
     if(love.time.readMonth() == 3) then     --If the month is March...
          if(love.time.ReadDay() == 19) then    --...and if the day is 19...
               doEventOne()     --...do event one!
          elseif(love.time.readHour == 20) then     --Else, if the hour is 20 pm (any day in March)...
               doEventTwo()     --...do event two!
          end
     end
end
Thank you! :D
When you talked about "time-based events" in a rpg/adventure I supposed you were talking about implement events like pop up a message dialog about x time. You for sure know that you should use dt time measure for that events and dont need to compare with OS clock/calender right? Just checking, your "time-based events" actually look more like "date-based events". :)
Joliplex
Prole
Posts: 7
Joined: Wed Dec 07, 2011 12:17 pm

Re: Time reading

Post by Joliplex »

coffee wrote:When you talked about "time-based events" in a rpg/adventure I supposed you were talking about implement events like pop up a message dialog about x time. You for sure know that you should use dt time measure for that events and dont need to compare with OS clock/calender right? Just checking, your "time-based events" actually look more like "date-based events". :)
Yes, I meant date-based events (like at Christmas Eve you get 100 coins, a vanity item and accessable quest). That os.date('!*t') looks good, but can you use those infos as values, like this:

Code: Select all

> table.foreach(os.date('!*t'), print)
hour    23
min     00
wday    5     --Is this weekday?
year    2012
yday    62     --Is this yearday?
month   3
sec     10
day     4
isdst   false     --What is this?

> if(month == 12 && day == 24) then coins = coins + 100     --Can you use && or || in Lua?
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Time reading

Post by tentus »

Joliplex wrote:

Code: Select all

> if(month == 12 && day == 24) then coins = coins + 100     --Can you use && or || in Lua?
You should use and and or.
Kurosuke needs beta testers
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Time reading

Post by Robin »

To recap:
Joliplex wrote:Is this weekday?
Yes.
Joliplex wrote:Is this yearday?
Yes.
Joliplex wrote:What is this?
Whether it's daylight saving time (summer time).

Code: Select all

if month == 12 and day == 24 then
    coins = coins + 100
end
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Time reading

Post by Jasoco »

Make sure to put in a safety to make it so it only gives you these special things once else you have people launching and quitting the game over and over to get a million coins.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 5 guests