Game Custom Data v1.26

This script saves a different data than your game's data, it doesn't matter where your game is...


now if you want it to save the custom data into your game's folder, you need to define the exact path + get the updated script and use nil for DATA_PATH (no "") since Ruby's call to ENV doesn't seem to know what CD means...


but then again, if the player puts the game into another folder, then the file is now out of that folder again...


I'm still trying to find the CD equivalent in Ruby so that you can flawlessly use the current folder
I just want it to work, I don't care where it is saved at... given that it works independently of where the game is saved what is a likely reason for the default set up not working for me either on a windows 7 computer with the game where it is. Regardless of whether I create said file path or leave it blank (as the script states it automatically creates a folder path). Like I said, nothing I try seems to work with it, I just assumed that I had to create an exact file path to my game directory for lack of knowledge of why else it might not be working.
So the file wasn't created on the path I gave you on the last post? can I have a screenshot of your AppData\Roaming\ folder?
As far as I can tell there isn't a file being created at all.
As far as I can tell there isn't a file being created at all.
Hmmm... that's weird... can I have a screenie of the AppData\Roaming\ folder?


PS: Uhm, you have it Appdata, try changing it back to AppData, run the game then check your AppData\Roaming folder again


PS 2: can you try playing Chicken Games, then go to AppData\Roaming\LanthanumEntertainment\Games\Chicken Games\ and see if the data is created? It uses this very script for that, so if that one creates the file then something is interfering in your set-up
I downloaded and tried out a little of Chicken games (each of the games 1 time) and then opened up AppData\Roaming and nothing is there. 



I don't know what exactly chicken games saves (I assume your chicken score when you press x or something) but I think at this point I'm going to assume some setting on my computer might be interfering with the scripts ability to create a file path since it doesn't seem to create anything there either.

Edit: Ah, changed it to AppData and it still shows no result.
why does it say Search results???? it should look like this:


C:\Users\WhateverUsernameyouhave\AppData\Roaming


as I told you on the last page


so your's would be


C:\Users\RinandAlex\AppData\Roaming
Ok, yeah I was looking in the wrong place. It is creating a file path and I have like 2 dozen empty folders now with every filepath convention I've tried so far, as well as chicken game's data.

Edit: I still cannot actually save the game however. Using the function CustomData.save creates the scripts data file within the path so it appears that the script is working, but actually saving progress in the game is cut off still. 
Oh, I see...


just make sure you don't change paths again after releasing the game, else your players will need to manually migrate the data into the correct folder
Hi!

The script is pretty nice, and it's just what I needed, but I must say there is a critical bug on it.

On the overriding for saving the game added on version 1.21 (the one available from the link in the original post), a parameter is missing when calling the original save method. That makes the saving of the game ALWAYS fail, which in the end means deleting the save file for the slot you are trying to save in, in case there was something there already(As that's the rescue operation on DataManager).

Basically, where it says:

class <<self; alias save_game_without_rescue_customdata save_game_without_rescue; end
def self.save_game_without_rescue(index)
    save_game_without_rescue_customdata
    DataManager.save_customdata
    return true
end

It should say:

class <<self; alias save_game_without_rescue_customdata save_game_without_rescue; end
def self.save_game_without_rescue(index)
    save_game_without_rescue_customdata(index)
    DataManager.save_customdata
    return true
end

Apart from that, pretty awesome and useful. I'm using it to store the language for the user, as I built a framework to have several translations, and I just laked a way to let the user choose a language and save that setting between games/gameplays.

EDIT:

I also found another issue on the load database method, on the line to create the path:

It says:

@spath = ENV[ADIK:😀ATA:😀ATA_PATH].nil? ? ENV[ADIK:😀ATA:😀ATA_PATH] + "\\" : ""

If you check, the condition is inverted, so when the data path is nil, it tries to assign the value to spath (Which utterly fails and cause a crash when it tries to append the "\\" part, because nil can not be converted to string), and if the path is not nil, then it stores the empty folder.
Thanks for the notifs... The errors seems to not come up with my tests so I didn't notice them... I'll work on those when I get the time
Updated for bug fixes
I need some serious help with your script.  🙁

My problem is this:

I put this exact script call on an event:

CustomData.add($game_variables[11], 1)

When it tries to execute I get this exact error:

Script 'Game_Interpreter' line 1411: NoMethodError occured.

undefined method `+' for nil:NilClass

When I use .sub, there's - instead of + in the error.

I really don't know what I'm doing wrong. I tried searching all over the place for a solution, but to no avail.

I don't know if it's my fault or the scripts or whatevers.

I'll be VERY thankful if someone could help me.
Are you sure that "$game_variables[11]" holds something? That should be the name of the variable you want to set, rather than the value.

What does "$game_variables[11]" contain?

Also, before "adding" to it. Did you set it first with the initial value? (0, or whatever default value you have?)

Cheers!
When I set the initial value to 0, and then add 1 in THE SAME event, I don't get the error.

I think that I tried setting the initial value earlier, but it was in another event, and I got the error.

But now, even though I didn't get it, when I call for CustomData.get($game_variables[11]), the variable is still zero, which I think means that the variable didn't get saved. 🙁
Hi!

What do you store inside $game_variables[11] ?

Cheers!
I'm trying to store only one number there.
I think that's the problem. The first value of those methods should be the name you want to use to store or read the value.

For example you init it with CustomData.set('SAVE_COUNT', 0);

Then, when you want to increase it

CustomData.add('SAVE_COUNT' , 1);

$game_variables[11] = CustomData.get('SAVE_COUNT');

The last line also serves when starting up, to load the stored value into the game variable. Instead of 'SAVE_COUNT' use whatever name makes sense for what you are storing there.

Cheers!
I did exactly like you wrote here and now I get a different error:

Script 'Game_Interpreter' line 1411: ArgumentError occured.

wrong number of arguments (0 for 1)

Setting the value goes fine, but when it tries to add, this happens. I guess the value didn't get set after all?

EDIT

The error happenes at line $game_variables[11] = CustomData.get('SAVE_COUNT').

...Any ideas?

EDIT #2

I got it to work in a singe event! 😀

Here's what I set in the event:

[the variable is named "reward"]

Script: CustomData.set("reward", 0)

Script: CustomData.add("reward", 1)

Control Variables: [0011:reward] = CustomData.get("reward")

When I call for the variable in text, it shows the correct number! And that's great!

I did what you told me to do, but in the last step, instead of using a script, I used the Control Variable Event Command.

I will check if it works in other maps.

It works as intended!

I just have to use the Control Variable to get the variables I need!

Thank you so much for help Disruption! Without it, I would be stuck for who knows how long! 😀 Thanks again!
The script was made for your own custom data, not to modify existing variables coz that's doable already as you've discovered... 🙂

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