[Solved] Change to specific scene based on table value

creyecreye Member, BASIC Posts: 16
edited August 2017 in Working with GS (PC)

Hi,

I'm trying to make my first game, and I'm pretty proud of my progress so far. However I'm stuck on what probably is a simple issue, atm.

My game is based on scenes (duh) with every new level being its own scene. But I want the progress to be saved so that if a player closes down the game he or she will continue from the same level.

So I made a table for "CurrentLevel". Which I call CurrentLevelTable. And every time a level (scene) is complete it saves its level number in that table (which by the way has 1 row and 2 columns :D). So the number there represents a level and is currently 1 or 2 since that's all the content I made so far.

So. When a player presses the "Start/Continue" button (actor) that I made I want something to check the table for what the level current level value is, somehow give it back, and for the actor to "Change to the correct scene" in its behaviour.

I am fully aware that I'm a complete noob. Regardless. Plz help.

Thank you.

Edit: Obviously if this is impossible to achieve, please tell me that. If you know what I can read in order to solve it, that's also welcome. Whatever will solve this.

Br
T

Comments

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

    Instead of using a table, just keep track of the current level as a game attribute (integer). The table idea isn't efficient because you would need to keep track of the current row in... an attribute. Each time a level is completed, change attribute game.currentLevel to game.currentLevel+1. Then save the attribute. Make sure to load the attribute on your intro scene using the exact same key expression (e.g. "game.currentLevel").

    To change the scene to an index value, you'll need to figure out what kind of offset you have based on other scenes. For example, if your scenes are in this order:

    Intro
    Menu
    Instructions
    Level 1
    Level 2
    Level 3
    ...

    Then your offset is 3 because "Level 1" starts at scene 4. So to resume, you would change the scene to game.currentLevel+3. That way if they left off on level 2, the value would be 2+3=5. The fifth scene is "Level 2."

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

  • creyecreye Member, BASIC Posts: 16

    @tatiang said:
    Instead of using a table, just keep track of the current level as a game attribute (integer). The table idea isn't efficient because you would need to keep track of the current row in... an attribute. Each time a level is completed, change attribute game.currentLevel to game.currentLevel+1. Then save the attribute. Make sure to load the attribute on your intro scene using the exact same key expression (e.g. "game.currentLevel").

    To change the scene to an index value, you'll need to figure out what kind of offset you have based on other scenes. For example, if your scenes are in this order:

    Intro
    Menu
    Instructions
    Level 1
    Level 2
    Level 3
    ...

    Then your offset is 3 because "Level 1" starts at scene 4. So to resume, you would change the scene to game.currentLevel+3. That way if they left off on level 2, the value would be 2+3=5. The fifth scene is "Level 2."

    Thank you for your reply.

    Interresting. A quick read and I'm not sure I understand it all, but I will give it my best once my toddler is in bed. Will post another reply then.

    Cheers
    T

  • creyecreye Member, BASIC Posts: 16

    @tatiang , I managed to do how you described and it seems to me it will work. Thanks a lot!

    BR
    T

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

    You're welcome! I always get my best work done when my kids are asleep (7 year old and 10 year old but they were 1 and 4 when I started with GameSalad).

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

  • creyecreye Member, BASIC Posts: 16

    @tatiang said:
    You're welcome! I always get my best work done when my kids are asleep (7 year old and 10 year old but they were 1 and 4 when I started with GameSalad).

    Same. Though in the morning when I'm rested, before any others wake up.

Sign In or Register to comment.