Saving system

IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
edited November -1 in Working with GS (Mac)
Hello, I made a simple saving system, and it works fine (I mean attributes are saving and loading properly), but I don't know how to save information on which scene the player is, and load this scene after taping on the load game button.
And second topic - is there a way to make few independent saving slots? If yes, how to do it?

Thank you very much and have a good day/night.

Comments

  • synthesissynthesis Member Posts: 1,693
    1) The save attribute and load attribute behaviors can be used anywhere in your game.
    2) The create a future memory slot...make an attribute (such as an integer) that has a default value of whatever...perhaps 1. Then save that attribute value to a unique memory key via the save attribute behavior for as many slots as you desire to be use later.

    Then in your game...if you wish to save a value to that slot...use the save attribute again to save the new value over the top of the previous value.

    This will require you to keep track of those memory keys and to triple check spelling. If those are mistyped or not pointed correctly...you won't be saving to the same slot...which can cause problems if you try to load a value from it.

    Also remember that saving or loading from memory can cause hiccups on FPS if the game is active. Its best to do it when the app is "quiet" as the behaviors are processor "heavy".
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Thank you for the reply.
    According to first topic, maybe I explained it in the wrong way. I have SAVE button in the interface (which is present in every scene). When player touch this button, than the game should save all attributes and current scene. Then player can quit this app, and when he start this app later, and touch the LOAD button in the main menu, he would start in the scene he was previously (when he saved).

    I know how to save attributes but I don't know how to save current scene, so player would be able to start where he has ended. I'm talking about manually saving (not an autosave in every scene).
  • synthesissynthesis Member Posts: 1,693
    There is no magic way to save a scene state. Anything that you want to restore you would have to create a unique memory slot to store the value and then load it and apply the values at the scene start.

    GS is not very "smart" when it comes to this kind of logic and the logic needed can be tedious to implement since its so fragmented.

    Your best bet is to start the level over and only save general game progress (if a game). Try to keep the data being restored to an absolute minimum. Otherwise...GS may not be the dev platform to build the app you are working on.
  • IsabelleKIsabelleK Member, Sous Chef Posts: 2,807
    Hello again,
    Maybe my english is to poor (I'm not an english native speaker), but I think that I can't understand all that you wrote. I'm sorry for this.
    In few words: I'm making point&click adventure game, and I have almost everything except saving system, and few other things. I have the SAVE button during the game, and LOAD button in the main menu.
    SAVE button is saving ONLY few important attributes (like: items that player has (about 10 attributes)). And this works fine.
    LOAD button is loading these attributes. And this works fine.

    Each background (like: room, corridor, bathroom etc.) is on a different scene (there is about 30 scenes), and I need SAVE button to save: the attributes (as I already have), and information on which scene player is, when he saves.
    So, when he click on the LOAD button in the main menu, he will appear on the scene, where he saved earlier.

    I think that I have to make an attribute for each scene, or something. I was trying to do it yesterday, but I don't know how (not how to make an attribute, but how to save it, as I said before).
  • synthesissynthesis Member Posts: 1,693
    The only tools you have to save and load data is the save attribute and load attribute behaviors. Those are connected to a key value.

    So...
    You use the save attribute to save the game.Inventory value (an integer). The key would then be set to "inventory". The key is used to name the memory slot that the data is stored in.

    Then use the load attribute behavior to grab that data from the memory slot. Enter the same key name in the load attribute behavior. Then assign that key value to the game.Inventory attribute.

    Repeat this for each piece of data you need to store in the memory.

    Then when you press the save button...it goes through all the save attribute behaviors and assigns the data to memory.

    Then on the next run...the user presses the load button. This switches a game.loadValues attribute to true. Then in an invisible controller actor have a rule:

    game.dataLoaded=false (a default set at scene load)

    when game.loadValues = true
    load attribute 1
    load attribute 2
    load attribute (key=lastSceneID) to game.lastSceneID
    etc.
    game.dataLoaded = true
    [ end rule ]

    RULE SET:
    when game.dataLoaded = true
    game.loadValues = false (resets the earlier boolean)
    ...when game.lastSceneID = 1 >> change scene to ...
    ...when game.lastSceneID = 2 >> change scene to ...
    etc.

    Hope this helps.
Sign In or Register to comment.