Difference between revisions of "Lua:autoAssembleCheck"

From Cheat Engine
Jump to navigation Jump to search
m (Updated example.)
m (Syntax Highlighting.)
 
Line 25: Line 25:
  
 
=== Example ===
 
=== Example ===
<pre>
+
<syntaxhighlight lang="lua" line>
 
local script = [[
 
local script = [[
 
alloc(newmem,2048,"cheatengine-x86_64-SSE4-AVX2.exe"+3E18)
 
alloc(newmem,2048,"cheatengine-x86_64-SSE4-AVX2.exe"+3E18)
Line 52: Line 52:
 
   print("Syntax error:", err)
 
   print("Syntax error:", err)
 
end
 
end
</pre>
+
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
  
 
{{Assembly}}
 
{{Assembly}}

Latest revision as of 19:26, 25 June 2026

<> Lua API Reference

function autoAssembleCheck(text, enable, targetself)

Checks the given Auto Assembler script for syntax errors. Returns true on success, or false with an error message on failure.

Function Parameters[edit]

Parameter Type Description
text String The Auto Assembler script to validate.
enable Boolean If set, checks the [ENABLE] part of the script.
targetself Boolean If true, checks the script as if assembling into Cheat Engine itself.

Example[edit]

 1 local script = [[
 2 alloc(newmem,2048,"cheatengine-x86_64-SSE4-AVX2.exe"+3E18)
 3 label(returnhere)
 4 label(originalcode)
 5 label(exit)
 6 
 7 newmem: //this is allocated memory, you have read,write,execute access
 8 //place your code here
 9 
10 originalcode:
11 lea rsp,[rsp+28]
12 
13 exit:
14 jmp returnhere
15 
16 "cheatengine-x86_64-SSE4-AVX2.exe"+3E18:
17 jmp newmem
18 returnhere:
19 ]]
20 
21 local ok, err = autoAssembleCheck(script, true, false)
22 if ok then
23   print("Script is valid")
24 else
25   print("Syntax error:", err)
26 end

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Assembler and Disassembler Related Lua Functions

Auto assembler, disassembly helpers, instruction size lookup, and assembler callbacks