Difference between revisions of "Lua"

From Cheat Engine
Jump to navigation Jump to search
m (DBK)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
Cheat Engine comes with an extensive set of Lua functions you can use inside cheattables, trainers and standalone scripts.
+
Cheat Engine comes with an extensive set of Lua functions you can use inside cheat tables, trainers and standalone scripts.
  
  
Line 10: Line 10:
 
These functions help manage the cheat table.
 
These functions help manage the cheat table.
  
* [[getAddressList]]: Returns the cheat table addresslist object
+
* [[getAddressList]]: Returns the cheat table [[Addresslist]] object
 
* [[findTableFile]]: Returns a [[TableFile]] stored in the cheat table
 
* [[findTableFile]]: Returns a [[TableFile]] stored in the cheat table
  
Line 18: Line 18:
 
These functions control Cheat Engine's scanning.
 
These functions control Cheat Engine's scanning.
  
* [[AOBScan]]: Scans the currently opened process and returns a StringList object containing all the results
+
* [[AOBScan]]: Scans the currently opened process and returns a [[StringList]] object containing all the results
* [[getCurrentMemscan]]: Returns the currently active scan session as a MemScan object
+
* [[getCurrentMemscan]]: Returns the currently active scan session as a [[MemScan]] object
  
  
Line 29: Line 29:
 
* [[getOpenedProcessID]]: Returns the currently opened process
 
* [[getOpenedProcessID]]: Returns the currently opened process
 
* [[getProcessIDFromProcessName]]: Returns a processid
 
* [[getProcessIDFromProcessName]]: Returns a processid
 +
* [[openFileAsProcess]]: Causes cheat engine to open the file with memory access as if it's a process
 +
* [[saveOpenedFile]]: Saves the changes of the opened file
 +
* [[setPointerSize]]: Sets the size cheat engine will deal with pointers in bytes. (Some 64-bit processes can only use 32-bit addresses)
 +
* [[setAssemblerMode]]: Sets the assembler's bit size mode (0=32-bit, 1=64-bit)
 +
* [[getProcesslist]]: Returns a processlist of the system
 +
* [[getWindowlist]]: Returns the top-window list of the system
 
* [[pause]]: Pauses the current opened process
 
* [[pause]]: Pauses the current opened process
 
* [[unpause]]: Resumes the current opened process
 
* [[unpause]]: Resumes the current opened process
 
* [[targetIs64Bit]]: Returns true if the target process is 64-bit, false if 32-bit
 
* [[targetIs64Bit]]: Returns true if the target process is 64-bit, false if 32-bit
* [[speedhack_setSpeed]]: Enables the speedhack if it was not active yet and sets the given speed
+
* [[enumModules]]: Returns a table containing information about each module in the current process, or the specified process ID
 +
* [[getHandleList]]: Returns a table with all the handles in the system
 +
* [[closeRemoteHandle]]: Closes the handle of a process
 +
* [[getForegroundProcess]]: Returns the process ID of the process that is currently on top
 +
 
 +
 
 +
=== Threads ===
 +
 
 +
* [[getCPUCount]]: Returns the number of CPU's
 +
* [[getThreadlist]]: Fills a List object with the threadlist of the currently opened process
 +
* [[inMainThread]]: Returns true if the current code is running inside the main thread (6.4+)
 +
* [[synchronize]]: Calls the given function from the main thread. Returns the return value of the given function
 +
* [[queue]]: Calls the given function from the main thread. Does not wait for the result
 +
* [[checkSynchronize]]: Call this from an infinite loop in the main thread when using threading and synchronize calls
  
  
Line 40: Line 59:
  
 
* [[getAddress]]: Returns the address of a symbol. Can be a modulename or an export
 
* [[getAddress]]: Returns the address of a symbol. Can be a modulename or an export
 +
* [[getAddressSafe]]: Returns the address of a symbol, or nil if not found. Similar to getAddress when errorOnLookup is false, but returns nil instead
 
* [[getNameFromAddress]]: Returns the given address in string form, returning the symbol representation if possible
 
* [[getNameFromAddress]]: Returns the given address in string form, returning the symbol representation if possible
 
* [[registerSymbol]]: Assign the specified symbolname to an address
 
