extends Node # Variable to store loaded JSON data var data var amount # Get all needed things for Ui.placeFields and save amount from it. func _ready(): data = Content.data var container = $"ScrollContainer/VBoxContainer" Ui.placeFields(data, container, true) amount = data.get("amount") # Upon pressing the "Send" button func _on_button_pressed(): # Create the save path based on which ID was entered var savePath = "user://player_" + $"ScrollContainer/VBoxContainer".get_child(0).text + ".json" # Get data from the fields to save, except the first one, which is the ID and should be used in the filename. var saveData = {} for i in range(int(data.get("amount"))): if i > 0: saveData[data.get(str(i))] = $"ScrollContainer/VBoxContainer".get_child(i).text # Call the global save function Save.saveJSON(savePath, saveData) # Only for the Main Menu "shortcut" func _process(delta): if Input.is_action_pressed("escape"): get_tree().change_scene_to_file("res://scenes/menu/main.tscn")