I am trying to write to a file inside my game folder but instead it is writing to the
%AppData%/LOVE/GameFolder/save.txt
thanks in advance!
Writing to files inside game folder
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Le_juiceBOX
- Citizen
- Posts: 71
- Joined: Sat Mar 26, 2016 3:07 pm
Re: Writing to files inside game folder
Yes that's how it works, love can only write in the save directory.
Re: Writing to files inside game folder
here's the sneaky solution: even though love.filesystem only wants to write to the designed save directory, the default lua io functions behave the same way they do in normal lua. this means for example that io.open("file", "w"):write("out\n"):close() will write the the current working directory, and not the save dir. You probably shouldn't ship a game with this but I find it handy for things like in-engine level editors
Re: Writing to files inside game folder
You shouldn't do it mainly because doing so requires elevated privileges, which you wouldn't have on any sane system. That's not to mention, default CWD for a video game is normally some unrelated location, so you'd also be shitting up filesystem for no good reason. Finally, that eliminates the issue of people hard-coding file paths which renders software inoperable on many systems, which is a lot more common error than you would imagine.
-
- Prole
- Posts: 3
- Joined: Fri Oct 28, 2016 8:12 pm
Re: Writing to files inside game folder
I think you should look towards this if you want to write files: https://love2d.org/wiki/love.filesystem
Who is online
Users browsing this forum: Bing [Bot], pgimeno and 14 guests