love.event.poll() and quit event

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
Yjuq
Prole
Posts: 5
Joined: Sun May 19, 2019 2:09 am

love.event.poll() and quit event

Post 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
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

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

Post by Xii »

The value of a appears to be nil in this event. No idea what it's for...
Yjuq
Prole
Posts: 5
Joined: Sun May 19, 2019 2:09 am

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

Post 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.
Yjuq
Prole
Posts: 5
Joined: Sun May 19, 2019 2:09 am

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

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests