How to reset a running timer?

I recently watched a TSB tutorial which told me to use this specific equation to allow minutes, seconds, and milliseconds to appear when playing my game:

floor(floor((game.time%3600)/6­0)/10)..floor((floor(game.time­%3600)/60)%10)..":"..floor((ga­me.time%60)/10)..floor(game.ti­me%10)..":"..(floor(game.time*­10(%10)..floor(floor(game.time­*100)%10)

This equation worked great for me, but the only problem is it is running constantly right from when I begin to preview my game (even when the timer is not in certain scenes) and I have no control when it starts, stops, pauses, and resets.

Can someone help me out?

Answers

  • DarkUndeadSpawnDarkUndeadSpawn Member Posts: 64
    There are some ways to fix this problem. You can setup a button to reset the scene. Just add a new button. When touched is pressed... Do Reset Scene!

    Another can be.
    Set a game attribute
    Boolean
    Name it Timer on or off
    Now add an actor!
    Place it anywhere.

    If timer on or off is true
    do
    Use values to the timer as the placement of values are acceptible!

    Now inside the timer.
    If timer on or off is false
    do
    using
    change attribute
    floor(floor((game.time%3600)/6­0)/10)..floor((floor(game.time­%3600)/60)%10)..":"..floor((ga­me.time%60)/10)..floor(game.ti­me%10)..":"..(floor(game.time*­10(%10)..floor(floor(game.time­*100)%10)
    to false

    That should work

    A lot of the time the mac version has the window running in the background.

    But on the windows version it actually stops the timer!!


    I have Simple ways of making the timer as well!! Something that can create minutes, seconds, milliseconds!!

    Try adding a timer in an actor.
    make a new game attribute
    integer
    Call it Timer

    Make another integer
    Call it Timer2

    Then add another integer
    call that timer 3


    These will indicate all three values

    Add 4 new actors and place them where ever you like

    Timer 1

    Timer 2

    Timer 3

    Timer Base

    Are the names i have

    Make a new rule

    if game.timer2 = 60

    do

    change attribute
    set game.timer 2 to 0

    New rule

    if game.timer 2 = 60

    change attribute

    set game.timer 1 to game.timer 1+1

    New Rule
    if game.timer 3 = 999

    do

    change attribute
    set game.timer 3 to 0

    Add a new timer
    every 0.1 seconds check off run to completion

    Change attribute
    set game.timer 3 to game.timer 3+111

    Make a new timer
    Every 1 second check off run to completion

    Change attribute
    set game.timer 2 to game.timer 2+1

    http://www.mediafire.com/?6574pf37o3bhfi6

    There is the link to my template
    Go ahead and check it out.

    I hope this helps!!

    Much easier way to have a timer set
    And turn it off when you want to.

    Thanks!

    Sincerely,
    DarkUndeadSpawn.
  • WingmanappsWingmanapps Member Posts: 458
    Your problem is that you are using the preset game.time
    meaning, it starts counting then second you start your app.

    Instead, just create a new game integer called Time.
    and replace the preset game.time. Problem solved.
  • SoxProcsSoxProcs Member Posts: 11
    Wow, that is surprisingly simple. Thanks @wingmanapps I'll just do that and see how it works!
  • WingmanappsWingmanapps Member Posts: 458
    edited July 2013
    @SoxProcs - It needs to be a real attribute instead of a integer - sorry
    BRAINFART!!!
  • SoxProcsSoxProcs Member Posts: 11
    @wingmanapps that still did not work for me. It displays the counter, but it does not count up like I am wanting when I replace the game.Time for my new integer attribute
Sign In or Register to comment.