* [[registerSymbol]]: Assign the specified symbolname to an address
 
* [[unregisterSymbol]]: Remove the name from the address
 
* [[unregisterSymbol]]: Remove the name from the address
 +
* [[getSymbolInfo]]: Returns a table as defined by the [[SymbolList]] class object (module name, search key, address, size)
 
* [[reinitializeSymbolhandler]]: Reinitializes the symbolhandler. E.g when new modules have been loaded
 
* [[reinitializeSymbolhandler]]: Reinitializes the symbolhandler. E.g when new modules have been loaded
 
* [[inModule]]: Returns true if the given address is inside a module
 
* [[inModule]]: Returns true if the given address is inside a module
 
* [[inSystemModule]]: Returns true if the given address is inside a system module
 
* [[inSystemModule]]: Returns true if the given address is inside a system module
 +
* [[getModuleSize]]: Returns the size of a given module (Use getAddress to get the base address)
 
* [[errorOnLookupFailure]]: Set whether address lookups will throw errors, or just return 0.
 
* [[errorOnLookupFailure]]: Set whether address lookups will throw errors, or just return 0.
 +
* [[registerSymbolLookupCallback]]: Registers a function to be called when a a symbol is parsed
 +
* [[unregisterSymbolLookupCallback]]: Removes the callback
 +
* [[registerAddressLookupCallback]]: Registers a function to be called when the name of an address is requested
 +
* [[unregisterAddressLookupCallback]]: Removes the callback
  
  
 
=== Memory ===
 
=== Memory ===
 +
 +
* [[allocateMemory]]: Allocates some memory into the target process
 +
* [[deAlloc]]: Frees allocated memory
 +
* [[allocateSharedMemory]]: Creates a shared memory object of the given size if it doesn't exist yet
 +
* [[createSection]]: Creates a 'section' in memory
 +
* [[mapViewOfSection]]: Maps the section to memory
 +
* [[unMapViewOfSection]]: Unmaps a section from memory
 +
  
 
These functions read/write memory from the opened process.
 
These functions read/write memory from the opened process.
  
;Reading
+
; Reading
 
* [[readBytes]]: Returns the bytes at the given address. If ReturnAsTable is true it will return a table instead of multiple bytes
 
* [[readBytes]]: Returns the bytes at the given address. If ReturnAsTable is true it will return a table instead of multiple bytes
 
* [[readSmallInteger]]: Reads a 16-bit integer from the specified address.
 
* [[readSmallInteger]]: Reads a 16-bit integer from the specified address.
Line 64: Line 98:
 
* [[readRegionFromFile]]: Writes the given file to a specific address
 
* [[readRegionFromFile]]: Writes the given file to a specific address
  
;Writing
+
; Writing
 
* [[writeBytes]]: Write the given bytes to the given address from a table
 
* [[writeBytes]]: Write the given bytes to the given address from a table
 
* [[writeSmallInteger]]: Writes a 16-bit integer to the specified address. Returns true on success.
 
* [[writeSmallInteger]]: Writes a 16-bit integer to the specified address. Returns true on success.
Line 73: Line 107:
 
* [[writeString]]: Write a string to the specified address. Returns true on success.
 
* [[writeString]]: Write a string to the specified address. Returns true on success.
 
* [[writeRegionToFile]]: Writes the given region to a file. Returns the number of bytes written.
 
* [[writeRegionToFile]]: Writes the given region to a file. Returns the number of bytes written.
 +
  
 
=== Input devices ===
 
=== Input devices ===
Line 78: Line 113:
 
These functions get/set keyboard/mouse input.
 
These functions get/set keyboard/mouse input.
  
* [[getMousePos]]: Returns the x,y coordinates of the mouse
+
* [[getMousePos]]: Returns the ''X'' and ''Y'' coordinates of the mouse
 
* [[setMousePos]]: Sets the mouse position
 
* [[setMousePos]]: Sets the mouse position
 
* [[isKeyPressed]]: Returns true if the specified key is currently pressed
 
* [[isKeyPressed]]: Returns true if the specified key is currently pressed
Line 84: Line 119:
 
* [[keyUp]]: Causes the key to go up
 
* [[keyUp]]: Causes the key to go up
 
