Skip to content

Commit

Permalink
Merge pull request #14 from TehZarathustra/master
Browse files Browse the repository at this point in the history
timers.lua: fix arg1 as string
  • Loading branch information
Perryvw authored Dec 28, 2024
2 parents 56dd106 + 520c9b7 commit d8c9590
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/vscripts/lib/timers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ function Timers:CreateTimer(arg1, arg2, context)
timer = {callback = arg1}
elseif type(arg1) == "table" then
timer = arg1
elseif type(arg1) == "string" then
timer = arg2
timer.name = arg1
elseif type(arg1) == "number" then
timer = {endTime = arg1, callback = arg2}
end
Expand Down Expand Up @@ -268,14 +271,17 @@ end

function Timers:RemoveTimer(name)
local timerHeap = self.gameTimeHeap
if name.useGameTime ~= nil and name.useGameTime == false then
local runningTimer = Timers.runningTimer
local hasMatch = runningTimer == name or runningTimer.name == name

if not hasMatch then return end

if runningTimer.useGameTime ~= nil and runningTimer.useGameTime == false then
timerHeap = self.realTimeHeap
end

timerHeap:Remove(name)
if Timers.runningTimer == name then
Timers.removeSelf = true
end
timerHeap:Remove(runningTimer)
Timers.removeSelf = true
end

function Timers:InitializeTimers()
Expand All @@ -285,4 +291,4 @@ end

if not Timers.started then Timers:start() end

GameRules.Timers = Timers
GameRules.Timers = Timers

0 comments on commit d8c9590

Please sign in to comment.