Setup a Lua auto attach script

From Cheat Engine

Jump to: navigation, search


[edit] How to setup a Lua auto attach script

On the Cheat Engine main form press Ctrl+Alt+L to open the cheat table Lua script form.

Now let's add the Lua script to auto attach to the process.

getAutoAttachList().add("Tutorial-i386.exe")

yep, that's probably all you need, it's what Cheat Engine generates for the trainers it makes. However, if you need more control for some reason, you can do it yourself with a timer and openProcess


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

Set the process name to the process you are attaching to, use the full process name from the process list.

Launch the process then click execute script in the cheat table Lua script form.


You should see the process name at the top of the Cheat Engine form.


Now when ever the cheat table is opened Cheat Engine will attempt to run the cheat table Lua script which will start the auto attach timer. By default Cheat Engine will ask to run the cheat table Lua script.

Note: You can change what Cheat Engine does with the cheat table Lua script in the Cheat Engine general settings.


[edit] See also

[edit] Syntax Highlighter

Personal tools
Toolbox