mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add set_interval 'repetions' argument
This commit is contained in:
parent
ddb04418ba
commit
f37bbc64f4
1 changed files with 10 additions and 1 deletions
|
|
@ -1,11 +1,12 @@
|
|||
local Schedule = {
|
||||
__index = {
|
||||
set_interval = function(self, ms, callback)
|
||||
set_interval = function(self, ms, callback, repetions)
|
||||
local id = self._next_interval
|
||||
self._intervals[id] = {
|
||||
last_called = 0.0,
|
||||
delay = ms / 1000.0,
|
||||
callback = callback,
|
||||
repetions = repetions,
|
||||
}
|
||||
self._next_interval = id + 1
|
||||
return id
|
||||
|
|
@ -18,6 +19,14 @@ local Schedule = {
|
|||
debug.error(s..'\n'..debug.traceback())
|
||||
end)
|
||||
interval.last_called = timer
|
||||
local repetions = interval.repetions
|
||||
if repetions then
|
||||
if repetions <= 1 then
|
||||
self:remove_interval(id)
|
||||
else
|
||||
interval.repetions = repetions - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self._timer = timer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue