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 


auto attach script modify

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
!BEWARE!
!BEWARE! Deletes post on answer
Reputation: 0

Joined: 26 Jun 2013
Posts: 57
Location: !BEWARE!

PostPosted: Mon Jan 22, 2024 8:14 am    Post subject: auto attach script modify Reply with quote

This script working fine, but when restarting game it don't reattach process.
I have to do it manually.
How fix it to full auto?

Code:
PROCESS_NAME = 'Tutorial-i386.exe'
--------
-------- Auto Attach
--------
local autoAttachTimer = nil ---- variable to hold timer object
local autoAttachTimerInterval = 1000 ---- Timer intervals are in milliseconds
local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run
local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max
local function autoAttachTimer_tick(timer) ---- Timer tick call back
        ---- Destroy timer if max ticks is reached
   if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
      timer.destroy()
   end
        ---- Check if process is running
   if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
      timer.destroy() ---- Destroy timer
      openProcess(PROCESS_NAME) ---- Open the process
   end
   autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
end
autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval
autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back

_________________
!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!!BEWARE!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1476

PostPosted: Mon Jan 22, 2024 11:09 am    Post subject: Reply with quote

Disable killing it if you're still going to use it.
-- timer.destroy()

Code:
if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
     -- --> timer.destroy() ---- Destroy timer
      openProcess(PROCESS_NAME) ---- Open the process
   end
   autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
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
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1066
Location: 0x90

PostPosted: Mon Jan 22, 2024 12:56 pm    Post subject: Re: auto attach script modify Reply with quote

!BEWARE! wrote:
This script working fine, but when restarting game it don't reattach process.
I have to do it manually.
How fix it to full auto?

Code:
PROCESS_NAME = 'Tutorial-i386.exe'
--------
-------- Auto Attach
--------
local autoAttachTimer = nil ---- variable to hold timer object
local autoAttachTimerInterval = 1000 ---- Timer intervals are in milliseconds
local autoAttachTimerTicks = 0 ---- variable to count number of times the timer has run
local autoAttachTimerTickMax = 5000 ---- Set to zero to disable ticks max
local function autoAttachTimer_tick(timer) ---- Timer tick call back
        ---- Destroy timer if max ticks is reached
   if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
      timer.destroy()
   end
        ---- Check if process is running
   if getProcessIDFromProcessName(PROCESS_NAME) ~= nil then
      timer.destroy() ---- Destroy timer
      openProcess(PROCESS_NAME) ---- Open the process
   end
   autoAttachTimerTicks = autoAttachTimerTicks + 1 ---- Increase ticks
end
autoAttachTimer = createTimer(getMainForm()) ---- Create timer with the main form as it's parent
autoAttachTimer.Interval = autoAttachTimerInterval ---- Set timer interval
autoAttachTimer.OnTimer = autoAttachTimer_tick ---- Set timer tick call back


Also, if you plan to share it. Give credit to the author(s) of the code.
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