- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.lua
More file actions
Latest commit
53 lines (44 loc) · 1.16 KB
/
Copy pathtimer.lua
File metadata and controls
53 lines (44 loc) · 1.16 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- timer.lua : Track that time!
locallog=require('log')
localtimer= {
total=0,
trackers= {},
}
functiontimer.track(tracker)
ifnottrackerthen
error('cannot setup tracker for nil')
return
end
timer.trackers[tracker] = {
_time=0,
_isTracking=false
}
log.debug('timer.track: ' ..tracker)
end
functiontimer.reset(tracker)
timer.trackers[tracker]._time=0
log.debug('timer.reset: ' ..tracker)
end
functiontimer.start(tracker)
timer.trackers[tracker]._isTracking=true
log.debug('timer.start: ' ..tracker
..' at: ' ..timer.trackers[tracker]._time)
end
functiontimer.stop(tracker)
timer.trackers[tracker]._isTracking=false
log.debug('timer.stop: ' ..tracker
..' at: ' ..timer.trackers[tracker]._time)
end
functiontimer.update(timeDelta)
timer.total=timer.total+timeDelta
fortrackerinpairs(timer.trackers) do
localt=timer.trackers[tracker]
ift._isTrackingthen
t._time=t._time+timeDelta
end
end
end
functiontimer.getTime(tracker)
returntimer.trackers[tracker]._time
end
returntimer