How do I can set random number ?

  • hi

    I want to set a random number and when system choose a number after 24 hours system choose another one .

    exp : cost for a flower : random( 18,25)

    system choose : 21

    after 24 hours system choose cost again.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can do something like.... when system chooses the cost, save the cost and time/date on local storage,

    and then compare the current time/date with the previously saved one.

    If its less than 24hrs, display the saved cost, and if its more than 24hrs. choose new cost and then overwrite the local storage with the new data.

    You can utilize RexRainbow's time plugin for it:

  • You have this 'away' timer in place. It tells you how long the game has been offline.

    It actual tells you also how long the game is running.

    Just set a variable to round(TimeAwayL.ElapsedTime("away")), but this time only once and when it is zero (first start). The difference between the actual round(TimeAwayL.ElapsedTime("away")) and that variable = the online time.

    Now the total time is just = TotalTime + that variabele (online time). TotalTime = zero for first run. The offline time (you have that one allready in place), we handle once on getting from the local storage.

    You have to store total time in the local storage.

    24 hours is 86400 seconds. (if i count right) So, its the same thing as you do allready with your build time.

    So on TotalTime getting from the local storage.

    TotalTime = TotalTime + away time (away time has to been get allready)

    round(TotalTime /86400) gives you the amount of times this total time passed 24h.

    If its bigger then 1 do the random thing

    set TotalTime to (TotalTime) - (round((TotalTime /86400) * 86400), this sets the total time to the remaining second left to complete again a 24 hours cycle.

    Say your total time is 216000... round(216000/86400) gives you 2 (2.5 rounded) ... means there are 2 times 24 h passed. Now there is still .5 times 24 hours left, and have to start from there for the new cycle. (TotalTime) - (round((TotalTime /86400) * 86400) gives you what is left.

    Now the total time is just = TotalTime + that variabele (online time) again.

    You do the same with buildtime, where you have to use ceil instead of round, because it is zero based.

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