Saving and loading RPG stats

I'm trying to save some attributes and tables at certain point during gameplay
1. when game starts (load)
2. when game is paused (save)
3. When game over (save)

This is what I came up with, it doesn't work on the preview


Is it supposed to work on preview? In other words if I restart the game on preview can the game save attributes on preview mode?

Comments

  • BigDaveBigDave Member Posts: 2,239
    edited December 2016

    for complex rpgs i would suggest to save into tables, so you keep the overview a bit better and only have to save one table instead of x variables.

    For tables refreshing the game preview keeps the table data saved, if you totaly stop the preview it doesnt save. Which is a good thing.

  • 3absh3absh Member Posts: 601

    @BigDave said:
    for complex rpgs i would suggest to save into tables, so you keep the overview a bit better and only have to save one table instead of x variables.

    Problem is I already attached a lot of rules to these attributes
    and it's mainly 5 attributes that I want to save.
    As for the table it has about 10 values that aren't recalled as frequent as the attributes.

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

    Edit: before doing anything else, make sure you're testing this on an actual mobile device.

    Assuming that your Key expressions match between Load and Save attribute behaviors, the only other factor in the screenshot above is the condition(s). Are game.Game... and game.Pause true at the same time? What happens when you add Log Debugging Statements to both rule sets above? Do they appear in the Debugger window?

    There's no reason you can't do this with attributes. Tables are generally much easier for something like this but if you prefer attributes then it's just a question of troubleshooting by limiting variables. So you might remove all other actors from the scene in question or you might turn off all other rules in the actor these rules are part of, etc. Even a screenshot of rules doesn't tell the whole picture because you could have an actor with a rule like this somewhere else in your game:

    Every 0.1 seconds
        Change Attribute game.pause to 1-game.pause

    Which would throw off everything else in your game. ;) :p

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

  • 3absh3absh Member Posts: 601
    edited December 2016

    @tatiang said:
    Edit: before doing anything else, make sure you're testing this on an actual mobile device.

    I tried that same issue.

    Are game.Game... and game.Pause true at the same time?

    No, game.gameover and game.pause do not happen at the same time

    What happens when you add Log Debugging Statements to both rule sets above? Do they appear in the Debugger window?

    This is what i got on the Debugger window, during the start of the game and reset. Nothing happens on the debugger when pausing and when gameover.


    I can only add an attribute to the debugger. I don't know how to write the save and load rule.

    There's no reason you can't do this with attributes. Tables are generally much easier for something like this

    Table also isn't saved. It goes back to zero values when game resets. I've tried both on preview and on the viewer on my phone.

  • 3absh3absh Member Posts: 601
    edited December 2016

    @BigDave said:
    for complex rpgs i would suggest to save into tables, so you keep the overview a bit better and only have to save one table instead of x variables.

    Same issue with the tables I have. They don't save, when I refresh the preview everything resets to the initial value of the attribute/table

  • 3absh3absh Member Posts: 601

    I'm not sure if I should load the table at a certain point after saving it. Or does it load automatically?

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Tables load automatically, there is no load table behavior.

  • 3absh3absh Member Posts: 601

    All the effort i put in this game is worthless if I don't make this work.

  • 3absh3absh Member Posts: 601

    I created a new attribute just to test out the save and load behavior:

    It works!
    I think I will just save the attributes whenever a change occurs to them and not only when game is paused or when game is over (I'm not sure how the frequent saves will effect performance though)
    And I will load their values first thing when the game starts without any condition.
    I still have the issue of table values not being saved, I'm going to see how I can get past that.

  • 3absh3absh Member Posts: 601

    Are game.Game... and game.Pause true at the same time?

    I just realized my noob mistake smh

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

    Sounds like you figured out the error: the "All" rule condition means that they must be simultaneously true. So game.gameover and game.pause needed to both be true. Changing that to "Any" would mean that either or both can be true for the rule to fire.

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

  • 3absh3absh Member Posts: 601

    Changing that to "Any" would mean that either or both can be true for the rule to fire.

    That's right, it's a rookie mistake, even though I've been using GS for quite a while I always manage to forget about "All" and "Any"

    I just checked table is now being saved. But attributes still don't save.
    And I'm facing an issue with the actors, somehow this rule now that it's working is affecting the behavior of the other actors. They simply don't appear..
    Lord what have I done to deserve this :'(

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

    It sounds like you need to simplify things. I recommend starting a new project with one table and a few attributes and making sure you can get loading and saving of the table and the attributes working properly before moving on. Then go back to this larger project and implement what you know.

    You reported above that saving of attributes worked but table saves did not. Now you're saying that attributes aren't saved but tables are. Sounds like too many variables (not variables as in attributes but variables as in things that affect other things in your rules). Simplify and you'll understand how to do this properly. There are good tutorials if you search things like gamesalad tables or gamesalad save attributes and click on the Videos tab.

    Good luck! It can be frustrating working all of this out...

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

  • 3absh3absh Member Posts: 601

    @tatiang

    Thanks a lot tatiang

  • 3absh3absh Member Posts: 601

    Is there any way i can log the behavior in the debugger and not only the attribute?

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

    You can log any expression. I'm not sure what you mean by "log the behavior." What would that look like if you could?

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

Sign In or Register to comment.