-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathlove.event.js
35 lines (29 loc) · 852 Bytes
/
love.event.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var gEvents = [];
function Love_Event_PollIterator()
{
var ev = gEvents[0];
gEvents.shift();
return ev;
}
$(window).focus(function()
{
push_event("focus", true);
});
$(window).blur(function()
{
push_event("focus", false);
});
window.onbeforeunload = function() {
call_lua_function_safe("love.quit", []);
};
/// init lua api
function Love_Event_CreateTable (G) {
var t = lua_newtable();
var pre = "love.event.";
G.str['love'].str['event'] = t;
t.str['clear'] = function () { gEvents = []; }
t.str['poll'] = function () { return [Love_Event_PollIterator]; }
t.str['pump'] = function () { } // If you ever need other events coming in
t.str['push'] = function (e, a, b, c, d) { gEvents[gEvents.length] = [e, a, b, c, d]; }
t.str['wait'] = function () { } // Makes no sense, there is nothing else that can push stuff.. yet
}