Reset game timer from another actor

ryastryast Member Posts: 145
edited December 2014 in Working with GS (Mac)

I have a simple "multiple choice game" (as I am a noob still learning) that goes like this:

  • I have an attribute "questionTimer" which has the value 5.5
  • In my spawner actor I have a timer that reads the attribute from above to set its timer loop (in this case every 5.5 seconds )
  • It then spawns a new multiple choice question onto the screen

so far so good, everything works as it should.

  • I have an attribute called "theAnswer" that is set to zero
  • I have three buttons that set the above attribute to 1,2 or 3
  • I have an actor called "controller" that fires every 0.1 seconds to check if the answer is greater than zero, if yes, it checks the answer, updates the "correct counter" or updates the "wrong counter" etc and it displays a new multiple choice question

This too works.

My problem:

If the first timer has run (for example) for 4.5 seconds and the user presses one of the three buttons to enter his answer, the first timer will anyway fire again in 1 second, how do I reset that first timer to give the user another "questionTimer" (5.5 secs) amount of seconds?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2014

    If you're using a Timer, it's not easy. If you're using a custom timer with rule conditions, it is. Create a real attribute called game.timeStamp and then add these to your actor:

    Change attribute game.timeStamp to game.Time

    When game.Time ≥ game.timeStamp+game.questionTimer
    [time's up!]
    change attribute game.timeStamp to game.Time

    When attribute game.theAnswer ≠ 0
    [check answer]
    change attribute game.timeStamp to game.Time

    Display Text round(game.questionTimer-(game.Time-game.timeStamp),1)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • jorkosjorkos Member, PRO Posts: 353

    I would not use time in this way unless you want to reward people for answering quickly. also, do not use the controller in the way you are for the answers. have a round rules actor that has a system with rules around check.answer if.correct if.incorrect

    if.correct then you go into the next question sequence etc.

    get away from timers.

    spawn a question actor when a new one starts that references the timeperquestion attribute - if.self.time is greater than timeperquestion and question is not correct, then go into run out of time sequence.... etc.

    play around with it....

    when you are first building, put in display actors that display text of attributes.....try to understand how things change

Sign In or Register to comment.