Skip to content

Commit

Permalink
added event passing to the lua script
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasalehlia committed May 23, 2013
1 parent fcb99c6 commit 23ecbac
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions demo/event.lua
@@ -0,0 +1,24 @@
-- vim: set noexpandtab:

module('event', package.seeall)

listeners = {}

function on(t, cb)
if listeners[t] == nil then
listeners[t] = {}
end
table.insert(listeners[t], cb)
end

function throw(t, data)
if listeners[t] ~= nil then
for i,v in pairs(listeners[t]) do
if v(data) then
table.remove(listeners[t], i)
end
end
end
end

GAME:setEventCallback(throw)

0 comments on commit 23ecbac

Please sign in to comment.