PDA

View Full Version : Save Tool


arty-fishL
01-21-2012, 11:59 PM
Arty-fishL's Save Tool

Description
http://img408.imageshack.us/img408/8206/reviewseparator.png
This is basically File I/O Tool - version 2.
For the old tool click here (http://alice.org/community/showthread.php?t=6758).

This is a save tool based upon my previous File I/O Tool.
It is much simpler and easier to use.
It is capable of saving and loading world variables.

Instructions
http://img408.imageshack.us/img408/8206/reviewseparator.png
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 - game_title - to the name of your game.
Set saveTool's variable - author - to your name.

Compatability
http://img408.imageshack.us/img408/8206/reviewseparator.png
So far this only works with world level variables of string or number type.

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

Please use this for game saves from now on.

Updates
http://img408.imageshack.us/img408/8206/reviewseparator.png
2012
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
2013
07 Mar - 1.3 - Added support for the Alicedoc mod (http://alice.org/community/showthread.php?p=52378#post52378)

Further Help
http://img408.imageshack.us/img408/8206/reviewseparator.png
Read below only if you require help:

VARIABLES:
- game_title
Set by you.
The name of the game/world.

- author
Set by you.
Your name/nickname/username.

- has_var_output
Do not change.
The result of a has_var check - true if variable is saved, false if it is not in the save data.

- @alicedoclocalvars
Do not change.
An internal data variable for the Alicedoc mod (http://alice.org/community/showthread.php?p=52378#post52378).

METHODS:
- save_var
Adds a world variable and its value to the save data.
Parameters:
var - the name of the world level variable (without world. at the start), ie. myvar
name - the identifier to use in the save file, it is the name used when loading.

- load_var
Gets a value from the save data and sets a world level variable as it.
Parameters:
name - the identifier used in the save file
var - the name of the world level variable (without world. at the start), ie. myvar.

- has_var
Checks if a variable is in the save data and then
sets saveTool's has_var_output variable to true or false if it exists or not.
Parameters:
name - the identifier used in the save file.

Support me by using this DOWNLOAD link (http://adf.ly/8J0dL) (AdF.ly)

Dj Tech42
01-22-2012, 12:01 AM
Awesome! This is a lot easier and more automatic than the other FileIOTool.

arty-fishL
01-22-2012, 12:20 AM
Awesome! This is a lot easier and more automatic than the other FileIOTool.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, 09:58 AM
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.

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, 10: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, 10:35 AM
Ought I to sticky this post most excellent?

Dj Tech42
01-22-2012, 11:08 AM
Ought I to sticky this post most excellent?

Yes

jediaction
01-22-2012, 12: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, 12:10 PM
Multiquote time
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.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 game_title and author variables otherwise you might interfere with somebody else's saves.

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.:confused:That's the World Loader Tool you're talking about, this is a new tool for saving.

Ought I to sticky this post most excellent?
YesYay :D.

x2495iiii
01-22-2012, 12:15 PM
Forsooth.

DensetsuNoKaboom
01-22-2012, 02:28 PM
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, 06: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.ScriptProper ty[name=script,owner=edu.cmu.cs.stage3.alice.core.res ponse.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, 07:54 PM
Any error for this FileIOTool.. I will try to download this one... thanks

arty-fishL
01-25-2012, 03: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.

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

InsertName
01-25-2012, 08:11 PM
Now I can finally make long RPGish games.

TauTrumpsPi
01-27-2012, 06: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, 06:08 PM
Now I can finally make long RPGish games.
I know what I'm gonna do today!

GameKid
02-11-2012, 02: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, 05:20 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)?
Two answers.

The save data is stored in one file; location "Alice 2.2\Required\saveToolData" (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, 01:10 PM
Two answers.

The save data is stored in one file; location "Alice 2.2\Required\saveToolData" (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.

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

arty-fishL
02-11-2012, 03:23 PM
Can you use the author string to make profiles? (separate variables for every user playing the game)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

Dj Tech42
02-11-2012, 03:33 PM
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. :)

sfunk
03-09-2012, 09: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, 07: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, 09:52 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.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, 10:18 AM
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.

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, 07:12 PM
Two answers.

The save data is stored in one file; location "Alice 2.2\Required\saveToolData" (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.

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, 10:46 AM
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.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, 02:45 PM
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).

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

arty-fishL
04-30-2012, 07:57 PM
Thank You for answering so fast, and also for solving my problem, it works great. Thank You.you're welcome :)

Greylar
07-01-2012, 10: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.ScriptProper ty[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-01-2012, 11:39 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.ScriptProper ty[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"?


Update Alice.

arty-fishL
07-02-2012, 04:44 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.ScriptProper ty[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"?

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, 05: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, 06:18 PM
What's rebecca...?

Greylar
07-02-2012, 06:50 PM
What's rebecca...?
The spanish version of Alice.

arty-fishL
07-03-2012, 08:14 AM
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 :)

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, 01: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, 02:31 PM
It doesn't load my world.
What am I doing wrong?

Beans
07-03-2012, 02:48 PM
Well, it actually says "Error during Simulation":confused:

Greylar
07-03-2012, 06:09 PM
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.
Don't worry, I've learned to use the "IO Tool", but although a little more work, I work well :D
All I saw was that he could not carry numeric or Boolean variables, so the change and add a couple of methods that are used to that. I hope you do not mind :P

arty-fishL
08-05-2012, 09:08 PM
I've updated the internal code. There is no change to surface functionality, except that this version (1.2) of the Save Tool is the minimum version that will work in conjunction with the ArtyOnline Tool when I release it.

Dj Tech42
08-05-2012, 09:15 PM
I've updated the internal code. There is no change to surface functionality, except that this version (1.2) of the Save Tool is the minimum version that will work in conjunction with the ArtyOnline Tool when I release it.

Will the Save Tool be able to store high scores and progress on ArtyOnline?

arty-fishL
08-06-2012, 12:56 AM
Will the Save Tool be able to store high scores and progress on ArtyOnline?The Save Tool is for local storage. Right now its use in conjunction with the ArtyOnline Tool is to save server details. I'm going to create a Cloud Tool for ArtyOnline storage.

Save Tool - local saves and loading
Cloud Tool - ArtyOnline/AODb saves and loading (including highscores)
ArtyOnline Tool - for multiplayer connections with the ArtyOnline Server Application

arty-fishL
04-06-2013, 07:39 PM
Latest update adds support for the Alicedoc mod (http://alice.org/community/showthread.php?p=52378#post52378).

This just means it should be easier to get help for this from within Alice without having to refer back to this page.

DensetsuNoKaboom
05-24-2016, 08:08 PM
PSA: Do not try to save or load lists or arrays. The Save Tool will break so badly that it will cause world-crashing errors every time it tries to save or load anything unless you redownload Alice.