From 9acc481319c385966328ea7ca2091ba28f9cb564 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 16 Sep 2024 23:30:13 +0200 Subject: [PATCH] Fix outdated `get_data()` JSON method usage in Saving games Direct member access is now used in Godot 4. --- tutorials/io/saving_games.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tutorials/io/saving_games.rst b/tutorials/io/saving_games.rst index afa7ad1c9..27347278d 100644 --- a/tutorials/io/saving_games.rst +++ b/tutorials/io/saving_games.rst @@ -232,17 +232,17 @@ load function: while save_file.get_position() < save_file.get_length(): var json_string = save_file.get_line() - # Creates the helper class to interact with JSON + # Creates the helper class to interact with JSON. var json = JSON.new() - # Check if there is any error while parsing the JSON string, skip in case of failure + # Check if there is any error while parsing the JSON string, skip in case of failure. var parse_result = json.parse(json_string) if not parse_result == OK: print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line()) continue - # Get the data from the JSON object - var node_data = json.get_data() + # Get the data from the JSON object. + var node_data = json.data # Firstly, we need to create the object and add it to the tree and set its position. var new_object = load(node_data["filename"]).instantiate() @@ -284,7 +284,7 @@ load function: { var jsonString = saveFile.GetLine(); - // Creates the helper class to interact with JSON + // Creates the helper class to interact with JSON. var json = new Json(); var parseResult = json.Parse(jsonString); if (parseResult != Error.Ok) @@ -293,7 +293,7 @@ load function: continue; } - // Get the data from the JSON object + // Get the data from the JSON object. var nodeData = new Godot.Collections.Dictionary((Godot.Collections.Dictionary)json.Data); // Firstly, we need to create the object and add it to the tree and set its position.