Difference between revisions of "Lua:getAddressSafe"

From Cheat Engine
Jump to navigation Jump to search
m (Syntax Highlighting.)
Line 31: Line 31:
  
 
===Examples===
 
===Examples===
<pre>
+
<syntaxhighlight lang="lua" line>
 
local address = getAddressSafe("KERNEL32.AddAtomA")
 
local address = getAddressSafe("KERNEL32.AddAtomA")
  
Line 39: Line 39:
 
   print("Symbol could not be resolved")
 
   print("Symbol could not be resolved")
 
end
 
end
</pre>
+
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}

Revision as of 16:28, 25 June 2026

<> Lua API Reference

function getAddressSafe(symbolname, local, shallow) : integer

Returns the address of a symbol, or nil if the symbol could not be resolved.

This function is similar to using getAddress with errorOnLookup set to false, but returns nil instead of raising an error when the symbol is not found.

The symbol can be a registered symbol, a module name, or an exported symbol. Set local to true to query the symbol table of the Cheat Engine process instead of the currently opened target process.

Function Parameters

Parameter Type Description
symbolname String The symbol, module name, or exported symbol to resolve.
local Boolean (optional) If true, queries the symbol table of the Cheat Engine process.
shallow Boolean (optional) If true, performs a shallow lookup.

Returns

integer or nil — The resolved address of the given symbol, or nil if the symbol could not be found.

Examples

1 local address = getAddressSafe("KERNEL32.AddAtomA")
2 
3 if address ~= nil then
4   print(string.format("%X", address))
5 else
6   print("Symbol could not be resolved")
7 end

Main Pages

Core Lua documentation entry points

Lua
Script Engine