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 01-22-2012 12:59 AM

Save Tool
 
2 Attachment(s)
[FONT=Impact][SIZE=4][COLOR=DarkGreen]Arty-fishL's[/COLOR] Save Tool[/SIZE][/FONT]
[FONT=Impact][COLOR=DimGray]
[SIZE=3]Description[/SIZE][/COLOR][/FONT]
[IMG]http://img408.imageshack.us/img408/8206/reviewseparator.png[/IMG]
This is basically File I/O Tool - version 2.
For the old tool [URL="http://alice.org/community/showthread.php?t=6758"]click here[/URL].

This is a save tool based upon my previous File I/O Tool.
It is much simpler and easier to use.
[B]It is capable of saving and loading world variables.[/B]
[FONT=Impact][SIZE=3][COLOR=DimGray]
Instructions[/COLOR][/SIZE][/FONT]
[IMG]http://img408.imageshack.us/img408/8206/reviewseparator.png[/IMG]
Import the object into the world you want to use it in.
Don't rename it and don't delete any of its variables, methods or events.

Set saveTool's variable - [I]game_title[/I] - to the name of your game.
Set saveTool's variable - [I]author[/I] - to your name.
[FONT=Impact][SIZE=3]
[COLOR=DimGray]Compatability[/COLOR][/SIZE][/FONT]
[IMG]http://img408.imageshack.us/img408/8206/reviewseparator.png[/IMG]
So far this [B]only works with world level variables of string or number type[/B].

This can be used simultaneously with the File I/O Tool.

Please use this for game saves from now on.

[FONT=Impact][SIZE=3][COLOR=DimGray]Updates[/COLOR][/SIZE][/FONT]
[COLOR=Gray][IMG]http://img408.imageshack.us/img408/8206/reviewseparator.png[/IMG]
[B][SIZE=1]2012[/SIZE][/B][/COLOR]
22 Jan - 1.0 - Original version
25 Jan - 1.1 - Fixed bug with validity check
06 Aug - 1.2 - Added internal functionality for ArtyOnline Tool compatibility
[COLOR=Gray][B][SIZE=1]201[SIZE=1]3[/SIZE][/SIZE][/B][/COLOR]
07 Mar - 1.3 - Added support for the [URL="http://alice.org/community/showthread.php?p=52378#post52378"]Alicedoc mod[/URL]

[FONT=Impact][SIZE=3][COLOR=DimGray]Further Help[/COLOR][/SIZE][/FONT]
[IMG]http://img408.imageshack.us/img408/8206/reviewseparator.png[/IMG]
[B]Read below only if you require help:[/B]
[COLOR=black]
[/COLOR] [COLOR=black][U][SIZE=1][B]VARIABLES:[/B][/SIZE][/U][/COLOR]
[SIZE=1][COLOR=Blue][B]- game_title[/B][/COLOR]
[/SIZE][SIZE=1][COLOR=DarkGreen]Set by you.[/COLOR]
The name of the game/world[/SIZE][SIZE=1].[/SIZE][SIZE=1]

[COLOR=Blue][B]- author[/B][/COLOR]
[COLOR=DarkGreen]Set by you.
[/COLOR]Your name/nickname/username[/SIZE][SIZE=1].[/SIZE][SIZE=1]

[/SIZE][SIZE=1][COLOR=Blue][B]- has_var_output[/B][/COLOR]
[COLOR=Red]Do not change.[/COLOR]
The result of a [COLOR=Sienna][I]has_var[/I][/COLOR] check - true if variable is saved, false if it is not in the save data.[/SIZE]

[SIZE=1][COLOR=Blue][B]- @alicedoclocalvars[/B][/COLOR]
[COLOR=Red]Do not change.[/COLOR]
An internal data variable for the [URL="http://alice.org/community/showthread.php?p=52378#post52378"]Alicedoc mod[/URL].[/SIZE]

[COLOR=black][U][SIZE=1][B]METHODS:[/B][/SIZE][/U][/COLOR]
[SIZE=1][COLOR=Sienna][B]- save_var[/B][/COLOR]
Adds a world variable and its value to the save data.
[COLOR=Indigo][COLOR=black][U]Parameters:[/U][/COLOR]
var[/COLOR] - the name of the world level variable (without [I]world.[/I] at the start), ie. [I]myvar[/I]
[COLOR=Indigo]name[/COLOR] - the identifier to use in the save file, it is the name used when loading.

[COLOR=Sienna][B]- load_var[/B][/COLOR]
Gets a value from the save data and sets a world level variable as it.[/SIZE][SIZE=1]
[U][COLOR=black]Parameters:[/COLOR]
[/U][/SIZE][SIZE=1][COLOR=Indigo]name[/COLOR] - the identifier used in the save file
[/SIZE][SIZE=1][COLOR=Indigo]var[/COLOR] - the name of the world level variable (without [I]world.[/I] at the start), ie. [I]myvar[/I].[/SIZE][SIZE=1]

