Lua:Class:Object

From Cheat Engine
Jump to navigation Jump to search

{} 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

Class Inherits From Description
Object None Base class for Lua-exposed objects.

Properties

Property Type Description
ClassName String The name of the object's class. Read-only.

Methods

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

Read the ClassName property

1 local form = createForm(false)
2 
3 print(form.ClassName)
4 
5 form.destroy()

Use getClassName

1 local form = createForm(false)
2 
3 local className = form.getClassName()
4 
5 print(className)
6 
7 form.destroy()

Check an object's class

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

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

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

 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

1 local form = createForm(false)
2 
3 form.Caption = "Temporary Form"
4 
5 form.destroy()

Destroy an object after use

1 local font = createFont()
2 
3 font.Name = "Consolas"
4 font.Size = 12
5 
6 print(font.Name)
7 
8 font.destroy()

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes