Lua:registerAutoAssemblerTemplate

From Cheat Engine
Revision as of 00:20, 11 July 2025 by Leunsel (talk | contribs)
Jump to navigation Jump to search

function registerAutoAssemblerTemplate(Name, Callback, [Shortcut]) : id

Registers a template for the Auto Assembler window in Cheat Engine. The callback function receives the current script as a TStrings object and the sender form. All script parsing and template logic is handled by your callback. Returns an ID that can be used to unregister the template if needed.

Function Parameters

Parameter Type Description
Name String The name of the template as it appears in the Auto Assembler's template menu.
Callback Function A function with the signature function(script: TStrings, sender: TFrmAutoInject) that is called when the template is selected.
script is a TStrings object directly connected to the current script.
Shortcut String (optional) A keyboard shortcut for the template (e.g., "Ctrl+Alt+T"). Optional.

Returns

The ID of the registered template (useful for unregisterAutoAssemblerTemplate).

Examples

-- Register a simple template that inserts a comment at the top of the script
local templateID = registerAutoAssemblerTemplate("Insert Comment", function(script, sender)
  script.insert(0, "-- Inserted by template!")
end)

-- Register a template with a shortcut
registerAutoAssemblerTemplate("NOP All", function(script, sender)
  script.text = "[ENABLE]\nalloc(newmem,$1000)\nlabel(return)\nnewmem:\nnop\njmp return\n[DISABLE]\n", sender
end, "Ctrl+Alt+N")

See also

Related Functions