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 


Timer Loop Duration

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

Joined: 17 Sep 2023
Posts: 211

PostPosted: Tue May 14, 2024 6:06 am    Post subject: Timer Loop Duration Reply with quote

I know this has been asked multiple times before. But I couldn't find it.
I am modifying the GUI and moving the Hex checkbox somewhere else however at that location other things move too so I have to adjust accordingly.

The other supposed solution is this but it only affects what I declared and overlooks the original instructions at this event.

Code:
getMainForm().VarType.OnMouseMove = function()
  ...
end



This code will result in stack-over-flow
Code:
getMainForm().VarType.OnMouseMove = function()
  local duration = 10 --(1 * 60)
   local startTime = os.clock()
   fixHexBoxPostimer = fixHexBoxPostimer or createTimer()
   fixHexBoxPostimer.Interval = 100
   fixHexBoxPostimer.OnTimer = function(t)
      if os.clock() - startTime < duration then
         MainForm.cbHexadecimal.Top = MainForm.cbNot.Top
         --print("Code on")
      else
         fixHexBoxPostimer.Destroy()
         --print("Code off")
      end
   end
end


So, obviously, I am looking for a way to check if the duration is up to break the loop.

Sorry that I am bothering you with things but I am trying to learn Lua by messing up things

Thank you for understanding.

I don't have any idea how the createTimer() works under the hood if you have an idea I'd be pleased. I know I could look it up in the source code. Well, I can't understand Pascal
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1418

PostPosted: Tue May 14, 2024 8:56 am    Post subject: Reply with quote

With "MouseMove" the function will be triggered repeatedly as the mouse arrow moves over the relevant surface.

Use "MouseEnter" or something else instead.

Code:
local duration = 0

if fixHexBoxPostimer then fixHexBoxPostimer.Destroy() end
   fixHexBoxPostimer = createTimer(MainForm,false)
   fixHexBoxPostimer.Interval = 100
   fixHexBoxPostimer.OnTimer = function()
     duration = tonumber(duration) + 1
      if duration==10 then
         MainForm.cbHexadecimal.Top = MainForm.cbNot.Top
         --print("Code on")
         fixHexBoxPostimer.Enabled=false
      end
   end

MainForm.VarType.OnMouseEnter = function()
  duration = 0 --(1 * 60)
  fixHexBoxPostimer.Enabled=true
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Game Hacking Dojo
Expert Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 211

PostPosted: Tue May 14, 2024 9:13 am    Post subject: Reply with quote

Actually, this code did everything I needed thank you )

Code:
MainForm.Panel5.OnMouseEnter = function()
   MainForm.cbHexadecimal.Top = MainForm.cbNot.Top
end
Back to top
View user's profile Send private message Visit poster's website
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