what does love.event.pump do?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
BozoDel
Party member
Posts: 164
Joined: Fri Nov 01, 2013 10:28 pm

what does love.event.pump do?

Post by BozoDel »

What does [wiki]love.event.pump[/wiki] do? My programming knowledge is rather thin, and I can't really grasp what it does. Can someone explain it to me "for dummies" style? It's for translating the wiki.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: what does love.event.pump do?

Post by bartbes »

Basically, love has a queue for events, and so does your OS. When love.event.pump is called, love asks the OS for any events that have happened since last time, and moves them to its own queue, where it can be handled by love.run, or whatever wants to. As the wiki page also notes, some OSes (mostly windows, as far as I know) use this data to determine when an application is "not responding", which just means they haven't dealt with events in a while.
User avatar
slime
Solid Snayke
Posts: 3171
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: what does love.event.pump do?

Post by slime »

Also note that the default [wiki]love.run[/wiki] calls it every frame for you.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: what does love.event.pump do?

Post by Jasoco »

It's one of those functions that the end user programmer doesn't really need to worry about because as was mentioned, it is already handled for you providing you use the built-in love.run() function. It's only accessible for people who decide to dirty their hands and code their own run() function instead. Most people won't need to know it exists or how it works.
User avatar
BozoDel
Party member
Posts: 164
Joined: Fri Nov 01, 2013 10:28 pm

Re: what does love.event.pump do?

Post by BozoDel »

Ok, lemme see if I get this straight. The OS keeps track of events, for example, keypresses. Every frame, LÖVE checks with the OS to see if there are new events since the last frame. So love.event.pump pumps those events from the OS into the LÖVE event queue. Is that correct?

@Jasoco: I know, it's unlikely that anyone will read it, but it's still part of the main documentation body, it would be weird to ignore it.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: what does love.event.pump do?

Post by bartbes »

Every frame love.run does that, but yes.
User avatar
BozoDel
Party member
Posts: 164
Joined: Fri Nov 01, 2013 10:28 pm

Re: what does love.event.pump do?

Post by BozoDel »

Got it! Thanks!
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: what does love.event.pump do?

Post by jjmafiae »

Is it possible to make a better love.run than the default one?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: what does love.event.pump do?

Post by Jasoco »

jjmafiae wrote:Is it possible to make a better love.run than the default one?
Really the most you can do is optimize it by removing some ifs and stuff you know you don't need. But not really worth it in most cases.

Maybe other people can answer better.
User avatar
slime
Solid Snayke
Posts: 3171
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: what does love.event.pump do?

Post by slime »

jjmafiae wrote:Is it possible to make a better love.run than the default one?
The default one is good for most situations, but if you have some specialized need for the game loop then you might want to customize it.

If you don't know if you should or not, then you probably don't need to.
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests