Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Share Objects (http://www.alice.org/community/forumdisplay.php?f=8)
-   -   Save Tool (http://www.alice.org/community/showthread.php?t=7968)

arty-fishL 02-11-2012 04:23 PM

1 Attachment(s)
[QUOTE=Dj Tech42;46419]Can you use the author string to make profiles? (separate variables for every user playing the game)[/QUOTE]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 [I]save_var[/I] method you get a [I]name[/I] parameter. This can have any value, it doesn't have to relate to the [I]var[/I] 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 [I]name[/I] 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 [I]name[/I] parameter for the [I]save_var[/I] 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

Dj Tech42 02-11-2012 04:33 PM

[QUOTE=arty-fishL;46422]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 [I]save_var[/I] method you get a [I]name[/I] parameter. This can have any value, it doesn't have to relate to the [I]var[/I] 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 [I]name[/I] 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 [I]name[/I] parameter for the [I]save_var[/I] 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[/QUOTE]

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. :)

sfunk 03-09-2012 10:06 AM

So this tool has come out at the right time, I am going to try to use this and the world loader tool with the Legend of Zelda game I am currently making, if it was to be one Alice world, it definitely would have been way to big and laggy

sfunk 03-23-2012 08:38 AM

So for some reason I cannot use the tool to save number variables, it won't give me the option, I got the string save to work just fine?

Never mind, I didn't realize that you had to manually type in the name of the number variable instead of being able to use the drop down menu like you can with a string.

arty-fishL 03-23-2012 10:52 AM

[QUOTE=sfunk;47547]So for some reason I cannot use the tool to save number variables, it won't give me the option, I got the string save to work just fine?

Never mind, I didn't realize that you had to manually type in the name of the number variable instead of being able to use the drop down menu like you can with a string.[/QUOTE]Sorry if I didn't make that too clear. I'm not too sure what you mean by "being able to use the drop down menu like you can with a string", as you should still have to type in the name. It should only be a minor inconvenience though.

sfunk 03-23-2012 11:18 AM

[QUOTE=arty-fishL;47553]Sorry if I didn't make that too clear. I'm not too sure what you mean by "being able to use the drop down menu like you can with a string", as you should still have to type in the name. It should only be a minor inconvenience though.[/QUOTE]

Well I used the save tool with a number variable and a string variable. The string variable was able to be located in the drop down menu under expressions (like using an if/else statement)

However, I tried the same procedure with a number variable, but it would not let me locate it under expressions, which I then just tried typing the variable's name in, which worked. I was just confused at first, but I now have it working.

KcajBR 04-29-2012 08:12 PM

[QUOTE=arty-fishL;46415]Two answers.

The save data is stored in one file; location "[I]Alice 2.2\Required\saveToolData[/I]" (it has no extension). That file is basically a stringified python structure and therefore loads and saves nicely with python.

The author string and game title string are both in place just to ensure each save variable gets a unique name and people who use the same game title don't overwrite each others saves. I may also give it other uses in the future, but for now its just an easy way to create unique save variable names.[/QUOTE]

How can I change the place where the save data is? instead of having it in Alice 2.2\Required\saveToolData have it in myWorldFolder\saveToolData

By the way nice job.

arty-fishL 04-30-2012 11:46 AM

1 Attachment(s)
[QUOTE=KcajBR;48434]How can I change the place where the save data is? instead of having it in Alice 2.2\Required\saveToolData have it in myWorldFolder\saveToolData

By the way nice job.[/QUOTE]Thankyou. I would really like all of the save data in one file, as this tool replaces my old tool which had files scattered about all over the place. If you must change the save location, then try the attached model. It has a "save_filename" variable, just edit that (by default it will save to the "Alice 2.2\Required" directory if you do not enter a full path name).

KcajBR 04-30-2012 03:45 PM

[QUOTE=arty-fishL;48443]Thankyou. I would really like all of the save data in one file, as this tool replaces my old tool which had files scattered about all over the place. If you must change the save location, then try the attached model. It has a "save_filename" variable, just edit that (by default it will save to the "Alice 2.2\Required" directory if you do not enter a full path name).[/QUOTE]

Thank You for answering so fast, and also for solving my problem, it works great. Thank You.

arty-fishL 04-30-2012 08:57 PM

[QUOTE=KcajBR;48446]Thank You for answering so fast, and also for solving my problem, it works great. Thank You.[/QUOTE]you're welcome :)


All times are GMT -5. The time now is 01:05 PM.

Copyright ©2020, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.