[/SIZE][SIZE=1][COLOR=Sienna][B]- has_var[/B][/COLOR]
Checks if a variable is in the save data and then
sets saveTool's [COLOR=Blue][I]has_var_output[/I][/COLOR] variable to true or false if it exists or not.[/SIZE][SIZE=1]
[U][COLOR=black]Parameters:[/COLOR]
[/U][/SIZE][SIZE=1][COLOR=Indigo]name[/COLOR] - the identifier used in the save file[/SIZE][SIZE=1].[/SIZE]

[SIZE=2][B]Support me by using [URL="http://adf.ly/8J0dL"][B][SIZE=2]this DOWNLOAD link[/SIZE][/B][/URL][/B] (AdF.ly)[/SIZE]

Dj Tech42 01-22-2012 01:01 AM

Awesome! This is a lot easier and more automatic than the other FileIOTool.

arty-fishL 01-22-2012 01:20 AM

[QUOTE=Dj Tech42;45898]Awesome! This is a lot easier and more automatic than the other FileIOTool.[/QUOTE]So, have you tried it then?
It works with numbers too, so there's no need for the string to number conversion idea I was going to implement before.

Dj Tech42 01-22-2012 10:58 AM

[QUOTE=arty-fishL;45902]So, have you tried it then?
It works with numbers too, so there's no need for the string to number conversion idea I was going to implement before.[/QUOTE]

I was using your string-to-number conversion script before, but this should make things faster.
I haven't been able to try this yet, but it sounds good. However, I may have to change some things to make it cross-platform like I did with the File I/O Tool.

jediaction 01-22-2012 11:19 AM

I used it in Halo 2. It works great, but you have to have the file it is looking for to switch to, in the same folder.

x2495iiii 01-22-2012 11:35 AM

Ought I to sticky this post most excellent?

Dj Tech42 01-22-2012 12:08 PM

[QUOTE=x2495iiii;45916]Ought I to sticky this post most excellent?[/QUOTE]

Yes

jediaction 01-22-2012 01:07 PM

Very cool. now it's a sticky post. So, what exactly do sticky posts do X2495iiii? I never really learned what they were.

arty-fishL 01-22-2012 01:10 PM

Multiquote time
[QUOTE=Dj Tech42;45909]I was using your string-to-number conversion script before, but this should make things faster.
I haven't been able to try this yet, but it sounds good. However, I may have to change some things to make it cross-platform like I did with the File I/O Tool.[/QUOTE]It should work perfectly cross platform, without any changes. You don't actually do anything with files, that is all handled by the tool, you just ask it to save or load a variable. Everything, for every game using this is stored in one file, this is a better approach than using multiple files. You therefore definitely need to set the [I]game_title[/I] and [I]author[/I] variables otherwise you might interfere with somebody else's saves.

[QUOTE=jediaction;45913]I used it in Halo 2. It works great, but you have to have the file it is looking for to switch to, in the same folder.[/QUOTE]:confused:That's the World Loader Tool you're talking about, this is a new tool for saving.

[QUOTE=x2495iiii;45916]Ought I to sticky this post most excellent?[/QUOTE]
[QUOTE=Dj Tech42;45918]Yes[/QUOTE]Yay :D.

x2495iiii 01-22-2012 01:15 PM

Forsooth.

DensetsuNoKaboom 01-22-2012 03:28 PM

1 Attachment(s)
Looks like this is exactly what Alice needs, thank you! :D

EDIT: I made a simple world to test this tool. It works perfectly as far as I can tell.

Dj Tech42 01-24-2012 07:53 PM

I'm getting a KeyError with it...


Error during simulation.


Alice version: 2.2 12/01/2011

Throwable that caused the error:
Traceback (innermost last):
File "edu.cmu.cs.stage3.alice.core.property.ScriptProperty[name=script,owner=edu.cmu.cs.stage3.alice.core.response.ScriptResponse[world.saveTool.has_var.__Unnamed2__]]", line 1, in ?
File "<string>", line 42, in has
KeyError: Dj Tech42.License to Fly.__default

Lirtjasksta 01-24-2012 08:54 PM

Helpful
 
Any error for this FileIOTool.. I will try to download this one... thanks

arty-fishL 01-25-2012 04:25 AM

I know I said I will be gone for a while, but I cant leave without fixing bugs in this :).

