How do I create consecutive days?

Get help using Construct 2

Post » Fri Jun 24, 2016 8:21 pm

I tried to search it but i couldn't find a "badge" of playing for x consecutive days.

I dont want the work / project done, i want to know how you guys could do it.

Thanks and regards :D.
B
31
S
13
G
6
Posts: 355
Reputation: 5,058

Post » Fri Jun 24, 2016 8:42 pm

This may be of use for you.
https://www.scirra.com/tutorials/940/ho ... -a-project

You can use it to get the current date and save it in your preferred data structure, which you can then use to compare to previous sessions' data saved with localstorage.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Fri Jun 24, 2016 9:03 pm

So the problem for this is to separate all the date and keep like the month and day, the real problem is when the consecutive days are between last days of the month and first of the next one.

Its pretty hard xD

Edited: for the first part (separate) i could use:

left(text, count)
Return the first count characters of text.

right(text, count)
Return the last count characters of text.
Last edited by katzin on Fri Jun 24, 2016 9:12 pm, edited 1 time in total.
B
31
S
13
G
6
Posts: 355
Reputation: 5,058

Post » Fri Jun 24, 2016 9:08 pm

katzin wrote:I tried to search it but i couldn't find a "badge" of playing for x consecutive days.

I dont want the work / project done, i want to know how you guys could do it.

Thanks and regards :D.


could you explain a little bit more? I will try to help you...

what do you mean with "couldn't find a "badge" of playing for x consecutive days"?
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Fri Jun 24, 2016 9:13 pm

i just want to give a badge or a gift when the player plays for example for about 5 consecutive days.
B
31
S
13
G
6
Posts: 355
Reputation: 5,058

Post » Fri Jun 24, 2016 9:32 pm

katzin wrote:i just want to give a badge or a gift when the player plays for example for about 5 consecutive days.


1 - consecutive day without quit the game (computer)?
2 - play 120 hours?
3- play for five day in different days?

ok, you could try like this:

1- add an event that every second add 1 to a variable, when a variable is more than 432000 do the event you want, if the player quit the game, the variable will lost the score.

2- add an event that every minute add 1 to a variable (and save every minut), when a variable is more than 7200 do the event you want.

3- make the data like 4/3/16 like this= 4316

if a player play the 4316, add 1 to a variable (because the first time he play the variable would be 0). if the player play another time to the same day, don't add nothing... because the time would be the same 4316.

if a player play another day, like 4/10/16, will be 41016, so is > than 4316, in this case you add 1 to your variable... and when the player score 5, just do the event you want.

let me know if is good like this :D
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Fri Jun 24, 2016 10:00 pm

I'm pretty sure the method Javascript used for time is seconds from a certain date (in the past). So it would be easy to compare the current time to the last time they played if you are interested in that method.
ImageImageImage
B
39
S
22
G
11
Posts: 486
Reputation: 9,913

Post » Fri Jun 24, 2016 11:04 pm

I mean play atleast once in a day for atleast 5 consecutive days.

I.e: jun 29, jun 30, jul 1, jul 2 and jul 3. (this should the worst scenario because have some days of the last month and some days of the new one)

so if i have a variable called consecutivedays.

the game should do something like this.

compare last day variable with today variable.

If: today (month and day) = saved (month and day) do nothing.

if saved day diferent than today and today is 1:
if month is Jul and saved is jun: add 1 to consecutivedays variable (need to do it for the whole 12 months u_U)
else consecutivedays = 1 (reset)

if saved month = today month and today is 1 greater than saved day: add 1 to consecutivedays variable.
B
31
S
13
G
6
Posts: 355
Reputation: 5,058

Post » Sat Jun 25, 2016 12:25 am

Well the data is there, the processing is a bit troublesome due to our calendar system being crap.

First parse out the relevant information and save to a data structure (array or variable). You'll want to grab the month, year, and day. I don't think you'll need the time. My goal is to convert everything strictly to number of days.

For each month, you want to convert it to however many days there were BEFORE that month in a year. Lets call these monthDays:
Jan=0, Feb=31, Mar=59, Apr=90, May=121, June=151, ect...

So to get the date in days, you would do year*365+monthDays+day. You then compare this final number to the previous one.

How to deal with leap years and February 29 eludes my limited brainpower at the moment. I imagine it would have to do with using modulo (%) or another set of conditional logic, but yeah... the calendar system is bonkers. Hopefully you get the idea.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303


Return to How do I....?

Who is online

Users browsing this forum: Syazanie Amirin and 9 guests