Difference between revisions of "Lua:Class:Object"
Jump to navigation
Jump to search
m (moved Object to Lua:Class:Object) |
(Major overhaul of the post.) |
||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | + | {{Class|'''class''' Object}} | |
| − | + | The Object class is the base class for Lua-exposed Cheat Engine objects. | |
| − | + | It provides basic class information, field and method address lookup helpers, and object destruction. | |
| − | |||
| − | |||
| − | == | + | ===Inheritance=== |
| − | ; | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
| − | + | !align="left"|Class | |
| + | !align="left"|Inherits From | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |Object | ||
| + | |None | ||
| + | |Base class for Lua-exposed objects. | ||
| + | |} | ||
| − | ; destroy() | + | ===Properties=== |
| − | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | |
| + | !align="left"|Property | ||
| + | !align="left"|Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |ClassName | ||
| + | |String | ||
| + | |The name of the object's class. Read-only. | ||
| + | |} | ||
| + | |||
| + | ===Methods=== | ||
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Method | ||
| + | !align="left"|Return Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |getClassName() | ||
| + | |String | ||
| + | |Returns the class name of the object. | ||
| + | |- | ||
| + | |fieldAddress(fieldname) | ||
| + | |Integer | ||
| + | |Returns the address of the specified field. | ||
| + | |- | ||
| + | |methodAddress(methodname) | ||
| + | |Integer | ||
| + | |Returns the address of the specified method. | ||
| + | |- | ||
| + | |methodName(address) | ||
| + | |String | ||
| + | |Returns the method name for the specified method address. | ||
| + | |- | ||
| + | |destroy() | ||
| + | |void | ||
| + | |Destroys the object. | ||
| + | |} | ||
| + | |||
| + | ===Examples=== | ||
| + | |||
| + | ====Read the ClassName property==== | ||
| + | <syntaxhighlight lang="lua" line> | ||
| + | local form = createForm(false) | ||
| + | |||
| + | print(form.ClassName) | ||
| + | |||
| + | form.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Use getClassName==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local form = createForm(false) | ||
| + | |||
| + | local className = form.getClassName() | ||
| + | |||
| + | print(className) | ||
| + | |||
| + | form.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Check an object's class==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local form = createForm(false) | ||
| + | |||
| + | if form.getClassName() == "TCEForm" then | ||
| + | print("This is a Cheat Engine form") | ||
| + | end | ||
| + | |||
| + | form.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Get the address of a field==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local form = createForm(false) | ||
| + | |||
| + | local address = form.fieldAddress("FName") | ||
| + | |||
| + | if address ~= nil and address ~= 0 then | ||
| + | print(string.format("%X", address)) | ||
| + | end | ||
| + | |||
| + | form.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Get the address of a method==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3"> | ||
| + | local form = createForm(false) | ||
| + | |||
| + | local address = form.methodAddress("Show") | ||
| + | |||
| + | if address ~= nil and address ~= 0 then | ||
| + | print(string.format("%X", address)) | ||
| + | end | ||
| + | |||
| + | form.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Get a method name from an address==== | ||
| + | <syntaxhighlight lang="lua" line highlight="3,6"> | ||
| + | local form = createForm(false) | ||
| + | |||
| + | local address = form.methodAddress("Show") | ||
| + | |||
| + | if address ~= nil and address ~= 0 then | ||
| + | local name = form.methodName(address) | ||
| + | |||
| + | print(name) | ||
| + | end | ||
| + | |||
| + | form.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Destroy an object==== | ||
| + | <syntaxhighlight lang="lua" line highlight="5"> | ||
| + | local form = createForm(false) | ||
| + | |||
| + | form.Caption = "Temporary Form" | ||
| + | |||
| + | form.destroy() | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | ====Destroy an object after use==== | ||
| + | <syntaxhighlight lang="lua" line highlight="8"> | ||
| + | local font = createFont() | ||
| + | |||
| + | font.Name = "Consolas" | ||
| + | font.Size = 12 | ||
| + | |||
| + | print(font.Name) | ||
| + | |||
| + | font.destroy() | ||
| + | </syntaxhighlight> | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | + | {{Forms}} | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 20:12, 25 June 2026
The Object class is the base class for Lua-exposed Cheat Engine objects.
It provides basic class information, field and method address lookup helpers, and object destruction.
Contents
Inheritance[edit]
| Class | Inherits From | Description |
|---|---|---|
| Object | None | Base class for Lua-exposed objects. |
Properties[edit]
| Property | Type | Description |
|---|---|---|
| ClassName | String | The name of the object's class. Read-only. |
Methods[edit]
| Method | Return Type | Description |
|---|---|---|
| getClassName() | String | Returns the class name of the object. |
| fieldAddress(fieldname) | Integer | Returns the address of the specified field. |
| methodAddress(methodname) | Integer | Returns the address of the specified method. |
| methodName(address) | String | Returns the method name for the specified method address. |
| destroy() | void | Destroys the object. |
Examples[edit]
Read the ClassName property[edit]
1 local form = createForm(false)
2
3 print(form.ClassName)
4
5 form.destroy()
Use getClassName[edit]
1 local form = createForm(false)
2
3 local className = form.getClassName()
4
5 print(className)
6
7 form.destroy()
Check an object's class[edit]
1 local form = createForm(false)
2
3 if form.getClassName() == "TCEForm" then
4 print("This is a Cheat Engine form")
5 end
6
7 form.destroy()
Get the address of a field[edit]
1 local form = createForm(false)
2
3 local address = form.fieldAddress("FName")
4
5 if address ~= nil and address ~= 0 then
6 print(string.format("%X", address))
7 end
8
9 form.destroy()
Get the address of a method[edit]
1 local form = createForm(false)
2
3 local address = form.methodAddress("Show")
4
5 if address ~= nil and address ~= 0 then
6 print(string.format("%X", address))
7 end
8
9 form.destroy()
Get a method name from an address[edit]
1 local form = createForm(false)
2
3 local address = form.methodAddress("Show")
4
5 if address ~= nil and address ~= 0 then
6 local name = form.methodName(address)
7
8 print(name)
9 end
10
11 form.destroy()
Destroy an object[edit]
1 local form = createForm(false)
2
3 form.Caption = "Temporary Form"
4
5 form.destroy()
Destroy an object after use[edit]
1 local font = createFont()
2
3 font.Name = "Consolas"
4 font.Size = 12
5
6 print(font.Name)
7
8 font.destroy()