Page 1 of 1

Q: How to unregister all timers?

Posted: Mon Jul 30, 2012 6:43 am
by kkulesza
Is there a way to unregister all timers, even if i don't know their names and how many was registered?

Re: Q: How to unregister all timers?

Posted: Mon Jul 30, 2012 8:51 am
by lisa
The timers are stored in a table but the table is local to lib/lib.lua, I wouldn't suguest making it global.

Easiest way I see of doing it would be to add your own function to lib.lua doing what ever it is you want to do.
it could be as simple as

Code: Select all

function timerlist()
	return timerList
end
then call it somewhere in a userfunction I guess

Code: Select all

local tlist = {}
tlist = timerlist()
table would look like this

Code: Select all

Command> local tlist = {} tlist = timerlist() table.print(tlist)
table: 01384540
GMdetection:    table: 04FA6748
        time:   5000
        func:   function: 0144B820
        args:   table: 04FA6770
timedSetWindowName:     table: 0404B870
        time:   1000
        func:   function: 013EFD20
        args:   table: 0404B9D8
                1:      Charname
The other way would be to find what timers are called and as they are being called to add the names to a global table which you can then later do a unregistertimer on them all if needed.

Default bot uses just 2 timers

Code: Select all

registerTimer("timedSetWindowName", secondsToTimer(1), timedSetWindowName, load_profile_name);
which is for updating the things ont he window, up top.

Code: Select all

registerTimer("timedAttack", secondsToTimer(2), timedAttack);
which is also unregistered, so this wouldn't be a latent timer.

So any other timers would have been added by non default code.
flying//wallclimbing//gmdetect//mountspeed

Re: Q: How to unregister all timers?

Posted: Mon Jul 30, 2012 9:45 am
by kkulesza
Thx for answer.
I've forgot about other timers that i didn't register in my scripts.
It would be better to leave them alone.
I think i'll make make own function that will register timers and add their names to global list.