Need help with my farming game/check for realtime

Get help using Construct 2

Post » Sun Feb 23, 2014 1:33 pm

Hello,
I need help again.
I'm making a game like Harvest Moon (a farm simulation), but I want to use real time.
I found a plugin for checking the real time, but I have a problem now:
I need to check if it's the day later then before, but how can I do this?
So if you play today and plant something, then tomorrow you can harvest it.
I thought about using variables.
I hope someone can help me.
B
4
G
1
Posts: 25
Reputation: 373

Post » Sun Feb 23, 2014 2:34 pm

Does anyone know an answer?
:(
B
4
G
1
Posts: 25
Reputation: 373

Post » Sun Feb 23, 2014 2:42 pm

Firstly,Bumping a thread before 24 hours in violation of the rules.

What is the name of the plugin?
B
11
S
5
G
2
Posts: 496
Reputation: 2,306

Post » Sun Feb 23, 2014 3:01 pm

Oh, sorry. :(
It is this one: viewtopic.php?t=63492&start=0
I need to save in a variable the date on wich the fruit was planted and then check on every 1 second if the day, on wich it was planted, is one lower then today.
So if I plant the fruit today, it have to check if it is tomorrow and if yes, it can be harvested.
B
4
G
1
Posts: 25
Reputation: 373

Post » Sun Feb 23, 2014 5:29 pm

That plugin can also display Unix time, which is a very convenient single number that measures time in milliseconds, factoring in all month lengths and everything else (except for leap seconds).

So, whenever a player plants something, assign the current Unix time to a local variable (Plant.TimePlanted or something). Then, provided each plant is assigned another variable (Plant.HarvestLength or something) to determine how long it needs to stay in the ground, all you need to do is a simple check to see if Date.Unixtimestamp - Plant.TimePlanted > Plant.HarvestLength. If so, then it's ready for harvesting.

Here's a little demo to show you the idea in action.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Mon Feb 24, 2014 2:55 pm

Great! Thanks! :) :)
But only one question:
If I plant something today and save the day/date in a variable and then play tomorrow, doesn't it load the date if tomorrow? :?
B
4
G
1
Posts: 25
Reputation: 373

Post » Mon Feb 24, 2014 3:54 pm

B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Mon Feb 24, 2014 4:53 pm

Thanks :)
I'm going to try it later
B
4
G
1
Posts: 25
Reputation: 373

Post » Tue Feb 25, 2014 9:07 am

EliasGames wrote:If I plant something today and save the day/date in a variable and then play tomorrow, doesn't it load the date if tomorrow? :?

I thought the idea here was to create a real-time game, right? So if the player plants all his stuff today, and comes back tomorrow, it's ready for harvesting?

If that's not the case, and you want to create a "local" real-time experience as opposed to a persistent one, then just use the timer behaviour.
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Tue Feb 25, 2014 11:37 am

You're right, it should be with real time :)
B
4
G
1
Posts: 25
Reputation: 373

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests