Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timers.lua: fix arg1 as string #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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