GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Loading Game sets all saved attributes to 1?

TwilightHunterTwilightHunter Posts: 146Member
edited November -1 in Working with GS (Mac)
Hey fellas, I pray you do not get annoyed at a save/load game question xD
Anyway, for testing this feature I added, this is what I'm doing.
When the player is in the first stage I have an actor:
When s key is pressed, Save Attribute game.playerhealth, etc. I have quite a few attributes to save. I also have an actor that saves the scene number. So I have an attribute called game.WhichScene.
When "I" is pressed, it saves that attribute. (So if in scene 1, switch WhichScene to 1, then I press I to save it)
So now, when I click on the title screen, and click load game, it loads the scene correctly, but all of the health and stuff is at 1...? Any idea why this is? I'm new with this feature (never mind GS in general :P ) so any help would be hot!
Thanks fellas!

Comments

  • TwilightHunterTwilightHunter Posts: 146Member
    Still having this problem fellas! XD
  • StusAppsStusApps Posts: 1,352Member, PRO
    Thing to remember with the save attribute feature is that you are not saving an actual attribute but a value to a key.

    Example:

    game.health=5
    Save atribute game.health key: 12345

    This has saved the value of 5 to a key of 12345

    This saved value can then be loaded into any attribute you like using the load attribute behaviour. If you want it back in game.health then you will need:

    load attribute 12345 to game.health

    Hope that makes sense.
  • TwilightHunterTwilightHunter Posts: 146Member
    Do I need a different key for each save attribute? Because right now I'm using the same one xD could make a difference!
  • StusAppsStusApps Posts: 1,352Member, PRO
    yes of course.

    It saves the value to the key, so each save is overwriting the next. It does not save to the attribute name but to the key.

    That's why you could load it to any attribute.

    Example:

    If I wanted to load the save I did above to a different attribute I could:

    load attribute 12345 game.displaybox1

    Now game.displaybox1 has the value of 5
  • TwilightHunterTwilightHunter Posts: 146Member
    WOOT! YEAH!
    Had to use a different key. ehem... may have been obvious to you.. ehem... wish I knew that at first... Thanks man! I wouldn't have figured it out if you hadn't posted. I had given up for the night xD
  • TwilightHunterTwilightHunter Posts: 146Member
    What sucks is I have a ton of different attributes to save. So I have to use a bunch of little slang words to remember them. Anyway thanks
  • StusAppsStusApps Posts: 1,352Member, PRO
    No problem

    I just use the same name as the attribute for the key, then I don't get confused.

    eg: save attribute game.health key: health
  • TwilightHunterTwilightHunter Posts: 146Member
    oh haha. yeah pretty much what I'm doing. Only more confusing.......?
    playerhealth: php
    ROFL
    anyway it worked. Thanks again
This discussion has been closed.