Page 1 of 1
Time reading
Posted: Wed Feb 29, 2012 8:50 pm
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!
Re: Time reading
Posted: Wed Feb 29, 2012 9:15 pm
by Jasoco
Re: Time reading
Posted: Wed Feb 29, 2012 9:56 pm
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!
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".
Re: Time reading
Posted: Fri Mar 02, 2012 9:01 pm
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?
Re: Time reading
Posted: Fri Mar 02, 2012 9:05 pm
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.
Re: Time reading
Posted: Fri Mar 02, 2012 9:34 pm
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
Re: Time reading
Posted: Fri Mar 02, 2012 10:50 pm
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.