Lua:getPropertyList

From Cheat Engine
Revision as of 00:23, 27 June 2026 by Leunsel (talk | contribs) (Major overhaul of the post.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<> Lua API Reference

function getPropertyList(class) : StringList

Returns a StringList object containing all published properties of the specified class.

The returned list must be freed when it is no longer needed.

Not every class with properties exposes them as published properties. For example, some classes may have usable properties that do not appear in the returned list.

Function Parameters[edit]

Parameter Type Description
class Object / Class The class or object whose published properties should be listed.

Returns[edit]

StringList — A list containing the published property names of the specified class.

Examples[edit]

Get published properties of the main form[edit]

1 local form = getMainForm()
2 local properties = getPropertyList(form)
3 
4 for i = 0, properties.Count - 1 do
5   print(properties[i])
6 end
7 
8 properties.destroy()

Check whether a property exists[edit]

 1 local form = getMainForm()
 2 local properties = getPropertyList(form)
 3 
 4 local hasCaption = false
 5 
 6 for i = 0, properties.Count - 1 do
 7   if properties[i] == "Caption" then
 8     hasCaption = true
 9     break
10   end
11 end
12 
13 print("Has Caption: " .. tostring(hasCaption))
14 
15 properties.destroy()

List properties of a created control[edit]

 1 local form = createForm(false)
 2 local button = createButton(form)
 3 local properties = getPropertyList(button)
 4 
 5 for i = 0, properties.Count - 1 do
 6   print(properties[i])
 7 end
 8 
 9 properties.destroy()
10 form.destroy()

Use pcall to ensure the list is destroyed[edit]

 1 local form = getMainForm()
 2 local properties = getPropertyList(form)
 3 
 4 local ok, err = pcall(function()
 5   for i = 0, properties.Count - 1 do
 6     print(properties[i])
 7   end
 8 end)
 9 
10 properties.destroy()
11 
12 if not ok then
13   print(err)
14 end

Handle classes without published properties[edit]

 1 local list = createStringlist()
 2 local properties = getPropertyList(list)
 3 
 4 if properties.Count == 0 then
 5   print("No published properties found")
 6 else
 7   for i = 0, properties.Count - 1 do
 8     print(properties[i])
 9   end
10 end
11 
12 properties.destroy()
13 list.destroy()

Copy property names into another StringList[edit]

 1 local form = getMainForm()
 2 local properties = getPropertyList(form)
 3 local copy = createStringlist()
 4 
 5 for i = 0, properties.Count - 1 do
 6   copy.add(properties[i])
 7 end
 8 
 9 print("Copied properties: " .. tostring(copy.Count))
10 
11 copy.destroy()
12 properties.destroy()

Main Pages

Core Lua documentation entry points

Lua
Script Engine