Skip to content

Instantly share code, notes, and snippets.

@qoh
Created March 12, 2016 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qoh/178585f5a08eccb83053 to your computer and use it in GitHub Desktop.
Save qoh/178585f5a08eccb83053 to your computer and use it in GitHub Desktop.
local schedule = ts.func "schedule"
if _G._TIMER_COUNT == nil then _G._TIMER_COUNT = 0 end
if _G._TIMER_TABLE == nil then _G._TIMER_TABLE = {} end
function _G._TIMER_FINISH(i)
i = tonumber(i)
_G._TIMER_TABLE[i]()
_G._TIMER_TABLE[i] = nil
end
return function(t, f)
local i = _G._TIMER_COUNT
_G._TIMER_COUNT = _G._TIMER_COUNT + 1
_G._TIMER_TABLE[i] = f
return schedule(t, "0", "luaCall", "_TIMER_FINISH", i)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment