0 votes

Been puzzling over this for an hour, but using store_line(some_string) or even store_string(some_string) produces a file that has no line breaks. They appear in some programs, but in notepad they do not.

More importantly I'm trying to output scripts for command line, and these won't work as .bat files. The lines will all get executed as one line.

Any suggestions on how to coax the output file into having carriage returns?

A basic code example would look like this:

var output = []

output.append("line 1")
output.append("line 2")
output.append("line 3")

var file = File.new()

if(file.open("res://script.bat", File.WRITE) == OK):
    for line in output: file.store_line(line)

Results end up like: line 1line 2line 3

asked 5 days ago in Engine by avencherus (4,196 points)

Have you tried store_string()?
Alternatively, you could try write new line directly for each line:
file.store_line('\n') # append new line, not sure whether that would work...

store_line(line + "\r") seems to work.

1 Answer

0 votes
Best answer

Appending an "\r" is the solution.

answered 5 days ago by avencherus (4,196 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 How to use this Q&A? before posting your first questions.