1
0
Fork 0
mirror of https://github.com/ctruLua/uCompat.git synced 2025-10-28 00:59:31 +00:00

Added Rumble and Timer libs, implemented the offset system for drawing.

This commit is contained in:
Firew0lf 2015-10-04 15:25:34 +02:00
parent 703418a419
commit 5eeb78d9ec
3 changed files with 88 additions and 16 deletions

53
Timer.lua Normal file
View file

@ -0,0 +1,53 @@
--[[
Timers related µLua compatibility layer/lib for ctrµLua
The code comes directly from µLua, befores timers were coded in C, but with
the name patch.
]]
-- Local
local ctr = require("ctr")
-- Module
Timer = {
new = function()
local t = ctr.time()
local isStarted = false
local tick = 0
local time = function(self)
if isStarted then return ctr.time() - t
else return tick end
end
local stop = function(self)
if isStarted then
isStarted = false
tick = ctr.time() - t
end
end
local start = function(self)
if not isStarted then
isStarted = true
t = ctr.time() - tick
end
end
local reset = function(self)
t = ctr.time()
isStarted = false
tick = 0
end
return{
time = time,
getTime = time, -- name patch
stop = stop,
start = start,
reset = reset
}
end
}