Your while loop is pretty cluttered. This could cause it to run slow if another program is consuming large amounts of the CPU.
Code: Select all
if (usa_autoparty and autoparty_ativo) then
--para o timer, para nao executar esta rotina antes do tempo
unregisterTimer("ativaAutoparty");
autoParty();
autoparty_ativo = false;
registerTimer("ativaAutoparty", minutesToTimer(TEMPO_AUTOPARTY), ativaAutoparty);
end
This kind of code should probably go before the while loop, as it only needs to be executed once. Calling registerTimer() will make the function be automatically called every once in awhile, so there is no need to constantly check if it's ready or not. You also do not need to unregister the timer and reregister it, this is done automatically, and calling these manually just adds extra work to be done. Now, instead of flipping things around and making it more complicated than it needs to be, we can call autoParty() directly, instead of ativaAutoparty().
Code: Select all
-- put this just before your while loop
if( usa_autoparty and autoparty_ativo ) then
registerTimer("ativaAutoparty", minutesToTimer(TEMPO_AUTOPARTY), autoParty);
end
You could basically clear out your whole while loop using this approach. One other thing I noticed is that you're not making a call to coroutine.yield() directly inside of your while loop. This could potentially make things appear slower, as the timers may not be getting the time they need to processes. You do, however, use myrest() to make a call to yrest() and coroutine.yield() inside of your subfunctions.
If you're using MicroMacro 0.98, you do not need to manually call coroutine.yield() along-side of yrest() to make sure it calls it at least once. This is done automatically now, so you can just use yrest() directly. Now your while loop can look like this:
So now your timers will be getting the time they need, and your while loop will waste less CPU power. It's hard to say if this will fix your problem or not without trying.