Saving and loading RPG stats
3absh
Member Posts: 601
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
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.
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
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.
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.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I tried that same issue.
No, game.gameover and game.pause do not happen at the same time
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.
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.
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
I'm not sure if I should load the table at a certain point after saving it. Or does it load automatically?
Tables load automatically, there is no load table behavior.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
All the effort i put in this game is worthless if I don't make this work.
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.
I just realized my noob mistake smh
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
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
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
@tatiang
Thanks a lot tatiang
Is there any way i can log the behavior in the debugger and not only the attribute?
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