Timers issues

RocketBrainRocketBrain Member, PRO Posts: 269
edited November -1 in Working with GS (Mac)
i tried making the timer "every # seconds do this"

I made the # a variable and tried changing the variable after the game started. however no matter what i did nothing changed.

So far it seems like once the timer initiates you cant change that attribute later.

Is this true?

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited July 2015

    @RabidWeasel

    Yes, technically this happens:

    So, yes, once a timer is started, it will run at the initially defined interval.

    You can use game.Time and rules to achieve what you want.

    self.LastTimeStamp = game.Time

    Rule: If self.LastTimeStamp + self.VariableInterval < game.Time then
    do whatever
    self.LastTimeStamp = game.Time
    end of Rule

    Now you can change the interval at will by changing self.VariableInterval

  • SocksSocks London, UK.Member Posts: 12,822

    @Hopscotch

    Brilliant illustration of the issue ! :)

  • GnarlyGnarly canadaMember Posts: 840

    I asked the exact question a few moons ago...........

    This illustration is great. You want what he gave you a "custom timer".

    I struggled with the custom timer logic at first. So don't fret if it makes little sense at first. I think of "game.time" as a constantly changing variable.

    I have to refer back to the example every time I use it....... I have a work around using timers, spawning actors but not good coding practice......

Sign In or Register to comment.