![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Tachekentya |
Hi! how can I save each element of an array in a new line of a text file using GDScript? I want each element of the array appears as a new line in the text file.
I am using the following code to do that, but what I’m getting is the whole array in one big line in the text file
func _ready():
array_of_strings = ["a,a,a,a", "b,b,b,b", "c,c,c,c"]
save(array_of_strings)
func save(array_):
var file = File.new()
file.open("res://Results//save_game.txt", File.WRITE)
for i in range(array_.size()):
file.store_line(String(array_[i])) #file.store_string(content.)
file.close()
The output now is
[a,a,a,a][b,b,b,b][c,c,c,c]
what I need
a,a,a,a
b,b,b,b
c,c,c,c
Thanks!!