Timer

ingenious.applicationsingenious.applications Member Posts: 102
edited July 2012 in Working with GS (Mac)
Hello everyone. In my current project, the main scene the player operates from (a map) has a timer on it that updates the "day" every 10 seconds. If the player uses any one of several buttons to go to one of the other scenes and then returns, the timer is reset to its starting value. The day count remains correct, but unless I can fix this it would essentially allow the player to remain on day 1 if they navigated to a different scene before the 10-second mark and then came back.

Best Answers

  • ORBZORBZ Posts: 1,304
    Accepted Answer
    Store the current day in a game attribute (global)
  • ORBZORBZ Posts: 1,304
    edited July 2012 Accepted Answer
    store the current time from self.time and use that as an offset.

Answers

  • ingenious.applicationsingenious.applications Member Posts: 102
    I already set up the day as an attribute and that works perfectly. The problem that I am trying to solve is to save...I guess the timer value at any given time (so in my example, the current second value between 1 and 10 seconds). This is so that when the player navigates away from that scene to view something else (ex: stats, options, etc) on another scene, they can return to the map and the timer will pick up from the value it left off at. For example, if the game starts and the player pressed a scene-changing button 7-seconds in, I would like for the scene to start off at 7 seconds when the player returns to that scene. The current day displays fine and changes over to the next day every 10 seconds without fail.
  • ingenious.applicationsingenious.applications Member Posts: 102
    I'm trying to understand what you're saying. Unfortunately, my understanding ends once I start to use the Save Attribute behavior. Should I select Game > (attribute I created for this)....or would I go with Current Scene > Time?

    Guessing, If I used either Game > Time or Current Scene > Time, it wouldn't be giving me what I'm looking for. The game time is obvious (because it'd be much larger than I could use, time-wise) and the same would hold true for the current scene time, assuming that the player was on the scene for more than 10 seconds.
  • ORBZORBZ Member Posts: 1,304
    You make a game level attribute and store the offset there. It's a global variable that persists between scenes.

    Read the manual.
  • ingenious.applicationsingenious.applications Member Posts: 102
    I know what a game-level attribute is and I've already done so for this function. Where I'm running into the problem is trying to store the time value into the global attribute I created. I know game-level time wouldn't work because that accounts for a much longer period of time that I am looking at. So, I believe the scene-level time attribute is what I need to use.

    If the scene's time is less than 10, than I change the attribute of the attribute I created earlier (seconds) to scene.time. Once the user navigates back to the scene in question, I would then try to add my created attribute to scene.time in order to pick up from where I left off. I'm currently not home and won't be for a while, so that's my train of thought.

    Maybe it'll work, maybe it won't. But, the other problem is how to organize behaviors that end in the same result if the player is in the target scene for more than 10 seconds (could be 14 seconds, could be minutes, or hours). Without having the use of "IF" statements, I'm not sure how I could make anything like a loop to determine things.
Sign In or Register to comment.