I have question about error handling.
With the function love.errorhandler(msg) we can do stuff and go back to the game if an unexpected error occurs. It’s really nice.
BUT, it works once. The second time an error occurs, love.errorhandler(msg) seems to be void and the game just end.
Here is a very simplified version of my code :
Code: Select all
BOOT = 0
function love.errorhandler(msg)
CRASH = true
love.window.setMode(640,360)
while CRASH do
love.event.pump()
for e, a, b, c in love.event.poll() do
if e == "keypressed" and a == "escape" then
CRASH = false
return love.run() -- restart mainloop beginning with love.load
end
end
love.graphics.printf("Game crashed "..tostring(BOOT).." time(s)\n\n\nPress ESC to restart", 0, 160, 640, 'center')
love.graphics.present()
love.timer.sleep(0.1)
end
end
function love.load()
BOOT = BOOT + 1
CLOCK = 0
love.window.setMode(640,360)
love.graphics.printf("Game is loading\n#"..tostring(BOOT), 0, 160, 640, 'center')
love.graphics.present()
love.timer.sleep(2)
end
function love.update(dt)
CLOCK = CLOCK + dt
if love.keyboard.isDown('space') then fakefunction() end
end
function love.draw()
love.graphics.printf("Game is running for:\n"..tostring(math.floor(CLOCK)).." sec\n\nPress SPACE to crash", 0, 160, 640,'center')
end
function love.quit()
love.graphics.printf("THE END !", 0, 160, 640, 'center')
love.timer.sleep(2)
end
- Boot #1 is launch
- Boot #2 is reboot after crash
- Boot #3 never exists
I think I misanderstood something about the way it should work and I would appreciate some help.
It may be around the return love.run() but without this line, game stops at the end of love.errorhandler . . .
I already develop the parts about save log, restart a match, live hot fix with console but i'm stuck with the possibility to use error handlder back to back.
Hope I'm clear enough and you could help me !
Syrius