Dj Tech42, the error your getting is in a validity check I have. For every game there is a default value automatically saved upon every save that must equal "valid", under the name "__default" (please don't use any names with double underscores at the start when saving, they are reserved for use by the internal workings of the tool, I should have said that in the main post, but that is not the problem here anyway).
What I should have noticed in the code is that when that value does not exist there will be an error when the code tries to get it.

I've fixed it by adding my friendly dict class (a class that emulates a python dictionary, but does not throw horrible errors) that I built for Addons.

[B]I've updated the top post with the new version.[/B]
I hope no more bugs come up, bye for a while.

InsertName 01-25-2012 09:11 PM

Now I can finally make long RPGish games.

TauTrumpsPi 01-27-2012 07:56 PM

This is actually exactly what I was using the file I/O tool for in the first place. This looks great, thanks Arty!

DensetsuNoKaboom 01-28-2012 07:08 PM

[QUOTE=InsertName;46011]Now I can finally make long RPGish games.[/QUOTE]
I know what I'm gonna do today!

GameKid 02-11-2012 03:33 AM

Two questions.
Where are the saved strings and numbers placed when saved, and what does the author string change (Example, how will the result be different if I enter A for the name from the result if I enter B for the name)?

arty-fishL 02-11-2012 06:20 AM

[QUOTE=GameKid;46413]Two questions.
Where are the saved strings and numbers placed when saved, and what does the author string change (Example, how will the result be different if I enter A for the name from the result if I enter B for the name)?[/QUOTE]
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.

Dj Tech42 02-11-2012 02:10 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]

Can you use the author string to make profiles? (separate variables for every user playing the game)

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

Greylar 07-01-2012 11:05 PM

Great job!
When I import the object and squeezed in "Play" I get this error:

"Rebeca versión: 2.2 8/1/2009

Throwable que causó el error:
Traceback (innermost last):
File "edu.cmu.cs.stage3.alice.core.property.ScriptProperty[nombre=script,propietario=edu.cmu.cs.stage3.alice.core.response.ScriptResponse[Mundo.saveTool.event.__Unnamed0__]]", line 1, in ?
File "<string>", line 3, in ?
ImportError: No module named python"

It will be because I use to "Rebeca" instead of "Alice"?

beachbum111111 07-02-2012 12:39 AM

[QUOTE=Greylar;50310]Great job!
When I import the object and squeezed in "Play" I get this error:

"Rebeca versión: 2.2 8/1/2009

Throwable que causó el error:
Traceback (innermost last):
File "edu.cmu.cs.stage3.alice.core.property.ScriptProperty[nombre=script,propietario=edu.cmu.cs.stage3.alice.core.response.ScriptResponse[Mundo.saveTool.event.__Unnamed0__]]", line 1, in ?
File "<string>", line 3, in ?
ImportError: No module named python"

It will be because I use to "Rebeca" instead of "Alice"?[/QUOTE]


Update Alice.

arty-fishL 07-02-2012 05:44 PM

[QUOTE=Greylar;50310]Great job!
When I import the object and squeezed in "Play" I get this error:

"Rebeca versión: 2.2 8/1/2009

Throwable que causó el error:
Traceback (innermost last):
File "edu.cmu.cs.stage3.alice.core.property.ScriptProperty[nombre=script,propietario=edu.cmu.cs.stage3.alice.core.response.ScriptResponse[Mundo.saveTool.event.__Unnamed0__]]", line 1, in ?
File "<string>", line 3, in ?
ImportError: No module named python"

It will be because I use to "Rebeca" instead of "Alice"?[/QUOTE]

I believe this is an error relating to Rebecca, but I'm sure I've tested this in Rebecca before and it worked. unfortunately I am not at a computer right now and won't be for several weeks, so I can only guess.

Greylar 07-02-2012 06:12 PM

The old tool: "I / O Tool" works perfectly in Rebecca, but it's too complicated. It's a shame, since I can not update the program: P
I'll have to use I / O Tool, thank you very much as :)

GameKid 07-02-2012 07:18 PM

What's rebecca...?

Greylar 07-02-2012 07:50 PM

[QUOTE=GameKid;50321]What's rebecca...?[/QUOTE]
The spanish version of Alice.

arty-fishL 07-03-2012 09:14 AM

[QUOTE=Greylar;50320]The old tool: "I / O Tool" works perfectly in Rebecca, but it's too complicated. It's a shame, since I can not update the program: P
I'll have to use I / O Tool, thank you very much as :)[/QUOTE]

I made the save tool because the IO Tool was too complicated and messy, so I completely understand if you would prefer to use the Save Tool.

I will have to find out what is wrong when I get back home in a few weeks. For now of you would like to see some examples of the IO Tool in use I think the flight sim by DJ Teck uses it.

GameKid 07-03-2012 02:01 PM

Perhaps rebecca has different file/folder names, or different file/folders period? So the save tool is confused on where to save?
For example. Save tool is programmed to save in alice/english-folder-name/here. But what if rebecca has instead rebecca/spainish-folder-name/here?

Beans 07-03-2012 03:31 PM

?????
 
It doesn't load my world.
What am I doing wrong?

Beans 07-03-2012 03:48 PM

Hmmmm.....
 
Well, it actually says "Error during Simulation":confused:


All times are GMT -5. The time now is 09:04 PM.

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