* [[doKeyPress]]: Simulates a key press
 
* [[doKeyPress]]: Simulates a key press
 +
* [[mouse_event]]: The Windows' API ''"mouse_event"''. [https://msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx msdn.microsoft.com/en-us/library/windows/desktop/ms646260(v=vs.85).aspx]
 +
* [[setGlobalKeyPollInterval]]: Sets the global keypoll interval
 +
* [[setGlobalDelayBetweenHotkeyActivation]]: Sets the minimum delay between the activation of the same hotey in milliseconds
 +
 +
; Game Controller
 +
* [[getXBox360ControllerState]]: Fetches the state of the connected XBox controller
 +
* [[setXBox360ControllerVibration]]: Sets the speed of the left and right vibrating motor inside the controller
 +
 +
; Clipboard
 +
* [[writeToClipboard]]: Writes the given text to the clipboard
 +
* [[readFromClipboard]]: Reads the text from the clipboard
 +
 +
 +
=== Screen ===
 +
 +
* [[getScreenHeight]]: Returns the screen height
 +
* [[getScreenWidth]]: Returns the screen  width
 +
* [[getWorkAreaHeight]]: Returns the work area height
 +
* [[getWorkAreaWidth]]: Returns the work area width
 +
* [[getScreenCanvas]]: Returns a Canvas object you can use to write to the screen (Note: Not as useful as you may think)
 +
* [[getPixel]]: Returns the RGB value of the pixel at the specific screen coordinate
 +
 +
 +
=== Sounds ===
 +
 +
* [[playSound]]: Plays a sound file
 +
* [[beep]]: Plays the fabulous beep/ping sound!
 +
* [[speak]]: Speaks a given text
 +
