Page 1 of 1

love.event.poll() and quit event

Posted: Fri Aug 21, 2020 1:06 am
by Yjuq
Hi there o/

I'm currently working on a new UI library for love2d. I'm implementing a custom event dispatcher for my new library and notice something in the love.run default implementation. I'm using the version 11.3

The thing that bothers me is the following code line:

Code: Select all

if name == "quit" then
	if not love.quit or not love.quit() then
		return a or 0
	end
end
It's the part with the "return a or 0". I don't get why "a" is here in the first place. The love.quit function doesn't take any inputs and I thought the parameter a-f in the love.event.poll function fetches these values for using them as parameter for the event handler. So, why is there "a" in the return value in the first place? What is the meaning for it?

I'm thinking of adding another parameter for all love event callbacks in order to indicate if my library already used this event for one of the UI elements. I just add a system to add event dispatcher for UI elements and give them own callback functions. This will prevent accidentally breaking the library apart while still using the love event callbacks for normal stuff. I already have a workaround specifically for the love.quit callback. But I'm still wondering why this "a" is here and what purpose it have in combination with the quit event.

Code: Select all

if love.event then
	love.event.pump()
			
	for n, a, b, c, d, e, f in love.event.poll() do
		local g = yui.event.dispatcher(n, a, b, c, d, e, f)

		if n == "quit" then
			if not love.quit or not love.quit(g) then
				return a or 0
			end
		end
		
		a = a or g
		b = b or g
		c = c or g
		d = d or g
		e = e or g
		f = f or g
					
		love.handlers[n](a, b, c, d, e, f, g)
	end
end

Re: love.event.poll() and quit event

Posted: Fri Aug 21, 2020 1:28 am
by Xii
The value of a appears to be nil in this event. No idea what it's for...

Re: love.event.poll() and quit event

Posted: Fri Aug 21, 2020 1:34 am
by Yjuq
Xii wrote: Fri Aug 21, 2020 1:28 am The value of a appears to be nil in this event. No idea what it's for...
Yes, this is what I observed on my windows machine as well. Maybe some cross platform stuff? Anyways, if this doesn't have a real purpose anymore it should be removed from the default game loop.

Re: love.event.poll() and quit event

Posted: Fri Aug 21, 2020 1:48 am
by Yjuq
Oh, I found the answer for my question. Actually, this is the exitstatus that you can use in the love.event.quit function.