Difference between revisions of "Lua:registerAutoAssemblerTemplate"

From Cheat Engine
Jump to navigation Jump to search
(Replaced content with '<span style="font-size:25px;color:red">Sorry! Content not available.</span>')
(Related Functions)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<span style="font-size:25px;color:red">Sorry! Content not available.</span>
+
[[Category:Lua]]
 +
'''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===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Parameter
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|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 <code>function(script: TStrings, sender: TFrmAutoInject)</code> that is called when the template is selected. <br> <code>script</code> 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 [[Lua:unregisterAutoAssemblerTemplate|unregisterAutoAssemblerTemplate]]).
 +
 
 +
===Examples===
 +
<pre>
 +
-- 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")
 +
</pre>
 +
 
 +
{{LuaSeeAlso}}
 +
 
 +
== Related Functions ==
 +
* [[Lua:registerAutoAssemblerCommand|registerAutoAssemblerCommand]]
 +
* [[Lua:registerAutoAssemblerPrologue|registerAutoAssemblerPrologue]]
 +
* [[Lua:unregisterAutoAssemblerPrologue|unregisterAutoAssemblerPrologue]]
 +
* [[Lua:unregisterAutoAssemblerTemplate|unregisterAutoAssemblerTemplate]]
 +
* [[Lua:generateCodeInjectionScript|generateCodeInjectionScript]]
 +
* [[Lua:generateAOBInjectionScript|generateAOBInjectionScript]]
 +
* [[Lua:generateFullInjectionScript|generateFullInjectionScript]]

Latest revision as of 00:20, 11 July 2025

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[edit]

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[edit]

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

Examples[edit]

-- 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[edit]

Related Functions[edit]