#Godot refuses to read txt files despite perfectly reading them previously?

35 messages · Page 1 of 1 (latest)

steep lantern
#
  1. This part here basically grabs the BootConfig.txt - the path to this file is correct.
var BootConfig_res="res://configs/BootConfig.txt"
var BootConfig_file=FileAccess.open(BootConfig_res, FileAccess.READ)
var BootConfig=BootConfig_file.get_as_text()
var BootConfigCommandsRaw=BootConfig.split("\r\n",false)
  1. Then this code here is used to format & execute
func BootConfigSetupAndInit(): #Cleans & Formats the BootConfig & executes it
    var CleanList=[]
    var Removed=0
    BootConfig_file.close()
    for i in range(len(BootConfigCommandsRaw)): #Remove All Comments
        BootConfigCommandsRaw[i]=BootConfigCommandsRaw[i].to_upper()
        if BootConfigCommandsRaw[i][0]=="#":
            CleanList.append(i)
    for i in range(len(CleanList)):
        BootConfigCommandsRaw.remove_at(CleanList[i]+Removed)
        Removed-=1
    for i in range(len(BootConfigCommandsRaw)):
        match BootConfigCommandsRaw[i]:
            "DEBUG_TRUE":
                DebugTest=true
            "DEBUG_FALSE":
                DebugTest=false
            "SKIP_INTRO_TRUE":
                SkipIntro=true
            "SKIP_INTRO_FALSE":
                SkipIntro=false
            "TYPEOUT_ADD_TIMERS":
                AddTimers=true
  1. The BootConfigSetupAndInit() function is executed at _ready()

It used to previously work perfectly as I would open the txt files outside of Godot, edit them & later on it would work. However I once made the mistake? of editing the said txt file within Godot and since then it straight up does not read it nor do I get an error?

#

I also have 2 other functions that work in a similar fashion, they used to work perfectly and now Godot just reads nothing from them?

shut swallow
#

Did you change godot versions at any point?

steep lantern
#

Solid on 4.1.1

#

Current game started on 4.1.1 & still is on 4.1.1 so that can't be it

#

Now, while testing, removing the files causes the game to crash, as expected of course

#

adding them back again doesn't seem to fix the issue either

#

it seems to? omfg wait

#

🤔 wha

#

I think I fixed it?

#

\r seems to be the issue?

#

but

shut swallow
#

Maybe it was a change to the files?

#

I know some files are saved with a carriage return and a newline and some only with a newline

steep lantern
#

var BootConfigCommandsRaw=BootConfig.split("\r\n",false) man wtf

steep lantern
#

Btw just to let everyone know, the functions only read, they don't write

#

This is it's formart in the txt file

#

var BootConfigCommandsRaw=BootConfig.split("\n",false)

["SKIP_INTRO_TRUE", "DEBUG_FALSE"]

Can this piece of shit decide

#

if it wants to work or not

shut swallow
#

You're splitting on "\r\n", but if the file only has "\n", then the split won't do anything.

steep lantern
#

I see

#

Now it works

#

wait, what does \r do even?

shut swallow
#

I believe you can control how line breaks are written with most text editors, so I guess you can keep that in mind if this happens again

steep lantern
#

well it's more like a config that 2 co-workers will use & it formats itself, removes newlines, comments, ect

#

so the point is that it does these things itself

#

during compilation

#

I have no idea how that

#

\r made it's way in