Godot Engine
Reading text files with gdscript
Hello,

I can't seem to figure out how to read text from a file in Godot. I'm not having any problem opening the file, just reading text from it. get_as_text doesn't work, as I need to get dozens of strings from the file, not just turn the file into one big string. Normally, I'd just change the file format it order to accomodate this, but I'm working with large proprietary files.

Thanks for your time!
< >
Se afișează 1-2 din 2 comentarii
Valdar 11 febr. 2018 la 22:55 
Have you tried "get_csv_line"?

From the docs...
PoolStringArray get_csv_line ( String delim=”,” ) const
Returns the next value of the file in CSV (Comma Separated Values) format. You can pass a different delimiter to use other than the default ”,” (comma).
-----------------------------------------------------------------------

As for your current attempt, how does "get_as_text " not work? If it works but reads the entire file into a variable, you could just parse it from there. Redardless of the technique, the source strings need to be delimited by something (even if just a CR), or it really is just one big string.
I'm having some trouble using a different delimiter, but just using the default comma (despite the total absence of commas) actually worked wonders. Thanks for the help!
Editat ultima dată de Karasawa MKII; 12 febr. 2018 la 7:57
< >
Se afișează 1-2 din 2 comentarii
Per pagină: 1530 50

Data postării: 11 febr. 2018 la 19:41
Postări: 2