Game Custom Data v1.26

-Overview-


So basically this allows the creation of an extra file for modifying and saving custom data during runtime that is not linked to a save file so that you can share those data in-between saves and even in-between different games.


You can modify the path, file name and path of the custom data file via constants


-Usage-


You can get a data, modify a data and save the file via simple script calls (included in the header)


Loading of the file is automatically done upon starting the game


-Link-


Get it here: http://lescripts.wordpress.com/rgss3/game-custom-data-v1-0/


-Add Ons-


Persistent Data (Switches and Variables)


- Changelog -


Version 1.10 - Added some wrappers


Version 1.11 - The data is now reloaded upon going to the title screen and loading data if autosave is not set to true


Version 1.12 - Native support for using ENV paths (AppData,ProgramFiles etc)


- Autocreates folder if it isn't yet created


Version 1.12b - Fixed a wrong variable setting that I saw


Version 1.20 - Realized that the older scripts have typos and such that caused it to not work


so I fixed it now, and fully tested to be working too


Version 1.21 - Made it save custom data when a game is saved


Version 1.22 - Just modified something


Version 1.23 - bug fixes


Version 1.24 – you can now save inside the game’s folder even if the player can move it around


Version 1.25 - fixed a bug where it won't allow loading of save files if autosave is true


Version 1.26 - fixed a missing end which caused the script to be unusable


-Notes-


Make sure you read the header of the script for more info


The script doesn't do much on it's own aside from making the file and loading it upon start-up


Everything else will be determined by how you use it.


The CD keyword for DATA_PATH doesn't seem to be recognized


-Sample Ideas-


You can use it for example counting how many times a player finished a game so that you can make something happen when a player finishes it a couple of times


