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 to loop this code?

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

Joined: 11 Mar 2016
Posts: 231

PostPosted: Tue Oct 25, 2016 1:54 pm    Post subject: how to loop this code? Reply with quote

Code:
if myhotkey then
  myhotkey.Destroy()
  myhotkey = nil
end
myhotkey = createHotkey(function()
  mouse_event(MOUSEEVENTF_RIGHTDOWN)
  mouse_event(MOUSEEVENTF_RIGHTUP)
end, VK_CONTROL)


*I am beginner in LUA I want to press CONTROL once and the script run like c.licker continuously press x key the script disabled .
* Is that possible to speed up mouse clicks ?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Oct 25, 2016 4:34 pm    Post subject: Reply with quote

If you only want it to execute once, what exactly are you trying to speed up?
Code:
if myhotkey then
  myhotkey.Destroy()
  myhotkey = nil
end
myhotkey = createHotkey(function()
  local time = os.time()
  if last_execute ~= time then
    mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP)
    last_execute = time
  end
end, VK_CONTROL)
Back to top
View user's profile Send private message
Twistedfate
Expert Cheater
Reputation: 1

Joined: 11 Mar 2016
Posts: 231

PostPosted: Tue Oct 25, 2016 5:23 pm    Post subject: Reply with quote

Quote:
Zanzer

I dont want to execute clicks one time ^^
I want to press CONTROL one time and right clicks run infinity
when I press CONTROL again clicks stop .


I want to speed up clicks like click every one ml second (ms)
and thank you
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue Oct 25, 2016 5:28 pm    Post subject: Reply with quote

Code:

if myhotkey then
  myhotkey.Destroy()
  myhotkey = nil
end

function killmytimer()
  if mytimer then
    mytimer.Destroy()
    mytimer = nil
  end
end

myhotkey = createHotkey(function()
  if mytimer then
    killmytimer()
  else
    mytimer=createTimer()
    mytimer.interval=1
    mytimer.OnTimer=function()
      --mouse_event(MOUSEEVENTF_RIGHTDOWN)
      --mouse_event(MOUSEEVENTF_RIGHTUP)
      print("bla")
    end
  end

end, VK_CONTROL)

_________________
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
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Oct 25, 2016 5:31 pm    Post subject: Reply with quote

Code:
if mytimer == nil then
  mytimer = createTimer(nil, false)
end
mytimer.OnTimer = function(timer)
  mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP)
end
mytimer.Interval = 1

if myhotkey then
  myhotkey.Destroy()
end
myhotkey = createHotkey(function()
  mytimer.Enabled = not mytimer.Enabled
end, VK_CONTROL)
Back to top
View user's profile Send private message
Twistedfate
Expert Cheater
Reputation: 1

Joined: 11 Mar 2016
Posts: 231

PostPosted: Tue Oct 25, 2016 5:33 pm    Post subject: Reply with quote

Wow thanks DB and zanzer work like Charm ^_*
mytimer.interval=1
I didnot think in this function ty ty ty
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