The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I have the following pair of methods in my game file handler:

func saveHand(deal, state, pressStack, dealNum):
var file =
var fileName = savePath + "/deal" + str(dealNum) + "-"
fileName += dateTimeStamp() + ".txt", File.WRITE)

var dealPsa
var statePsa
var stackPsa

func retrieveHand(fileName):
var file =, File.READ)
dealPsa = file.get_csv_line() # Get deal psa
statePsa = file.get_csv_line() # Get deal psa
stackPsa = file.get_csv_line() # Get deal psa

The first three arguments to save hand are poolStringArrays and result in the following file:

which, as expected is in the form of thee sets of comma separated values separated by newlines.

However, when retrieveHand(fileName) attempts to read them back dealPsa, statePsa and stackPsa are just three empty poolString arrays. Since the function is called getcsvline() shouldn't it fill the PoolStringArrays with the CSV's in the three lines?

fileName is the name of the file from which the data has been taken, cut and pasted from windows explorer. No errors are thrown. If I print the three variables I just get:
enter code here

in Engine by (38 points)

1 Answer

+1 vote

Never mind. I just answered my own question. I needed to add savePath/ to the filename. What caught me by surprise was that godot didn't make any demur when I tried to open a non existent path. From now on I better use:

var fileN = savePath + "/" + fileName
    if file.exists(fileN):, File.READ)
         print("Error: Can't find file " + fileN )
by (38 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.