Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Do I need to destroy timers, or is disabling them fine?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Valatros
Cheater
Reputation: 1

Joined: 21 Nov 2015
Posts: 36

PostPosted: Sat Feb 11, 2017 11:52 pm    Post subject: Do I need to destroy timers, or is disabling them fine? Reply with quote

Basically the subject; I have some auto assembler entries that disable the timer on Disable and reenable it on Enable. That enough, or do I have a timer (possibly several) ticking away in the background using up memory for no reason while timer.Enabled=false?
Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Sun Feb 12, 2017 12:51 am    Post subject: Reply with quote

If you're creating them in the enable section then yes you'd need to destroy it otherwise a new one will be created each time the script is enabled
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Sun Feb 12, 2017 4:13 am    Post subject: This post has 1 review(s) Reply with quote

Code:

[Enable]
if timer ~= nil
then
timer.Enabled = true
else
timer = createTimer()
timer.Interval = 1000
timer.Whatver = bla
end

[Disable]
timer.Enabled = false



TOOO much code just use Destroy()

_________________
Back to top
View user's profile Send private message
Valatros
Cheater
Reputation: 1

Joined: 21 Nov 2015
Posts: 36

PostPosted: Sun Feb 12, 2017 12:01 pm    Post subject: Reply with quote

Excellent, thank you; I actually just had the timer being created on running the script the first time. I like akumakuja28's solution better though; that way if I'm not using the associated cheats it's not there in the background pointlessly.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites