Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lavaduder | |
Old Version | Published before Godot 3 was released. |
I’m having trouble loading a file path into my save system, _file_selected( String path )
What I am doing is saving the path to the file in a var called filepath.
I then use this path in the savegame function to open a file
(AKA File.new().open(filepath,File.WRITE)
)
However I am having trouble getting the filepath when loading/opening the file. Save mode works, but not MODE_OPEN_FILE
extends Control
var num = 0
var filepath
#Nodes
var file #The name of the FileDialog, Confusing I know.
func _ready():
file = get_node("file")
pass
#File node
func display_file(filetype):
file.set_hidden(false)
file.set_mode(filetype)
func _on_file_file_selected( path ):
filepath = path
if file.MODE_SAVE_FILE:
print("save")
print("Filename: "+str(file.get_current_file()))
elif file.MODE_OPEN_FILE:
print("load")
print("Filename: "+str(file.get_current_file()))
else:
print("Error, Could not load/Save")
print(path)
#Click button
func _on_click_pressed():
num += 1
get_node("click").set_text(str(num))
#Save and Load buttons
func _on_save_pressed():
display_file(file.MODE_SAVE_FILE)
func _on_load_pressed():
display_file(file.MODE_OPEN_FILE)
I am using the current stable branch 2.1.3