function onAutoGuess(callback) : void
Registers a callback function that is called whenever Cheat Engine's auto guess feature is used to predict a variable type.
The callback can override the guessed variable type by returning a different value type. If the guess should not be changed, return the provided ceguess value.
Function Parameters
| Parameter
|
Type
|
Description
|
| callback
|
Function
|
The function to call when Cheat Engine auto-guesses a variable type.
|
Returns
This function does not return a value.
Callback Parameters
| Parameter
|
Type
|
Description
|
| address
|
Integer
|
The address for which Cheat Engine is guessing the variable type.
|
| ceguess
|
ValueType
|
The variable type guessed by Cheat Engine.
|
Callback Return Value
| Return Type
|
Description
|
| ValueType
|
Return the variable type that should be used. Return ceguess if the guessed type should not be changed.
|
Common Value Types
| Constant
|
Description
|
| vtByte
|
Byte value.
|
| vtWord
|
2-byte value.
|
| vtDword
|
4-byte integer value.
|
| vtQword
|
8-byte integer value.
|
| vtSingle
|
4-byte floating-point value.
|
| vtDouble
|
8-byte floating-point value.
|
| vtString
|
String value.
|
| vtPointer
|
Pointer value.
|
Examples
Keep Cheat Engine's guessed type
1 onAutoGuess(function(address, ceguess)
2 return ceguess
3 end)
Force all guesses to 4-byte
1 onAutoGuess(function(address, ceguess)
2 return vtDword
3 end)
Override guesses for a specific address range
1 onAutoGuess(function(address, ceguess)
2 local startAddress = getAddress("game.exe+1000")
3 local endAddress = getAddress("game.exe+2000")
4
5 if address >= startAddress and address <= endAddress then
6 return vtSingle
7 end
8
9 return ceguess
10 end)
Treat pointer-looking addresses as pointers
1 onAutoGuess(function(address, ceguess)
2 local value = readPointer(address)
3
4 if value ~= nil and value ~= 0 then
5 return vtPointer
6 end
7
8 return ceguess
9 end)
Log auto guess activity
1 onAutoGuess(function(address, ceguess)
2 print(string.format("Auto guess at %X: %s", address, tostring(ceguess)))
3
4 return ceguess
5 end)
Use a named callback function
1 local function autoGuessOverride(address, ceguess)
2 if ceguess == vtDword then
3 return vtQword
4 end
5
6 return ceguess
7 end
8
9 onAutoGuess(autoGuessOverride)
Only override unknown or unwanted guesses
1 onAutoGuess(function(address, ceguess)
2 if ceguess == nil then
3 return vtDword
4 end
5
6 return ceguess
7 end)
Core Lua documentation entry points