Difference between revisions of "Lua:getAutoAttachList"

From Cheat Engine
Jump to navigation Jump to search
m (added page reference)
(Major overhaul of the post.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' getAutoAttachList() ''':''' UserData
+
{{CodeBox|'''function''' getAutoAttachList() ''':''' StringList}}
  
Returns the AutoAttach '''[[Lua:Class:StringList|StringList]]''' UserData object.
+
Returns the Auto Attach [[Lua:Class:Stringlist|Stringlist]] object.
  
{{LuaFunctionParametersNone}}
+
The returned list contains process names that Cheat Engine can automatically attach to. The object can be controlled with the StringList routines and properties, but it should not be destroyed.
  
== Examples ==
+
===Function Parameters===
The returned object can be controlled with [[Lua:Class:StringList|StringList]] methods, e.g:
+
This function has no parameters.
  getAutoAttachList().add("some string")
 
  getAutoAttachList().getString(1)
 
  
{{LuaSeeAlso}}
+
===Returns===
 +
[[Lua:Class:Stringlist|Stringlist]] — The Auto Attach string list object.
 +
 
 +
===Examples===
 +
 
 +
====Get the Auto Attach list====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
 
 +
print("Auto Attach entries: " .. tostring(autoAttachList.Count))
 +
</syntaxhighlight>
 +
 
 +
====Add a process name====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
 
 +
autoAttachList.add("game.exe")
 +
</syntaxhighlight>
 +
 
 +
====Add a process name only if it is missing====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
local processName = "game.exe"
 +
 
 +
if autoAttachList.IndexOf(processName) == -1 then
 +
  autoAttachList.add(processName)
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Print all Auto Attach entries====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
 
 +
for i = 0, autoAttachList.Count - 1 do
 +
  print(autoAttachList[i])
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Remove a process name====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
local index = autoAttachList.IndexOf("game.exe")
 +
 
 +
if index ~= -1 then
 +
  autoAttachList.delete(index)
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Clear the Auto Attach list====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
 
 +
autoAttachList.clear()
 +
</syntaxhighlight>
 +
 
 +
====Set multiple Auto Attach entries====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
 
 +
autoAttachList.clear()
 +
autoAttachList.add("game.exe")
 +
autoAttachList.add("game_dx12.exe")
 +
autoAttachList.add("game_win64_shipping.exe")
 +
</syntaxhighlight>
 +
 
 +
====Use Text to replace the list====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
 +
 
 +
autoAttachList.Text = [[game.exe
 +
game_dx12.exe
 +
game_win64_shipping.exe]]
 +
</syntaxhighlight>
 +
 
 +
====Check whether a process is in the Auto Attach list====
 +
<syntaxhighlight lang="lua" line highlight="1">
 +
local autoAttachList = getAutoAttachList()
  
=== Related Classes ===
+
if autoAttachList.IndexOf("game.exe") ~= -1 then
* [[Lua:Class:StringList|StringList]]
+
  print("game.exe is in the Auto Attach list")
 +
end
 +
</syntaxhighlight>
  
== Notes ==
+
{{LuaSeeAlso}}
It is not recommended to destroy this list object.
 

Latest revision as of 19:52, 25 June 2026

<> Lua API Reference

function getAutoAttachList() : StringList

Returns the Auto Attach Stringlist object.

The returned list contains process names that Cheat Engine can automatically attach to. The object can be controlled with the StringList routines and properties, but it should not be destroyed.

Function Parameters[edit]

This function has no parameters.

Returns[edit]

Stringlist — The Auto Attach string list object.

Examples[edit]

Get the Auto Attach list[edit]

1 local autoAttachList = getAutoAttachList()
2 
3 print("Auto Attach entries: " .. tostring(autoAttachList.Count))

Add a process name[edit]

1 local autoAttachList = getAutoAttachList()
2 
3 autoAttachList.add("game.exe")

Add a process name only if it is missing[edit]

1 local autoAttachList = getAutoAttachList()
2 local processName = "game.exe"
3 
4 if autoAttachList.IndexOf(processName) == -1 then
5   autoAttachList.add(processName)
6 end

Print all Auto Attach entries[edit]

1 local autoAttachList = getAutoAttachList()
2 
3 for i = 0, autoAttachList.Count - 1 do
4   print(autoAttachList[i])
5 end

Remove a process name[edit]

1 local autoAttachList = getAutoAttachList()
2 local index = autoAttachList.IndexOf("game.exe")
3 
4 if index ~= -1 then
5   autoAttachList.delete(index)
6 end

Clear the Auto Attach list[edit]

1 local autoAttachList = getAutoAttachList()
2 
3 autoAttachList.clear()

Set multiple Auto Attach entries[edit]

1 local autoAttachList = getAutoAttachList()
2 
3 autoAttachList.clear()
4 autoAttachList.add("game.exe")
5 autoAttachList.add("game_dx12.exe")
6 autoAttachList.add("game_win64_shipping.exe")

Use Text to replace the list[edit]

1 local autoAttachList = getAutoAttachList()
2 
3 autoAttachList.Text = [[game.exe
4 game_dx12.exe
5 game_win64_shipping.exe]]

Check whether a process is in the Auto Attach list[edit]

1 local autoAttachList = getAutoAttachList()
2 
3 if autoAttachList.IndexOf("game.exe") ~= -1 then
4   print("game.exe is in the Auto Attach list")
5 end

Main Pages

Core Lua documentation entry points

Lua
Script Engine