event.quit() [solved]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
drfractal
Prole
Posts: 4
Joined: Sat Jan 18, 2020 3:56 pm

event.quit() [solved]

Post by drfractal »

OK I am maybe dumb but in my code:

Code: Select all

love.update() 
       stage.update()
....  ......

function stage.update()
  if love.keyboard.isDown("z")
        
        print("goodbye")
        love.event.quit()
  end
...
why if i click z key I get the message "goodbye" BUT love not exit the game?
Is something about the right placement for calling an event like quit or what?
thank you
Last edited by drfractal on Mon Jan 27, 2020 12:43 pm, edited 1 time in total.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: event.quit()

Post by grump »

It will only not quit if you have defined love.quit and it retuns something else than false or nil. In all other cases, it should quit. Not immediately though, it will quit after the next main loop iteration.
drfractal
Prole
Posts: 4
Joined: Sat Jan 18, 2020 3:56 pm

Re: event.quit()

Post by drfractal »

i only use that quit in a menu button that i copied from someone else tutorial (in this case it works):

Code: Select all

  table.insert( buttons, newButton(
    "close game",
    function()
      love.event.quit(0)
    end  ))
is it that the overwrite you are talking about?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: event.quit()

Post by raidho36 »

No. It's something like this:

Code: Select all

function love.quit ( )
...
return true
end
It shouldn't return anything, or it may return nil or false, to actually quit. Returning anything else will cancel the quit.
drfractal
Prole
Posts: 4
Joined: Sat Jan 18, 2020 3:56 pm

Re: event.quit()

Post by drfractal »

well quit() is only in those two places in the entire project... I have to look for something else.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: event.quit()

Post by pgimeno »

There are several other things that can cause this (like calling love.event.poll yourself, or causing a hang before the next frame, or overriding love.run wrongly) but it's very hard to say if you don't show the code.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests