Löve game does not work after compile

5

Recently, I created a game based on löve , which once finished and tested, I decided to try to compile.

I followed the tutorial of the löve wiki build, using:

copy /b love.exe+GhostShield.love GhostShield.exe

It compiled normally, but when I ran the compiled game, I had an unexpected problem:

  

Error

     

controllers / menuController.lua: 8: attempt to compare number with nil

     

Traceback

     

controllers / menuController.lua: 8: in function 'menuDisplay'
  main.lua: 180: in function 'draw'
  [C]: in function 'xpcall'

I searched for line 8 that failed:

menu.menuPresentation()
menu.menuButton(200,250,90,30,"Jogar")
menu.menuButton(500,250,90,30,"Como jogar")
if  ranking.readRanking() >= 200 then --Problema aqui
    menu.menuButton(350,350,90,30,"Extra")
end
menu.menuButton(350,500,90,30,"Sair")

And the function it retrieves from the ranking value:

ranking.readRanking = function ()
    rankingReader = love.filesystem.read(rankingLocal, love.filesystem.getSize(rankingLocal))
    return tonumber(rankingReader)  
end

The most curious thing is that I can drag the folder to the löve icon or compress it into .zip and change the extension to .love, and it works perfectly, error only occurs when I compile into executable.

Annotation: There is a function to change the mouse shape at the beginning of the code, and the mouse changes correctly even after the error, so I believe it was compiled correctly.

When the program starts, I check it:

if not love.filesystem.exists(rankingLocal) then
    ranking.createRanking()
end

Theoretically, by doing this, I guarantee the file exists, even if the default folder changes:

ranking.createRanking = function ()
    rankCreate = love.filesystem.newFile(rankingLocal)
    rankCreate:open("w")
    rankCreate:write("0000")
    rankCreate:close()
end

One detail I found interesting is that if I run my game as a "standalone program ", it fails, but if you drag it to run on the basis of löve2d / a>, dragging it to it, works without any problem, both in the version installed on the system and in the zipped version ...

    
asked by anonymous 19.03.2014 / 04:05

1 answer

2

It seems that löve only writes to the %appdata% directory (in the case of Windows), as it is in the wiki , where you can create a folder for your project.

However, after compiling, löve apparently does not accept the default folder %appdata%/LOVE/ anymore, requiring you to create a folder for your project.

To solve this, in love.load() add the following call:

 love.filesystem.setIdentity("Ghost Shield")

This function will define that the files that your project will create will be written in %appdata%/Ghost Shield/ .

    
23.03.2014 / 03:19