* [[speak]]: Speaks a given text using the given flags [https://msdn.microsoft.com/en-us/library/speechplatform_speakflags.aspx msdn.microsoft.com/en-us/library/speechplatform_speakflags.aspx]
 +
* [[speakEnglish]]: Will try the English voice by wrapping the given text into an XML statement specifying the English voice
 +
 +
; xmplayer
 +
* [[xmplayer_playXM]]: Plays the given filename using the xmplayer
 +
* [[xmplayer_pause]]: Pauses the current xm audio file
 +
* [[xmplayer_resume]]: Resumes the current xm audio file
 +
* [[xmplayer_stop]]: Stops the current xm audio file
 +
* [[xmplayer_isPlaying]]: Returns true if there is currently an xm audio file being played
 +
 +
 +
=== Text to Speech ===
 +
 +
* [[speak]]: Speaks a given text.
 +
* [[speakEnglish]]: Speaks a given text with English voice.
 +
 +
 +
=== Fonts ===
 +
 +
* [[loadFontFromStream]]: Loads a font from a memory stream and returns an id (handle) to the font for use with [[unloadLoadedFont]]
 +
* [[unloadLoadedFont]]: Unloads a font from a memory stream
 +
 +
 +
=== Forms and Windows ===
 +
 +
* [[findWindow]]: Finds a window with the given classname and/or windowname
 +
* [[getWindow]]: Gets a specific window based on the given window (Check MSDN getWindow for the command description)
 +
* [[getWindowCaption]]: Returns the caption of the window
 +
* [[getWindowClassName]]: Returns the classname of the window
 +
* [[getWindowProcessID]]: Returns the processid of the process this window belongs to
 +
* [[getForegroundWindow]]: Returns the windowhandle of the topmost window
 +
* [[sendMessage]]: Sends a message to a window
 +
* [[hookWndProc]]: Hooks a window's wndproc procedure
 +
* [[unhookWndProc]]: Called when done with the hook from [[hookWndProc]]
  
  
Line 90: Line 187:
 
These functions help manage Cheat Engine itself.
 
These functions help manage Cheat Engine itself.
  
* [[unhideMainCEwindow]]: Shows the main cheat engine window
+
* [[getFormCount]]: Returns the total number of forms assigned to the main CE application
* [[hideAllCEWindows]]: Makes all normal ce windows invisible (e.g trainer table)
+
* [[getForm]]: Returns the form at the specific index
 +
* [[getMemoryViewForm]]: Returns the first Memoryview form class object
 +
* [[getMainForm]]: Returns the first Mainform class object
 +
* [[getFreezeTimer]]: Returns the Timer object responsible for freezing values
 +
* [[getUpdateTimer]]: Returns the Timer object responsible for updating the value list
 +
* [[getCommonModuleList]]: Returns the commonModuleList [[StringList]] object
 +
* [[targetIs64Bit]]: Returns true if the target process is 64-bit, false if 32-bit
 +
* [[getCheatEngineProcessID]]: Returns the processid of cheat engine
 +
* [[cheatEngineIs64Bit]]: Returns true if Cheat Engine is 64-bit, false if 32-bit
 +
* [[closeCE]]: Closes Cheat Engine
 +
* [[getAutoAttachList]]: Returns the AutoAttach [[StringList]] object
 +
* [[registerFormAddNotification]]: Registers a function to be called when a form is attached to Cheat Engine's form list
 +
* [[unregisterFormAddNotification]]: unregister the FormAddNotification call back
 +
* [[connectToCEServer]]: Connects to the given host and port. On success, most commands subsequent will be handled by the server
 +
 
 +
* [[unhideMainCEwindow]]: Shows the main Cheat Engine window
 +
* [[hideAllCEWindows]]: Makes all normal Cheat Engine windows invisible (e.g trainer table)
 
* [[supportCheatEngine]]: Will show an advertising window which will help keep the development of Cheat Engine going.
 
* [[supportCheatEngine]]: Will show an advertising window which will help keep the development of Cheat Engine going.
 
* [[fuckCheatEngine]]: Removes the ad window if it was showing
 
* [[fuckCheatEngine]]: Removes the ad window if it was showing
Line 97: Line 210:
 
* [[readBytesLocal]]: readBytes, but for Cheat Engine's own memory
 
* [[readBytesLocal]]: readBytes, but for Cheat Engine's own memory
 
* [[writeBytesLocal]]: writeBytes, but for Cheat Engine's own memory
 
* [[writeBytesLocal]]: writeBytes, but for Cheat Engine's own memory
* [[cheatEngineIs64Bit]]: Returns true if CE is 64-bit, false if 32-bit
 
* [[closeCE]]: Closes ce
 
  
 
; Messages
 
; Messages
* [[showMessage]]: Shows a messagebox with the given text
+
* [[showMessage]]: Shows a message box with the given text
* [[messageDialog]]: Pops up a messagebox
+
* [[messageDialog]]: Pops up a message box
 +
* [[outputDebugString]]: Outputs a message using the windows OutputDebugString message
  
; Sounds
+
; Input
* [[playSound]]: Plays a sound file
+
* [[inputQuery]]: Shows a dialog where the user can input a string. This function returns the given string, or nil on cancel  (CE6.4+)
* [[beep]]: Plays the fabulous beep/ping sound!
+
 
* [[xmplayer_playXM]]: Plays the given filename using the xmplayer
+
; Shortcuts
* [[xmplayer_pause]]: Pauses the current xm audio file
+
* [[shortCutToText]]: Returns the textual representation of the given shortcut value (integer) (6.4+)
* [[xmplayer_resume]]: Resumes the current xm audio file
+
* [[textToShortCut]]: Returns an shortcut integer that the given string represents.  (6.4+)
* [[xmplayer_stop]]: Stops the current xm audio file
+
* [[convertKeyComboToString]]: Returns a string representation of the given keys like the hot-key handler does
* [[xmplayer_isPlaying]]: Returns true if there is currenty an xm audio file being played
+
 
 +
; Speed Hack
 +
* [[speedhack_setSpeed]]: Enables the speed hack if it was not active yet and sets the given speed
 +
* [[speedhack_getSpeed]]: Returns the last set speed
  
; Text to Speech
 
* [[speak]]: Speaks a given text.
 
* [[speakEnglish]]: Speaks a given text with English voice.
 
  
 
=== Lua ===
 
=== Lua ===
Line 154: Line 266:
 
* [[getInstructionSize]]: Returns the size of an instruction
 
* [[getInstructionSize]]: Returns the size of an instruction
 
* [[getPreviousOpcode]]: Returns the address of the previous opcode (guess)
 
* [[getPreviousOpcode]]: Returns the address of the previous opcode (guess)
 +
* [[registerAssembler]]: Registers a function to be called when the single line assembler is invoked to convert an instruction to a list of bytes
 +
* [[unregisterAssembler]]: Unregisters the registered assembler
 +
 +
=== Auto Assembler ===
 +
 +
* [[registerAutoAssemblerCommand]]: Registers an auto assembler command to call the specified function
 +
* [[unregisterAutoAssemblerCommand]]: Unregisters an auto assembler command
 +
* [[registerAutoAssemblerPrologue]]: Registers a function to be called when the auto assembler is about to parse an auto assembler script
 +
* [[unregisterAutoAssemblerPrologue]]: Unregisters an auto assembler prologue
 +
* [[registerAutoAssemblerTemplate]]: Registers a template for the auto assembler
 +
* [[unregisterAutoAssemblerTemplate]]: Unregisters a template for the auto assembler
 +
* [[generateCodeInjectionScript]]: Adds a default code injection script to the given script
 +
* [[generateAOBInjectionScript]]: Adds an AOB injection script to the given script
 +
* [[generateFullInjectionScript]]: Adds a Full Injection script to the given script
 +
 +
  
 
=== Debugger ===
 
=== Debugger ===
Line 168: Line 296:
 
* [[debug_getLastBranchRecord]]: Returns the value of the Last Branch Record at the given index (when handling a breakpoint)
 
* [[debug_getLastBranchRecord]]: Returns the value of the Last Branch Record at the given index (when handling a breakpoint)
 
* [[debugger_onModuleLoad]]: Called by CE when the windows debugger interface loads a module (userdefined)
 
* [[debugger_onModuleLoad]]: Called by CE when the windows debugger interface loads a module (userdefined)
* [[getAutoAttachList]]: Returns the AutoAttach StringList object
 
 
* [[debug_getContext]] (since 6.5): Force-update the Lua variables representing the registers?
 
* [[debug_getContext]] (since 6.5): Force-update the Lua variables representing the registers?
 
* [[debug_setContext]] (since 6.5[http://www.cheatengine.org/forum/viewtopic.php?p=5639331&sid=755d2d512f48af1f29382048087761b9#5639331]): Force-update the registers to the Lua variables which represent them?
 
* [[debug_setContext]] (since 6.5[http://www.cheatengine.org/forum/viewtopic.php?p=5639331&sid=755d2d512f48af1f29382048087761b9#5639331]): Force-update the registers to the Lua variables which represent them?
 +
  
 
=== DBK ===
 
=== DBK ===
Line 186: Line 314:
 
* [[dbvm_readMSR]]: Reads the msr using dbvm (bypasses the driver)
 
* [[dbvm_readMSR]]: Reads the msr using dbvm (bypasses the driver)
 
* [[dbvm_writeMSR]]: Writes the msr using dbvm (bypasses the driver)
 
* [[dbvm_writeMSR]]: Writes the msr using dbvm (bypasses the driver)
 +
  
 
=== Translation ===
 
=== Translation ===
 +
 
* [[getTranslationFolder]]: Returns the path of the current translation files, empty if there is no translation going on
 
* [[getTranslationFolder]]: Returns the path of the current translation files, empty if there is no translation going on
 
* [[loadPOFile]]: Loads a ''".PO"'' file used for translation
 
* [[loadPOFile]]: Loads a ''".PO"'' file used for translation
 
* [[translate]]: Returns a translation of the string, returns the same string if it can't be found
 
* [[translate]]: Returns a translation of the string, returns the same string if it can't be found
 
* [[translateID]]: Returns a translation of the string ID
 
* [[translateID]]: Returns a translation of the string ID
 +
 +
 +
=== Files ===
 +
 +
* [[getFileVersion]]: Returns the 64-bit file version, and a table that has split up the file version into major, minor, release and build]]
 +
* [[getDirectoryList]]: Returns an indexed table with directory names
 +
 +
 +
=== Structures ===
 +
* [[registerStructureDissectOverride]]: same as [[onAutoGuess]], but is called by the structure dissect window when the user chooses to let cheat engine guess the structure for them
 +
* [[unregisterStructureDissectOverride]]: unregisters the structure dissect auto guess override
 +
* [[registerStructureNameLookup]]: Registers a function to be called when dissect data asks the user for the name of a new structure define
 +
* [[unregisterStructureNameLookup]]:
  
  
Line 206: Line 349:
 
* [[encodeFunction]]: Converts a given function into an encoded string that you can pass on to [[decodeFunction]]
 
* [[encodeFunction]]: Converts a given function into an encoded string that you can pass on to [[decodeFunction]]
 
* [[decodeFunction]]: Converts an encoded string back into a function
 
* [[decodeFunction]]: Converts an encoded string back into a function
 
+
* [[md5memory]]: Returns a md5 sum calculated from the provided memory
 
+
* [[md5file]]: Returns a md5 sum calculated from the file
Other various Cheat Engine internal objects.
+
* [[getSystemMetrics]]: Retrieves the specified system metric or system configuration setting [https://msdn.microsoft.com/en-us/library/windows/desktop/ms724385.aspx msdn.microsoft.com/en-us/library/windows/desktop/ms724385.aspx]
 
+
* [[getTickCount]]: Returns the current tickcount since windows was started. Each tick is one millisecond
* [[getFormCount]]: Returns the total number of forms assigned to the main CE application
+
* [[processMessages]]: Lets the main eventhandler process the new messages (allows for new button clicks)
* [[getForm]]: Returns the form at the specific index
+
* [[integerToUserData]]: Converts a given integer to a userdata variable
* [[getMemoryViewForm]]: Returns the first Memoryview form class object
+
* [[userDataToInteger]]: Converts a given userdata variable to an integer
* [[getMainForm]]: Returns the first Mainform class object
+
* [[executeCode]]: Executes a stdcall function with 1 parameter at the given address in the target process and wait for it to return
* [[getFreezeTimer]]: Returns the Timer object responsible for freezing values
+
* [[executeCodeLocal]]: Executes a stdcall function with 1 parameter at the given address in the target process
* [[getUpdateTimer]]: Returns the Timer object responsible for updating the value list
+
* [[getUserRegistryEnvironmentVariable]]: Returns the environment variable stored in the user registry environment
* [[getCommonModuleList]]: Returns the commonModuleList StringList object
+
* [[setUserRegistryEnvironmentVariable]]: Sets the environment variable stored in the user registry environment
 +
* [[broadcastEnvironmentUpdate]]: Call this when you've changed the environment variables in the registry
 +
* [[stringToMD5String]]: Returns an md5 hash string from the provided string
 +
* [[getApplication]]: Returns the application object (the titlebar)
  
  
Line 288: Line 434:
  
 
See:
 
See:
* [[getPropertyList]] : Returns a StringList object containing all the published properties of the specified class
+
* [[getPropertyList]] : Returns a [[StringList]] object containing all the published properties of the specified class
 
* [[setProperty]] : Sets the value of a published property of a class (Won't work for method properties)
 
* [[setProperty]] : Sets the value of a published property of a class (Won't work for method properties)
 
* [[getProperty]] : Gets the value of a published property of a class (Won't work for method properties)
 
* [[getProperty]] : Gets the value of a published property of a class (Won't work for method properties)

Revision as of 09:02, 4 January 2018

Cheat Engine comes with an extensive set of Lua functions you can use inside cheat tables, trainers and standalone scripts.


Functions

Cheat table

These functions help manage the cheat table.


Scanning

These functions control Cheat Engine's scanning.


Process


Threads

  • getCPUCount: Returns the number of CPU's
  • getThreadlist: Fills a List object with the threadlist of the currently opened process
  • inMainThread: Returns true if the current code is running inside the main thread (6.4+)
  • synchronize: Calls the given function from the main thread. Returns the return value of the given function
  • queue: Calls the given function from the main thread. Does not wait for the result
  • checkSynchronize: Call this from an infinite loop in the main thread when using threading and synchronize calls


Addresses

These functions help convert between memory addresses and symbols/CEAddressStrings.


Memory


These functions read/write memory from the opened process.

Reading
  • readBytes: Returns the bytes at the given address. If ReturnAsTable is true it will return a table instead of multiple bytes
  • readSmallInteger: Reads a 16-bit integer from the specified address.
  • readInteger: Reads a 32-bit integer from the specified address.
  • readQword: Reads a 64-bit integer from the specified address.
  • readPointer: In a 64-bit target this equals readQword, in a 32-bit target readInteger().
  • readFloat: Reads a single precision floating point value from the specified address
  • readDouble: Reads a double precision floating point value from the specified address
  • readString: Reads a string from memory until it hits a 0-terminator. maxlength is just so you won't freeze for too long
  • readRegionFromFile: Writes the given file to a specific address
Writing
  • writeBytes: Write the given bytes to the given address from a table
  • writeSmallInteger: Writes a 16-bit integer to the specified address. Returns true on success.
  • writeInteger: Writes a 32-bit integer to the specified address. Returns true on success.
  • writeQword: Write a 64-bit integer to the specified address. Returns true on success.
  • writeFloat: Writes a single precision floating point to the specified address. Returns true on success.
  • writeDouble: Writes a double precision floating point to the specified address. Returns true on success.
  • writeString: Write a string to the specified address. Returns true on success.
  • writeRegionToFile: Writes the given region to a file. Returns the number of bytes written.


Input devices

These functions get/set keyboard/mouse input.

Game Controller
Clipboard


Screen


Sounds

xmplayer


Text to Speech


Fonts


Forms and Windows


Cheat Engine

These functions help manage Cheat Engine itself.

Messages
Input
  • inputQuery: Shows a dialog where the user can input a string. This function returns the given string, or nil on cancel (CE6.4+)
Shortcuts
  • shortCutToText: Returns the textual representation of the given shortcut value (integer) (6.4+)
  • textToShortCut: Returns an shortcut integer that the given string represents. (6.4+)
  • convertKeyComboToString: Returns a string representation of the given keys like the hot-key handler does
Speed Hack


Lua

These functions help manage Lua itself.

  • resetLuaState: This will create a new Lua state that will be used.
  • sleep: Pauses for the number of specified milliseconds


Types

These functions help structure a process's memory into datatypes.


Object-oriented

These functions determine how a Lua object fits in the class hierarchy.


Assembly

These functions help work with the x86 machine code as assembly.

  • autoAssemble: Runs the auto assembler with the given text
  • autoAssembleCheck: Checks the script for syntax errors. Returns true on succes, false with an error message on failure
  • disassemble: Disassembles the given address and returns a string in the format of "address - bytes - opcode extra"
  • splitDisassembledString: Returns 4 strings. The address, bytes, opcode and extra field
  • getInstructionSize: Returns the size of an instruction
  • getPreviousOpcode: Returns the address of the previous opcode (guess)
  • registerAssembler: Registers a function to be called when the single line assembler is invoked to convert an instruction to a list of bytes
  • unregisterAssembler: Unregisters the registered assembler

Auto Assembler


Debugger

These functions manage the debugger. See Lua Debugging.


DBK


Translation

  • getTranslationFolder: Returns the path of the current translation files, empty if there is no translation going on
  • loadPOFile: Loads a ".PO" file used for translation
  • translate: Returns a translation of the string, returns the same string if it can't be found
  • translateID: Returns a translation of the string ID


Files

  • getFileVersion: Returns the 64-bit file version, and a table that has split up the file version into major, minor, release and build]]
  • getDirectoryList: Returns an indexed table with directory names


Structures


Miscellaneous


Besides the above functions, Cheat Engine also implements some classes.

Classes

  • Addresslist: The addresslist class is a container for memory records
  • Brush: The brush class is part of the Canvas object. It's used to fill surfaces
  • Button: The button class is a visual component in the shape of a button.
  • ButtonControl: Common ancestor of several button like objects.
  • Canvas: The canvas class is a graphical class. It allows you do draw lines, pictures, and text on top of other object. Usually used in onPaint events and other graphical events
  • CheatComponent: The cheatcomponent class is the component used in Cheat Engine 5.x trainers
  • CheckBox: The Checkbox is a visual component that lets the user click it and change state between checked, unchecked, and if possible, grayed
  • Component : Base class for all components that need owner-owned functionality.
  • Control : Base class for visible controls.
  • Collection: The Collection class is an abstract class that the ListColumns class implements (And perhaps other classes as well)
  • CollectionItem: Basic object that is managed by a Collection class
  • ComboBox: The Combobox is like an edit field with a ListBox attached to it
  • CustomControl: Base class for windowed controls which paint themselves
  • Disassemblerview: The visual disassembler used in the memory view window
  • Edit: The Edit class is a visual component that lets the user type in data (Use control_getCaption to get the user input)
  • FileStream: The FileStream class is a Stream class that is linked to an open file on disk
  • Font: Class that defines a font
  • Form: Class that defines a window
  • FoundList: The foundlist is an companion class to MemScan. It opens the current memscan's result file and provides an interface for reading out the addresses
  • GenericHotkey: Lets you register hotkeys to Cheat Engine's internal hotkey handler
  • Graphic: Base class for dealing with Graphic images (Abstract)
  • GraphicControl: Class that supports simple lightweight controls that do not need the ability to accept keyboard input or contain other controls.
  • GroupBox: The groupbox class is like a Panel, but then has a header on top
  • Hexadecimalview: The visual hexadecimal object used on the memory view window
  • Image: The Image class is a visual component that lets you show an image
  • Label: The Label class is a visual component that lets you display text
  • ListBox: The listbox class is a visual component with a list of selectable strings
  • ListColumn: The listcolumn class is an implemented CollectionItem class which is used by the ListColumns class of the listview class
  • ListColumns: The ListColumns class contains the Column class objects of a ListView object
  • ListItem: The ListItem class object is an entry in a ListView
  • ListItems: The listItems class is a container for the ListItem class objects of a Listview
  • Listview: The listview class lets you have a listbox like component with resizable columns
  • MainMenu: The menu at the top of a form
  • Memo: The Memo class is a multiline edit field
  • MemScan: The memscan class is the memory scanner of Cheat engine
  • Menu: Common Class ancestor for the MainMenu and PopupMenu classes
  • MenuItem: Holds the menuitems of a Menu, PopupMenu or even another MenuItem
  • MemoryRecord: The Memoryrecord class object describes a Cheat Table's Cheat Entry.
  • MemoryRecordHotkey: The memoryRecordHotkey class object is part of a MemoryRecord class. It's used as an interface to each individual hotkey inside a Cheat Table
  • MemoryStream: The memorystream class is a Stream class that is stored completely in memory. Because it's a stream there are multiple functions that can work with it
  • Memoryview: The memoryview class is the Memory view window of Cheat Engine. Use this as a basis to access the objects inside this window
  • Object : Most basic class. All classes inherit from this class
  • Panel: The Panel class is like a form which can contain visual components.
  • Pen: The Pen class is part of the Canvas object. It's used to draw lines
  • Picture: Container for the Graphic class
  • PopupMenu: The menu that shows when rightclicking on an object
  • ProgressBar: The progressbar class is a visual representation for a bar that can show the current progress on something
  • RadioGroup: The radiogroup is like a GroupBox but autopopulated using the Items(Strings object)
  • OpenDialog: The OpenDialog class is used for selecting files to open.
  • SaveDialog: The SaveDialog class is based on the OpenDialog class but is used to select a file for saving
  • Splitter: The Splitter class is a visual component that lets the user re-size neighboring components)
  • Stringlist: Class that holds a list of strings
  • Strings: Abstract class that some text based classes make use of
  • TableFile: Tablefiles are files stored into a Cheat Table. You can access the data of such a file using this class
  • Timer: The timer class is an non visual component that when active triggers an onTimer event every few milliseconds, based on the given interval
  • ToggleBox: The togglebox is like a button, but can stay down. Use with the checkbox methods
  • TrackBar: The trackbar class is a slider you can drag arround and read/set the state
  • Wincontrol: Base class for controls which can contain other controls.

Undefined Class Property Functions

Not all properties of all classes have been explicitly exposed to lua, but if you know the name of a property of a specific class you can still access them (assuming they are declared as published in the pascal class declaration)

See:

  • getPropertyList : Returns a StringList object containing all the published properties of the specified class
  • setProperty : Sets the value of a published property of a class (Won't work for method properties)
  • getProperty : Gets the value of a published property of a class (Won't work for method properties)