Difference between revisions of "Lua:getAutoAttachList"
Jump to navigation
Jump to search
m (added page reference) |
Mr millchick (talk | contribs) (added more details and examples) |
||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' getAutoAttachList() ''':''' UserData | + | '''function''' getAutoAttachList() ''':''' UserData ('''[[Lua:Class:StringList|StringList]]''') |
| − | Returns | + | Returns Cheat Engine's global '''Auto Attach''' process list as a live [[Lua:Class:StringList|StringList]] object. |
| − | + | * '''Parameters:''' <None> | |
| + | * '''Returns:''' A shared '''[[Lua:Class:StringList|StringList]]''' object containing process names that Cheat Engine will try to auto-attach to when they start. | ||
| + | ** '''Ownership:''' ''Do not'' call '''destroy()''' on this object. It is owned by Cheat Engine and shared with the UI/settings. | ||
| + | |||
| + | |||
| + | === Description === | ||
| + | |||
| + | Cheat Engine can automatically attach to a process if its name appears in the Auto Attach list. This function exposes that list to Lua as a '''[[Lua:Class:StringList|StringList]]''', allowing you to: | ||
| + | |||
| + | * Inspect the current auto-attach targets | ||
| + | * Add new process names (e.g., ''notepad.exe'') | ||
| + | * Remove or clear entries | ||
| + | * Reorder items | ||
| + | |||
| + | Changes take effect immediately and are reflected in Cheat Engine's UI. | ||
| + | |||
| + | |||
| + | === Function Parameters === | ||
| + | |||
| + | ''None'' | ||
| + | |||
| + | |||
| + | === Returns === | ||
| + | |||
| + | A live [[Lua:Class:StringList|StringList]] object. Common members you may use: | ||
| + | |||
| + | * '''Count''' — number of items | ||
| + | * '''Add(text)''' — append a process name | ||
| + | * '''Delete(index)''' — remove by index (0-based) | ||
| + | * '''IndexOf(text)''' — find an item's index or return -1 if not found | ||
| + | * '''Clear()''' — remove all items | ||
| + | * '''Strings[index]''' / '''[index]''' — get/set item text | ||
| + | |||
| + | ''Reminder:'' This is a shared internal object. Do not destroy it. | ||
| + | |||
| + | |||
| + | === Usage Examples === | ||
| + | |||
| + | '''Simple Auto Attach to a Process:''' | ||
| + | * See [[Tutorials:Lua:Setup_Auto_Attach|Setup Auto Attach Tutorial]] for more details. | ||
| + | getAutoAttachList().add("mygame.exe") | ||
| + | |||
| + | '''Print the current auto-attach list:''' | ||
| + | local list = getAutoAttachList() | ||
| + | for i = 0, list.Count - 1 do | ||
| + | print(i .. ": " .. list[i]) | ||
| + | end | ||
| + | |||
| + | '''Add a new target (if not already present):''' | ||
| + | local list = getAutoAttachList() | ||
| + | local name = "notepad.exe" | ||
| + | if list.IndexOf(name) == -1 then | ||
| + | list.Add(name) | ||
| + | print("Added: " .. name) | ||
| + | else | ||
| + | print("Already exists: " .. name) | ||
| + | end | ||
| + | |||
| + | '''Get the name of the second auto-attach target:''' | ||
| + | getAutoAttachList().getString(1) | ||
| + | |||
| + | '''Remove a target by name:''' | ||
| + | local list = getAutoAttachList() | ||
| + | local name = "oldgame.exe" | ||
| + | local idx = list.IndexOf(name) | ||
| + | if idx ~= -1 then | ||
| + | list.Delete(idx) | ||
| + | print("Removed: " .. name) | ||
| + | end | ||
| + | |||
| + | '''Clear all entries (use with care):''' | ||
| + | local list = getAutoAttachList() | ||
| + | list.Clear() | ||
| + | print("Auto-attach list cleared. Count = " .. list.Count) | ||
| + | |||
| + | '''Insert and reorder:''' | ||
| + | local list = getAutoAttachList() | ||
| + | -- Insert at the top | ||
| + | list.Insert(0, "game.exe") | ||
| + | -- Move first item to the end | ||
| + | if list.Count > 0 then | ||
| + | local first = list[0] | ||
| + | list.Delete(0) | ||
| + | list.Add(first) | ||
| + | end | ||
| + | |||
| + | |||
| + | === Notes === | ||
| + | |||
| + | * Entries are typically process executable names (e.g., ''game.exe''). | ||
| + | * The list is shared with Cheat Engine's UI; edits here show up in the Auto Attach configuration. | ||
| + | * ''Don't'' call '''destroy()''' on the returned list. Manage entries via standard '''StringList''' methods. | ||
| − | |||
| − | |||
| − | |||
| − | |||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | |||
| − | |||
* [[Lua:Class:StringList|StringList]] | * [[Lua:Class:StringList|StringList]] | ||
| − | + | ``` | |
| − | |||
| − | |||
Latest revision as of 04:14, 25 October 2025
function getAutoAttachList() : UserData (StringList)
Returns Cheat Engine's global Auto Attach process list as a live StringList object.
- Parameters: <None>
- Returns: A shared StringList object containing process names that Cheat Engine will try to auto-attach to when they start.
- Ownership: Do not call destroy() on this object. It is owned by Cheat Engine and shared with the UI/settings.
Description[edit]
Cheat Engine can automatically attach to a process if its name appears in the Auto Attach list. This function exposes that list to Lua as a StringList, allowing you to:
- Inspect the current auto-attach targets
- Add new process names (e.g., notepad.exe)
- Remove or clear entries
- Reorder items
Changes take effect immediately and are reflected in Cheat Engine's UI.
Function Parameters[edit]
None
Returns[edit]
A live StringList object. Common members you may use:
- Count — number of items
- Add(text) — append a process name
- Delete(index) — remove by index (0-based)
- IndexOf(text) — find an item's index or return -1 if not found
- Clear() — remove all items
- Strings[index] / [index] — get/set item text
Reminder: This is a shared internal object. Do not destroy it.
Usage Examples[edit]
Simple Auto Attach to a Process:
- See Setup Auto Attach Tutorial for more details.
getAutoAttachList().add("mygame.exe")
Print the current auto-attach list:
local list = getAutoAttachList() for i = 0, list.Count - 1 do print(i .. ": " .. list[i]) end
Add a new target (if not already present):
local list = getAutoAttachList()
local name = "notepad.exe"
if list.IndexOf(name) == -1 then
list.Add(name)
print("Added: " .. name)
else
print("Already exists: " .. name)
end
Get the name of the second auto-attach target:
getAutoAttachList().getString(1)
Remove a target by name:
local list = getAutoAttachList()
local name = "oldgame.exe"
local idx = list.IndexOf(name)
if idx ~= -1 then
list.Delete(idx)
print("Removed: " .. name)
end
Clear all entries (use with care):
local list = getAutoAttachList()
list.Clear()
print("Auto-attach list cleared. Count = " .. list.Count)
Insert and reorder:
local list = getAutoAttachList() -- Insert at the top list.Insert(0, "game.exe") -- Move first item to the end if list.Count > 0 then local first = list[0] list.Delete(0) list.Add(first) end
Notes[edit]
- Entries are typically process executable names (e.g., game.exe).
- The list is shared with Cheat Engine's UI; edits here show up in the Auto Attach configuration.
- Don't call destroy() on the returned list. Manage entries via standard StringList methods.
See also[edit]
```