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 


[solved]

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

Joined: 21 Feb 2016
Posts: 115

PostPosted: Sun Aug 21, 2016 10:47 pm    Post subject: [solved] Reply with quote

[solved thanks to Zanzer]

Last edited by usernotfound on Sat Aug 27, 2016 7:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Aug 21, 2016 11:01 pm    Post subject: Reply with quote

Code:
if mytimer1 == nil then
  mytimer1 = createTimer(nil, false)
end
mytimer1.Interval = 1000
mytimer1_index = 0
mytimer1.OnTimer = function(timer)
  mytimer1_index = mytimer1_index + 1
  if mytimer1_index == 1 then
    doKeyPress(VK_ESCAPE)
  elseif mytimer1_index == 2 then
    doKeyPress(VK_RETURN)
  elseif mytimer1_index == 3 then
    doKeyPress(VK_UP)
  elseif mytimer1_index >= 4
    doKeyPress(VK_RETURN)
    mytimer1_index = 0
  end
end
mytimer1.Enabled = true


Code:
if mytimer2 == nil then
  mytimer2 = createTimer(nil, false)
end
mytimer2.Interval = 300000
mytimer2.OnTimer = function(timer)
  mytimer1.Enabled = false
end
mytimer2.Enabled = true
Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Mon Aug 22, 2016 10:08 am    Post subject: Reply with quote

Zanzer wrote:
Code:
if mytimer1 == nil then
  mytimer1 = createTimer(nil, false)
end
mytimer1.Interval = 1000
mytimer1_index = 0
mytimer1.OnTimer = function(timer)
  mytimer1_index = mytimer1_index + 1
  if mytimer1_index == 1 then
    doKeyPress(VK_ESCAPE)
  elseif mytimer1_index == 2 then
    doKeyPress(VK_RETURN)
  elseif mytimer1_index == 3 then
    doKeyPress(VK_UP)
  elseif mytimer1_index >= 4
    doKeyPress(VK_RETURN)
    mytimer1_index = 0
  end
end
mytimer1.Enabled = true


Code:
if mytimer2 == nil then
  mytimer2 = createTimer(nil, false)
end
mytimer2.Interval = 300000
mytimer2.OnTimer = function(timer)
  mytimer1.Enabled = false
end
mytimer2.Enabled = true


Hi Zanzer, thank you kindly for the example but I'm not quite sure how to set it up correctly. The first part does what I'm looking for with the Keypress loop, but how do I disable it with my togglebox? And the second part for the interval, I'm not quite sure how to implement that with my editbox.

Really sorry for my incompetence !
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Aug 22, 2016 6:09 pm    Post subject: Reply with quote

Have the two scripts just execute when the table loads, but remove these two lines from them:
Code:
mytimer1.Enabled = true
mytimer2.Enabled = true

When the user clicks your button, simply execute:
Code:
mytimer2.Interval = tonumber(UDF1.CEEdit1.Text)
mytimer1_index = 0
mytimer2.Enabled = true
mytimer1.Enabled = true

If you want to let the user disable the timer before it runs out, simply execute:
Code:
mytimer2.Enabled = false
mytimer1.Enabled = false
Back to top
View user's profile Send private message
usernotfound
Expert Cheater
Reputation: 0

Joined: 21 Feb 2016
Posts: 115

PostPosted: Mon Aug 22, 2016 7:54 pm    Post subject: Reply with quote

Zanzer wrote:
Have the two scripts just execute when the table loads, but remove these two lines from them:
Code:
mytimer1.Enabled = true
mytimer2.Enabled = true

When the user clicks your button, simply execute:
Code:
mytimer2.Interval = tonumber(UDF1.CEEdit1.Text)
mytimer1_index = 0
mytimer2.Enabled = true
mytimer1.Enabled = true

If you want to let the user disable the timer before it runs out, simply execute:
Code:
mytimer2.Enabled = false
mytimer1.Enabled = false


Ahh I got it now, thank you so much for the clear explanation. This will be fun to play around with Smile
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