You can use it as a base for a shared stash (I'm trying to make one in another script)


Basically if you need data that is shared between playthroughs or even between games, this would be a useful script


- Ideas from others -


Shaz

Spoiler
This would also be good as a preferences file (which I was going to write and share, but I won't now 😀 ) where you could save mouse enabled/disabled settings and other options that a player might want to set that affects all games (bgm on/off, window/fullscreen).


If you were to save it into the player's AppData folder instead of the System folder, you could also have several people sharing the same computer who could have their own settings/custom data, that wouldn't be interfered with by others.
- Links to useful posts -


http://forums.rpgmakerweb.com/index.php?/topic/20304-game-custom-data/#entry194065
So, if I understand this right... This allows you to have the save file that players would load and play from, and then there would be a mirror file that you can change game data, like switches, variables, etc? Or am I completely misunderstanding this script?
This would also be good as a preferences file (which I was going to write and share, but I won't now 😀 ) where you could save mouse enabled/disabled settings and other options that a player might want to set that affects all games (bgm on/off, window/fullscreen).


If you were to save it into the player's AppData folder instead of the System folder, you could also have several people sharing the same computer who could have their own settings/custom data, that wouldn't be interfered with by others.
So, if I understand this right... This allows you to have the save file that players would load and play from, and then there would be a mirror file that you can change game data, like switches, variables, etc? Or am I completely misunderstanding this script?
This allows you to save any data that you want (that should persist among saves/games)... You can of course save things like switches etc, but you need to load them back to the switches on your own... or, simply make a Boolean entry to the Custom Data and use it instead of switches...


You can also pair it with Shaz's Linked Variables (is that the right name?) so that you can link the game variables to the custom data... So that using the Game Variable will load the linked Custom Data, though of course, edits should be done to the Custom Data and not the variable (is that right Shaz?)


I originally made it because I wanted a shared stash, then realized that this core can work much more than that so I uploaded it... 🙂


@Shaz - oh yeah, the AppData folder... that's nice... 🙂
Yes, you could use it like that with the Linked Variables script. I'm also going to post a linked switches script, which could also be used in a similar way.


If you were to use it with the linked variables script, and let's say you want variable 1, which, using adiktuzmiko's example, is the number of times the game has been completed, to be saved in custom game data, you would not set the variable with Control Variables (because the Linked Variables script would ignore it). Instead, you would set it via Custom Data:

CustomData.set🙂games_completed, $game_variables[1] + 1)(add 1 to the current value)
(You don't have to call it :games_completed - you could call it "Games Completed", "Variable 1", :variable1, whatever you want)


Then in the Linked Variables script, set up the data like this:

@links[1] = CustomData.get🙂games_completed)(again, just call it whatever you called it when setting it).
Then whenever you used Variable 1 in an event, as a condition, a conditional branch, within a calculation, behind the scenes it would grab it from the custom data.
Maybe I should add a wrapper for the 4 basic math functions and maybe a push wrapper...
This is fantastic. Thank you. I'm using it with my first commercial game. BTW, I love your Terms and Conditions. Succint and more than fair.
glad you like it... 🙂


I'm thinking of adding some more things especially reloading the data from the file upon start screen if autosave is not set to true...
update bump...


It now reloads data from the custom data file upon going back to title screen or loading a saved file if autosave is false (because that means that the current data and the saved data might not be the same, so we load the saved data)...


I cannot test it right now though but I think it works correctly...
Very nice 🙂
Did anyone tested if the current version works? I haven't still got to test it... XD...


and maybe I'll make some add-ons in case I can think of useful ones... 🙂
Update Bump:

Version 1.12 - Native support for using ENV paths (AppData,ProgramFiles etc)


- Autocreates folder if it isn't yet created
Note: This version hasn't been tested yet, though I think it should work without problems


EDIT: updated to 1.12b, hasn't been tested still...


EDIT: Tested it yesterday and realized it has typos and wrong settings... All fixed and working now
BUMP...


and oh well, I just realized that you can also actually save any game data into this ($game_actors for example)


EDIT: Added an Add-On for persistent switches and variables for those who wants it and cannot set it up (not tested)
I can't seem to be able to save my game while using this regardless of how I try to set the filepath (which I assume is why it isn't working, but I'm confused.) Also the Persistent Switches/Variables script gives up a syntax error. (Though that seems unimportant since the base script seems to be able to easily save a switch as persistent anyway, which is what I need right now I just can't save the game with the script active.)
can you show me the path you set? Also, what do you mean by you can't save?


PS: I forgot to test that add-on. XD
I tried several different paths, from the default just including the game folder name of "Horrid Darkness" to giving my exact file path from computer/libraries/documents/Horrid Darkness 

I know I've got to be just not understanding something here.
can you show me the actual set-up on the script? you might have miswritten the path


PS: I can't seem to have a directory here named computer/libraries/documents


my documents folder on this comp (OS=Win7 pro) is named: C:\Users\username\Documents
I know I don't have the path correct. I know I've got the layout correct because I copied the way it was originally as "libraries","documents","Horrid Darkness" 

Which was wrong as you've already pointed out but even if it was the correct path it would then only work on my computer anyway, correct? So the fact that I'm actually trying to detail the specific path isn't the correct way to do it is it? I thought from what I read that's what 'AppData' does with the folder path being what's created within the game but doing that (and creating a folder with the same name as the path) doesn't work either for me. Basically "Game_Name","Saves" and creating the saves folder... as you can probably see by now I don't have a clue what I'm doing with this one. 

Screen of most recent of several different attempts, if that helps:

Spoiler
I know I don't have the path correct. I know I've got the layout correct because I copied the way it was originally as "libraries","documents","Horrid Darkness" 


Which was wrong as you've already pointed out but even if it was the correct path it would then only work on my computer anyway, correct? So the fact that I'm actually trying to detail the specific path isn't the correct way to do it is it? I thought from what I read that's what 'AppData' does with the folder path being what's created within the game but doing that (and creating a folder with the same name as the path) doesn't work either for me. Basically "Game_Name","Saves" and creating the saves folder... as you can probably see by now I don't have a clue what I'm doing with this one. 


Screen of most recent of several different attempts, if that helps:

Spoiler
Using that set-up you posted, your file should be on (assuming it's win7):


C:\Users\YourUserName\Appdata\Roaming\Horrid Darkness\Saves


PS: If you actually tried that libraries etc,


then you should also see a file on:


C:\Users\YourUserName\Appdata\Roaming\libraries\documents\Horrid Darkness


PS 2: AppData folder is normally hidden
[SIZE=10.5pt]Ok, my complete file path to the game is as follows: C:\Users\RinandAlex\Documents\Horrid Darkness[/SIZE]

[SIZE=10.5pt] [/SIZE]

[SIZE=10.5pt]Given this which one should I use between "AppData" and "LOCALAPPDATA" as any of the others crash the game anyway because of permissions and also what should be in the subfolders path? Like I said my first attempts was "Documents","Horrid Darkness" but that's clearly wrong as well. Also would this mean that to use this script anyone who would be playing the game later would have to put the game in the exact file path - the unique user data or is there a way to set it up to find it on it's own? Sorry for all of the trouble, I don't remember feeling this much of a newb when I considered myself to be one but I clearly don’t have the faintest idea how this script is supposed to be set up.[/SIZE]

Original thread: https://forums.rpgmakerweb.com/threads/game-custom-data-v1-26.20304/