• SupportSolved
  • Saving save_data.json files with password, are not working properly

Does the issue occur in the editor or during gameplay? If it occurs during gameplay, please specify which movement system is being used (free movement or grid movement):

Gameplay, Grid

Briefly describe the issue you're experiencing:

When trying to figure out if the save_data(data, filename, *password) would prevent me from deleting the file or uploaded the file without using the password.

When I saved the save_data.json file with a password when reloading the file, it did not prompt a requirement to load the data, still it was possible to delete the file using a script, and when trying to open the save_data.json in VS Code, it was not eligible.

However, when trying to use this process with a save_data.json without a password, the json.file could be loaded and read in VS Code with no issues.

The test was to save a data_file as a json.file without the password, then read it using VScode, and then saving one with a password to see if it matter when you loaded or try to read it in VScode.

Are there any errors in the in-game debug console or external console window?

External console prints this:
ERROR: Script inherits from native type 'Reference', so it can't be instanced in object of type: 'Node2D'
At: modules\gdscript\gdscript.cpp:329

Provide the steps necessary to reproduce the issue:
@ @ @ @
1) Create a script that will save an save_data.json task to be triggered once a new game is activated, this way the script can save the data, with a password requirement, in a Json format.

2) Start a new game and allow the script to run for couple seconds or mins, then quit the game.

3) Using VS Code, try to read the save_data.json file.

4) Now activate the game and continue, once you’re in the game, reload your save_data.json file.

5) Open Console to check for errors and then record any errors.

6) Repeat step 2 to 5 with a script that can save the JSON file without the password requirement.

7) Document any changes or errors between the two processes.

Provide a download link to the bare bones project (if applicable):

Can provide files if necessary.


$file2 = data["npcs2.json"];
print($file2);
for $x in $file2 do
    $ent_id = $file2[$ent_num]["id"];
    for $prop in $file2[$ent_num]["props"] do
        entity[$ent_id].property[$prop] = $file2[$ent_num]["props"][$prop];
    end;
    for $stat in $file2[$ent_num]["stats"] do
        entity[$ent_id].stat[$stat] = $file2[$ent_num]["stats"][$stat];
    end;
    $ent_num += 1;
end;

for $skil in data["skills.json"] do
	global.property[$skil] = data["skills.json"][$skil];
end;

give_item("ITEM_0012", 1, entity["RED DEVIL BAT"]);
give_item("ITEM_0011", 1, entity["RED DEVIL BAT"]);
equip_item(entity["RED DEVIL BAT"], "right_hand", "ITEM_0012");

$string1 = "some test";
$var = 290;
$bool = false;
$cody = codex["value1": $string1, "value2": $var, "value3": $bool];
save_data($cody, "save_dat.json");```

    This is what the save_data.JSON file looks like in VS Code with a password, when you try to read it.

    Omegalight27 It seems to be working for me when saving both a data file that is both a generic data file and a json file.

    This image is from trying to open a json file saved with a password.
    First time I tried without adding a second parameter and it just came back null, the second time I supplied an empty string and it actually returned an error.

    Can you provide the code for your load_data to see how you are doing it specifically?

    Does it work properly if you save_data and don't try to open it in VS first?

    After some testing, I believe we have tracked this down to a save game that was created before the json file with the password was created so was using old code.

    Just discovered that old save games remember and use script code that was valid at the time of saving, while the actual file has since been altered.

    I gained a better understanding of how this process works, this is a win in my book!

    ~