Quote:
Originally Posted by DrJim
Could you post an example. When I try to use this to save information from in-game activities, all of the parameters get reset to their default values when the game (and thus the world level method) ends (as in the attached example).
While you could obviously record the parameters manually (or to a text output file with the "print" function) before ending the game, you still have to reset their default values to replay the game. This does works - after a fashion - but I'd like to see a better solution (such as saving an object without ending the world level method) if you have one.
|
If you save the important game values as property values in an object, and then manually save that object before terminating the program, you can manually import that object the next time you run the program and the values that you saved will be intact.
However, you probably need to delete that object before terminating the program the first time. Otherwise, when you restart the game and import the object, it will get a new name, which will not be compatible with existing code. Unfortunately, deleting an object that is referenced by code will cause some difficulties as well.
There are some object naming issues with regard to the names of the object in the code that saves the values as properties prior to termination unless you are going to save them manually. I suppose there may be a way around this manual effort, but right off hand, I don't see what it is.
Like you, I would like to see an example program that accomplishes this objective with a minimum of manual effort on the part of the player of the game. Hopefully we will see something really slick here.
Dick Baldwin
Free Alice tutorials:
http://www.dickbaldwin.com/tocalice.htm
Free Scratch tutorials:
http://www.dickbaldwin.com/tocHomeSchool.htm
Free Java/C#, etc. tutorials:
http://www.dickbaldwin.com/toc.htm