Thread: Save Tool
View Single Post
Old
Dj Tech42
Senior Member
 
Dj Tech42's Avatar
 
Status: Offline
Posts: 202
Join Date: Feb 2011
Default 02-11-2012, 04:33 PM

Quote:
Originally Posted by arty-fishL View Post
I would prefer you didn't.

The author variable is your (the creators) name/nickname, the game title is the title of the game.
Any other way and saves could get mixed up.

If you want to create game profiles for different users then you can. When you use the save_var method you get a name parameter. This can have any value, it doesn't have to relate to the var parameter at all, but for the sake of keeping it simple I suggest you do make it relate somehow.

Because it can have any value, you can request a username from the user or work out some other way of identifying each user and getting a unique string out of it for their profile. You can then simply join the username and the string you would have set the name parameter to. I suggest joining them with a "." in the middle.

eg. If I entered my username as "Arty-fishL" and the name being used to identify the variable being saved was "score" then the value to use as the name parameter for the save_var method would be:
"Arty-fishL.score"
Or if my username was "Dj Tech" it would be:
"Dj Tech.score"

Does that make sense?
Take a look at my attached example that uses the eg
Enter a username
Press green to increase your score
Red to reset it
Restart the world and enter the same name, your score will load
Try it with different names
Basically all I need is a function that returns the joined string and a variable to keep track of the username? Wow, it's a lot easier than I thought.

I guess I don't think as much in a programming sense when I'm using Alice. If I was using Java, I would have figured it out quickly. But, I forgot that you could return things in Alice. Thanks.


Flight Simulator with Dogfight Modes:
http://www.alice.org/community/showthread.php?t=6840
   
Reply With Quote