Need help with my farming game/check for realtime

0 favourites
  • 15 posts
From the Asset Store
10 Retro songs ideal for platformers or farming games
  • 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.

  • Does anyone know an answer?

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

    What is the name of the plugin?

  • Oh, sorry.

    It is this one:

    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.

  • 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.

  • 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?

  • Thanks

    I'm going to try it later

  • 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.

  • You're right, it should be with real time

  • GeometriX

    So I tried it now and yes, that is what i wanted!

    My only question is:

    Can I compare:

    If tomato planted > Day = Today

    if Day = Yesterday > tomato can be harvested.

    Or is the time you set in your projekt exatly one day? I don't know because I set the harvest time to a lower number, so I haven't to wait so long.

    Thanks

  • The events in my example are checking to see how long the plants have been in the ground. So you can set that to be any length of time you want - even a whole day. Just adjust the harvest time to whatever it is you need and it'll work, whether you want to set it to a minute or a day or a year. Bear in mind that Unix Time is measured in milliseconds.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • GeometriX

    Oh, ok

    Thanks.

    At the moment I'm going to make the game without real time, because it's easier to make it with out, but after I finished everything else, I will add it.

    Thanks again for your help.

  • To make your life easier, I'd suggest that you create a global variable to manage the real-time issue while you're still working on the game. This is very important to ensure you don't waste any time while developing but still use the exact same system that the player will ulimately use.

    Assume this variable is called called HarvestMultiplier. So, set your plants to be whatever harvest length you want, and then create a single event Plants(family) On creation > Set HarvestLength to Plants.HarvestLength*HarvestMultiplier. If your multiplier is set to 1, it'll be real-time. If it's set to 0.1, it'll be ten times faster than real-time. 0.01: 100 times faster, and so on.

    If you want, you can also come back to this later to adjust overall game speed from a single variable without having to manually change every plant, which will probably be a huge chore later down the line.

  • GeometriX

    Thanks again!

    It's a good idea!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)