Difference between revisions of "Lua:registerAutoAssemblerTemplate"
Jump to navigation
Jump to search
m (Reverted edits by This content is not available (Talk) to last revision by Dark Byte) |
|||
Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
− | '''function''' registerAutoAssemblerTemplate('' | + | '''function''' registerAutoAssemblerTemplate(''Name'', ''Callback'', [''Shortcut'']) ''':''' id |
− | Registers a template | + | 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" | |
− | |||
− | |||
− | == Function Parameters == | ||
− | {|width="85%" cellpadding="10 | ||
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
!style="width: 80%;background-color:white;" align="left"|Description | !style="width: 80%;background-color:white;" align="left"|Description | ||
|- | |- | ||
− | | | + | |Name |
|String | |String | ||
− | |The | + | |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. |
|} | |} | ||
− | == Examples == | + | ===Returns=== |
− | + | The ID of the registered template (useful for [[Lua:unregisterAutoAssemblerTemplate|unregisterAutoAssemblerTemplate]]). | |
− | + | ||
− | + | ===Examples=== | |
− | script. | + | <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}} | {{LuaSeeAlso}} |
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
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")