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 


How do timers work?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Woza
Newbie cheater
Reputation: 0

Joined: 08 Sep 2012
Posts: 12

PostPosted: Sun Sep 08, 2013 5:13 am    Post subject: How do timers work? Reply with quote

Code:
form = createFormFromFile("Form.FRM")
form_show(form)
t = createTimer(nil) -- Why pass nil as a parameter, is it important?
timer_onTimer(t, printasd)
timer_setInterval(t,3000)
timer_setEnabled(t, false)

function toggle(sender)
         if (control_getCaption() == 1) then
            timer_setEnabled(t, true)
         else
            timer_setEnabled(t, false)
         end
end

function printasd()
         print("asd")
end


Changing a checkbox that calls toggle() crashes CE and prints "Error: Invalid class object". Also what does the argument to createTimer() mean?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25288
Location: The netherlands

PostPosted: Sun Sep 08, 2013 5:27 am    Post subject: Reply with quote

control_getCaption() needs as parameter an object that inherits from the Control Class and it returns a string

If you are using 6.3 you can use this code:
Code:

function toggle(sender)
         t.Enabled=sender.Checked
end   


if you're using 6.2 or earlier then use this:
Code:

  if (checkbox_getState(sender)==cbChecked) then
    timer_setEnabled(t, true)
  else
    timer_setEnabled(t, false)
  end


the parameter passed to createTimer is the owner. If the owner gets destroyed, the timer gets automatically destroyed as well

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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