I am receiving errors from love2D when drag and dropping my folder containing my project onto the program. It is about file io and closing an opened file for reading. When I run my project in Visual Studio Code it runs fine, but when going the more traditional way with the love2D application directly it gives me this error: [code]Error main.lua:34: bad argument #1 to 'close' (FILE* expected, got nil)
Traceback
[C]: in function 'close'
main.lua:34: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
[/code]
In my main.lua file I have these lines of code:
Code: Select all
fileHighScore = io.open("score.txt", "r")
io.input(fileHighScore)
and then within love.load I wrote this:
Code: Select all
scoreString = io.read()
highscore = tonumber(scoreString)
io.close(fileHighScore)
I do not understand why the fileHighscore is returning nil when ran directly by love2D but not when ran through VS Code
I included my project zipped up into a .love file: