I’m using pairs()…
Here’s some code:
Relavent timer code:
[lua]
– The iteration function
for k, v in pairs(timerStack) do
if timerStack[k] and timerStack[k].running then – Not paused
--print("iterating "…k)
if time>=(timerStack[k].time * timerStack[k].iterCount)+timerStack[k].timeOffset then
timerStack[k].iterCount=timerStack[k].iterCount+1 – Number of iterations
if timerStack[k].iterations>1 then
timerStack[k].iterations=timerStack[k].iterations-1
timerStack[k].func()
elseif timerStack[k].iterations==1 then – Finished iterations
timerStack[k].func()
timerStack[k].onComplete()
timerStack[k] = nil
end
– The stop function
– After various nil checks…
timerStack[handle._timerStack_key] = nil – Delete a timer
handle = nil
[/lua]
And here’s the relavent turret code:
[lua]
if turret.stopAfterNextFire then – Stop for updates so we can reset the turret’s fire speed
spark.stop(turret.fireTimer)
turret.fireTimer = spark.timer(turret.speed, turret.fire, 0) – turret.fire is the function that this code is found inside
turret.stopAfterNextFire = false
end
[/lua]
Any ideas?