Difference between revisions of "Lua:Class:MemoryRecord"

From Cheat Engine
Jump to navigation Jump to search
m (Events / Callbacks: Strike-Through Fix)
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''MemoryRecord''' '''class''': ('''Inheritance''': ''[[Lua:Class:Object|Object]]'')
+
{{Class|'''class''' MemoryRecord ''':''' Object}}
  
The MemoryRecord class represents an entry in the Cheat Engine address list. 
+
The MemoryRecord class represents an entry in Cheat Engine's [[Lua:Class:Addresslist|Addresslist]].
Each memory record can represent an address, pointer, script, or group header, and provides access to its properties, children, hotkeys, and events.
 
  
== Properties ==
+
A memory record can represent a normal address, a pointer, an Auto Assembler script, a Lua script entry, a group header, or another cheat table entry. MemoryRecord objects expose properties for address handling, value display, activation, child records, dropdown lists, hotkeys, and event callbacks.
{|class="wikitable" style="width:100%"
+
 
! Property
+
===Inheritance===
! Type
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
! Description
+
!align="left"|Class
 +
!align="left"|Inherits From
 +
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
| ID
+
|MemoryRecord
| Integer
+
|[[Lua:Class:Object|Object]]
| Unique ID of the memory record.
+
|Represents one entry in the Cheat Engine address list.
 +
|}
 +
 
 +
===Properties===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Property
 +
!align="left"|Type
 +
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
| Index
+
|ID
| Integer
+
|Integer
| The index of this record in the address list (0 is top, ReadOnly).
+
|Unique ID of the memory record.
 
|-
 
|-
| Description
+
|Index
| String
+
|Integer
| The description of the memory record.
+
|The index of this record in the address list. 0 is the top entry. Read-only.
 
|-
 
|-
| Address
+
|Description
| String
+
|String
| Get/set the interpretable address string. Supports symbols, module+offset notation, and Lua expressions. See [[Lua:getAddress|getAddress]] and [[Lua:getNameFromAddress|getNameFromAddress]].
+
|The description of the memory record.
 
|-
 
|-
| AddressString
+
|Address
| String
+
|String
| The address string shown in CE (ReadOnly).
+
|Gets or sets the interpretable address string. This is useful for simple address settings and can contain symbols, module offsets, or expressions.
 
|-
 
|-
| OffsetCount
+
|AddressString
| Integer
+
|String
| The number of offsets. Set to 0 for a normal address.
+
|The address string shown in Cheat Engine. Read-only.
 
|-
 
|-
| Offset[index]
+
|OffsetCount
| Integer
+
|Integer
| Array to access each offset by index (0-based).
+
|The number of offsets. Set this to 0 for a normal non-pointer address.
 
|-
 
|-
| OffsetText[index]
+
|Offset[index]
| String
+
|Integer
| Array to access each offset using interpretable text style (0-based).
+
|Array-style access to each pointer offset.
 
|-
 
|-
| CurrentAddress
+
|OffsetText[index]
| Integer
+
|String
| The address the memory record points to (ReadOnly). Alias: '''CachedAddress'''. See [[Lua:getAddress|getAddress]] and [[Lua:readInteger|memory reading functions]].
+
|Array-style access to each pointer offset using interpretable text.
 
|-
 
|-
| CachedAddress
+
|CurrentAddress
| Integer
+
|Integer
| The cached/real address value (ReadOnly). Same as '''CurrentAddress'''.
+
|The resolved address the memory record points to.
 
|-
 
|-
| VarType
+
|VarType
| String
+
|String
| The variable type of this record as a string name (e.g., "vtByte", "vtDword"). See [[#Variable Types|Variable Types]] and [[Lua:VariableType|VariableType]].
+
|The variable type of this record as a string.
 
|-
 
|-
| Type
+
|Type
| Integer
+
|ValueType
| The variable type of this record as an integer constant (0-16). See [[#Variable Types|Variable Types]].
+
|The variable type of this record as a numeric ValueType constant.
 
|-
 
|-
| CustomTypeName
+
|CustomTypeName
| String
+
|String
| If the type is vtCustom, this contains the name of the CustomType.
+
|If the type is vtCustom, this contains the name of the custom type.
 
|-
 
|-
| CustomType
+
|Script
| [[Lua:Class:CustomType|CustomType]]
+
|String
| If the type is vtCustom, this contains the actual CustomType object (ReadOnly).
+
|If the type is vtAutoAssembler, this contains the Auto Assembler script.
 
|-
 
|-
| Script
+
|Value
| String
+
|String
| If the type is vtAutoAssembler, this contains the auto assembler script. See [[Lua:Auto Assembler|Auto Assembler]] and [[Lua:autoAssemble|autoAssemble]].
+
|The value in string form.
 
|-
 
|-
| Value
+
|NumericalValue
| String
+
|Number
| The value in string form. For direct memory access, see [[Lua:readInteger|readInteger]], [[Lua:readFloat|readFloat]], [[Lua:readString|readString]], [[Lua:writeInteger|writeInteger]], etc.
+
|The value in numerical form, or nil if it cannot be parsed as a number.
 
|-
 
|-
| DisplayValue
+
|Selected
| String
+
|Boolean
| The value as displayed in the address list, formatted according to display settings (ReadOnly).
+
|True if this record is selected. Read-only.
 
|-
 
|-
| NumericalValue
+
|Active
| Number
+
|Boolean
| The value in numerical form, or '''nil''' if it cannot be parsed.
+
|Set to true to activate or freeze the record. Set to false to deactivate or unfreeze it.
 
|-
 
|-
| Selected
+
|Color
| Boolean
+
|Integer
| True if selected (ReadOnly).
+
|The display color of the memory record.
 
|-
 
|-
| Active
+
|ShowAsHex
| Boolean
+
|Boolean
| Set to true to activate/freeze, false to deactivate/unfreeze.
+
|If true, the value is shown as hexadecimal.
 
|-
 
|-
| Color
+
|ShowAsSigned
| Integer
+
|Boolean
| The color of the memory record.
+
|If true, the value is shown as signed.
 
|-
 
|-
| ShowAsHex
+
|AllowIncrease
| Boolean
+
|Boolean
| Show value as hexadecimal.
+
|Allows the value to increase while frozen. Unfreezing resets this to false.
 
|-
 
|-
| ShowAsSigned
+
|AllowDecrease
| Boolean
+
|Boolean
| Show value as signed.
+
|Allows the value to decrease while frozen. Unfreezing resets this to false.
 
|-
 
|-
| AllowIncrease
+
|Collapsed
| Boolean
+
|Boolean
| Allow value increasing; unfreeze resets to false.
+
|Set to true to collapse this record or false to expand it. Use expand/collapse methods for recursive operations where available.
 
|-
 
|-
| AllowDecrease
+
|IsGroupHeader
| Boolean
+
|Boolean
| Allow value decreasing; unfreeze resets to false.
+
|Set to true if the record was created as a group header with no address or value information.
 
|-
 
|-
| Collapsed
+
|IsAddressGroupHeader
| Boolean
+
|Boolean
| Set to true to collapse this record, false to expand.
+
|Set to true if the record was created as a group header with an address.
 
|-
 
|-
| IsGroupHeader
+
|IsReadable
| Boolean
+
|Boolean
| True if the record is a group header with no address or value info.
+
|Set to false if the record contains an unreadable address. Read-only. This is only updated after the Value property has been accessed at least once.
 
|-
 
|-
| IsAddressGroupHeader
+
|Options
| Boolean
+
|String set
| True if the record is a group header with address.
+
|A string enclosed by square brackets containing comma-separated options. See [[#MemoryRecord Options|MemoryRecord Options]].
 
|-
 
|-
| IsReadableAddress
+
|DropDownLinked
| Boolean
+
|Boolean
| False if record contains an unreadable address (ReadOnly, set after value is accessed).
+
|True if the dropdown list refers to the dropdown list of another memory record.
 
|-
 
|-
| IsReadable
+
|DropDownLinkedMemrec
| Boolean
+
|String
| Alias for '''IsReadableAddress'''. False if record contains an unreadable address (ReadOnly).
+
|Description of the linked memory record, or an empty string if no record is linked.
 
|-
 
|-
| Options
+
|DropDownList
| String set
+
|[[Lua:Class:Stringlist|Stringlist]]
| A string enclosed by square brackets with options separated by commas (e.g., [moHideChildren,moActivateChildrenAsWell]). See [[#MemoryRecord Options|MemoryRecord Options]].
+
|List of "value:description" lines used for dropdown display.
 
|-
 
|-
| DropDownLinked
+
|DropDownReadOnly
| Boolean
+
|Boolean
| True if dropdown list refers to another memory record's list.
+
|True if manual user input is disallowed.
 
|-
 
|-
| DropDownLinkedMemrec
+
|DropDownDescriptionOnly
| String
+
|Boolean
| Description of linked memory record or empty string if not linked.
+
|If true, only the dropdown description is displayed.
 
|-
 
|-
| DropDownList
+
|DisplayAsDropDownListItem
| [[Lua:Class:Stringlist|Stringlist]]
+
|Boolean
| List of "value:description" lines. Use '''DropDownList.Text''' to set (the stringList field cannot be overwritten directly). See [[Lua:Class:Stringlist|Stringlist]].
+
|If true, the value is displayed as a dropdown list item.
 
|-
 
|-
| DropDownReadOnly
+
|DropDownCount
| Boolean
+
|Integer
| True if 'Disallow manual user input' is set.
+
|Equivalent to DropDownList.Count. Read-only.
 
|-
 
|-
| DropDownDescriptionOnly
+
|DropDownValue[index]
| Boolean
+
|String
| If true, only the description is shown (not the value).
+
|Array-style access to dropdown values. Read-only.
 
|-
 
|-
| DisplayAsDropDownListItem
+
|DropDownDescription[index]
| Boolean
+
|String
| If true, the value is displayed as a dropdown list item.
+
|Array-style access to dropdown descriptions. Read-only.
 
|-
 
|-
| DropDownCount
+
|Count
| Integer
+
|Integer
| Equivalent to '''DropDownList.Count''' (ReadOnly).
+
|The number of child records.
 
|-
 
|-
| DropDownValue[index]
+
|Child[index]
| String
+
|[[Lua:Class:MemoryRecord|MemoryRecord]]
| Array to access values in DropDownList by index (0-based, ReadOnly).
+
|Array-style access to child records.
 
|-
 
|-
| DropDownDescription[index]
+
|[index]
| String
+
|[[Lua:Class:MemoryRecord|MemoryRecord]]
| Array to access descriptions in DropDownList by index (0-based, ReadOnly).
+
|Default accessor for child records.
 
|-
 
|-
| Count
+
|Parent
| Integer
+
|[[Lua:Class:MemoryRecord|MemoryRecord]]
| Number of child records (ReadOnly).
+
|The parent memory record.
 
|-
 
|-
| Child[index]
+
|HotkeyCount
| MemoryRecord
+
|Integer
| Array to access child records by index (0-based).
+
|The number of hotkeys attached to this memory record.
 
|-
 
|-
| Parent
+
|Hotkey[index]
| MemoryRecord
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
| The parent of the memory record.
+
|Array-style access to hotkeys attached to this memory record.
 
|-
 
|-
| HotkeyCount
+
|Async
| Integer
+
|Boolean
| Number of hotkeys attached to this memory record (ReadOnly).
+
|Set to true if activating this entry should be asynchronous. This only applies to Auto Assembler or Lua script records.
 
|-
 
|-
| Hotkey[index]
+
|AsyncProcessing
| [[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
+
|Boolean
| Array to index the hotkeys by index (0-based). See [[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]].
+
|True when Async is true and the record is currently being processed.
 
|-
 
|-
| Async
+
|AsyncProcessingTime
| Boolean
+
|Qword
| Set to true if activating this entry will be asynchronous (only for AA/Lua scripts).
+
|The time in milliseconds that the record has been processing asynchronously.
 
|-
 
|-
| AsyncProcessing
+
|HasMouseOver
| Boolean
+
|Boolean
| True when async is true and it's being processed (ReadOnly).
+
|True if the mouse is currently over this memory record.
 
|-
 
|-
| AsyncProcessingTime
+
|DontSave
| Qword
+
|Boolean
| The time that it has been processing in milliseconds (ReadOnly).
+
|If true, this memory record and its children will not be saved.
 +
|}
 +
 
 +
===Type-Specific Properties===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Record Type
 +
!align="left"|Property
 +
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
| HasMouseOver
+
|vtString
| Boolean
+
|String.Size
| True if the mouse is currently over it (ReadOnly). Alias: '''HasMouseFocus'''.
+
|The number of characters in the string.
 
|-
 
|-
| HasMouseFocus
+
|vtString
| Boolean
+
|String.Unicode
| Alias for '''HasMouseOver'''. True if the mouse is currently over it (ReadOnly).
+
|If true, the string is treated as Unicode.
 
|-
 
|-
| LastAAExecutionFailed
+
|vtString
| Boolean
+
|String.Codepage
| True if the last auto assembler script execution failed (ReadOnly).
+
|If true, the string uses codepage handling.
 
|-
 
|-
| LastAAExecutionFailedReason
+
|vtBinary
| String
+
|Binary.Startbit
| Contains the error message if LastAAExecutionFailed is true (ReadOnly).
+
|The first bit to start reading from.
 
|-
 
|-
| ScriptHotKey
+
|vtBinary
| [[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
+
|Binary.Size
| The hotkey that was used to toggle this script (ReadOnly). Only set when a hotkey activates an auto-assembler script.
+
|The number of bits.
 
|-
 
|-
| DontSave
+
|vtByteArray
| Boolean
+
|Aob.Size
| Don't save this memoryrecord and its children.
+
|The number of bytes in the byte array.
|-
 
| OnActivate
 
| function
 
| Event callback: '''function(memoryrecord, before):boolean'''. See [[#Events / Callbacks|Events / Callbacks]].
 
|-
 
| OnDeactivate
 
| function
 
| Event callback: '''function(memoryrecord, before):boolean'''. See [[#Events / Callbacks|Events / Callbacks]].
 
|-
 
| OnDestroy
 
| function
 
| Event callback: '''function()'''. See [[#Events / Callbacks|Events / Callbacks]].
 
|-
 
| OnGetDisplayValue
 
| function
 
| Event callback: '''function(memoryrecord, valuestring):boolean,string'''. See [[#Events / Callbacks|Events / Callbacks]].
 
|-
 
| OnValueChanged
 
| function
 
| Event callback: '''function(memoryrecord, oldvalue, newvalue)'''. See [[#Events / Callbacks|Events / Callbacks]].
 
|-
 
| OnValueChangedByUser
 
| function
 
| Event callback: '''function(memoryrecord, oldvalue, newvalue)'''. See [[#Events / Callbacks|Events / Callbacks]].
 
 
|}
 
|}
  
=== Special Properties by Type ===
+
===Events===
 
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
When a MemoryRecord is set to specific variable types, additional properties become available through nested property accessors. These properties configure type-specific behavior.
+
!align="left"|Event
 
+
!align="left"|Callback
==== String Type Properties ====
+
!style="width: 80%;background-color:white;" align="left"|Description
 
 
When '''VarType''' = '''vtString''', the following properties are available:
 
 
 
{|class="wikitable" style="width:85%"
 
! Property
 
! Type
 
! Description
 
 
|-
 
|-
| String.Size
+
|OnActivate
| Integer
+
|function(memoryrecord, before, currentstate): boolean
| The length of the string in characters (or bytes for non-Unicode). If Unicode is enabled, each character is 2 bytes.
+
|Called when the memory record will change or has changed Active to true. If before is true, not returning true stops activation.
 
|-
 
|-
| String.Unicode
+
|OnDeactivate
| Boolean
+
|function(memoryrecord, before, currentstate): boolean
| If true, the string is treated as a Unicode (UTF-16) string. If false, it's an ANSI or codepage string. Setting this to true automatically sets Codepage to false.
+
|Called when the memory record will change or has changed Active to false. If before is true, not returning true stops deactivation.
 
|-
 
|-
| String.Codepage
+
|OnDestroy
| Boolean
+
|function()
| If true, the string uses the system codepage encoding (Windows codepage). If false, it's treated as standard ANSI. Setting this to true automatically sets Unicode to false.
+
|Called when the memory record is destroyed.
|}
 
 
 
'''Example:'''
 
<pre>
 
local mr = AddressList.createMemoryRecord()
 
mr.Type = vtString
 
mr.Address = "player_name"
 
mr.String.Size = 32          -- 32 characters max
 
mr.String.Unicode = true      -- Use Unicode encoding
 
-- mr.String.Codepage is now false (mutually exclusive with Unicode)
 
</pre>
 
 
 
==== Binary Type Properties ====
 
 
 
When '''VarType''' = '''vtBinary''', the following properties are available for bitfield manipulation:
 
 
 
{|class="wikitable" style="width:85%"
 
! Property
 
! Type
 
! Description
 
 
|-
 
|-
| Binary.Startbit
+
|OnGetDisplayValue
| Integer
+
|function(memoryrecord, valuestring): boolean, string
| The bit position (0-based) within the byte(s) where the bitfield starts. For example, Startbit=2 means the bitfield begins at bit 2.
+
|Called when rendering the value of a memory record. Return true and a string to override the displayed value.
 
|-
 
|-
| Binary.Size
+
|OnValueChanged
| Integer
+
|function(memoryrecord, oldvalue, newvalue)
| The number of bits in the bitfield (also called bitlength). For example, Size=4 means a 4-bit field.
+
|Called whenever the value of a memory record has changed.
|}
 
 
 
'''Note:''' The Binary type allows you to read/write specific bits within a memory address. The value is extracted by shifting and masking the underlying bytes.
 
 
 
'''Example:'''
 
<pre>
 
local flags = AddressList.createMemoryRecord()
 
flags.Type = vtBinary
 
flags.Address = "0x00400000"
 
flags.Binary.Startbit = 3    -- Start at bit 3
 
flags.Binary.Size = 2        -- Read 2 bits (bits 3-4)
 
-- This will read bits 3 and 4 from the byte at 0x00400000
 
-- If the byte is 0b00011000 (0x18), the value will be 0b11 (3)
 
</pre>
 
 
 
==== ByteArray Type Properties ====
 
 
 
When '''VarType''' = '''vtByteArray''', the following property is available:
 
 
 
{|class="wikitable" style="width:85%"
 
! Property
 
! Type
 
! Description
 
 
|-
 
|-
| Aob.Size
+
|OnValueChangedByUser
| Integer
+
|function(memoryrecord, oldvalue, newvalue)
| The number of bytes in the array. This determines how many bytes are read/written from memory.
+
|Called whenever the value of a memory record has been changed by the user.
 
|}
 
|}
  
'''Example:'''
+
===Methods===
<pre>
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
local signature = AddressList.createMemoryRecord()
+
!align="left"|Method
signature.Type = vtByteArray
+
!align="left"|Return Type
signature.Address = "module+1000"
+
!style="width: 80%;background-color:white;" align="left"|Description
signature.Aob.Size = 16      -- Read 16 bytes
 
signature.ShowAsHex = true    -- Display as hex bytes
 
-- Value might display as: 48 8B 05 12 34 56 78 90 AB CD EF 01 23 45 67 89
 
</pre>
 
 
 
== Variable Types ==
 
{|class="wikitable" style="width:60%"
 
! Constant
 
! Value
 
! Description
 
|-
 
| vtByte
 
| 0
 
| 1 byte (unsigned)
 
|-
 
| vtWord
 
| 1
 
| 2 bytes (unsigned)
 
|-
 
| vtDword
 
| 2
 
| 4 bytes (unsigned)
 
|-
 
| vtQword
 
| 3
 
| 8 bytes (unsigned)
 
|-
 
| vtSingle
 
| 4
 
| 4 bytes (float)
 
|-
 
| vtDouble
 
| 5
 
| 8 bytes (double/float)
 
 
|-
 
|-
| vtString
+
|getDescription()
| 6
+
|String
| String (ASCII)
+
|Returns the description of the memory record.
 
|-
 
|-
| vtUnicodeString<br>vtWideString
+
|setDescription(description)
| 7
+
|void
| Unicode string (Only used by autoguess)
+
|Sets the description of the memory record.
 
|-
 
|-
| vtByteArray
+
|getAddress()
| 8
+
|String, Table
| Array of bytes
+
|Returns the interpretable address string. If it is a pointer, it returns a second result containing a table with the offsets.
 
|-
 
|-
| vtBinary
+
|setAddress(address)
| 9
+
|void
| Binary (bitfield)
+
|Sets the interpretable address string.
 
|-
 
|-
| vtAll
+
|setAddress(address, offsets)
| 10
+
|void
| All types (used for scans)
+
|Sets the interpretable address string and pointer offsets.
 
|-
 
|-
| vtAutoAssembler
+
|getOffsetCount()
| 11
+
|Integer
| Auto Assembler script
+
|Returns the number of offsets for this memory record.
 
|-
 
|-
| vtPointer
+
|setOffsetCount(count)
| 12
+
|void
| Pointer (Only used by autoguess and structures)
+
|Sets the number of offsets.
 
|-
 
|-
| vtCustom
+
|getOffset(index)
| 13
+
|Integer
| Custom type
+
|Returns the offset at the given index.
 
|-
 
|-
| vtGrouped
+
|setOffset(index, value)
| 14
+
|void
| Grouped type
+
|Sets the offset at the given index.
 
|-
 
|-
| vtByteArrays
+
|getCurrentAddress()
| 15
+
|Integer
| Multiple byte arrays
+
|Returns the current resolved address as an integer.
 
|-
 
|-
| vtCodePageString
+
|appendToEntry(memrec)
| 16
+
|void
| Code page string
+
|Appends this memory record to the given memory record as a child.
|}
 
 
 
== MemoryRecord Options ==
 
 
 
The following options can be set in the '''Options''' property of a MemoryRecord. 
 
The value is a string enclosed in square brackets, with options separated by commas (e.g., <code>[moHideChildren,moActivateChildrenAsWell]</code>).
 
 
 
{|class="wikitable" style="width:60%"
 
! Option
 
! Description
 
 
|-
 
|-
| moHideChildren
+
|getHotkey(index)
| Hides the child records of this memory record.
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
 +
|Returns the hotkey at the given index.
 
|-
 
|-
| moActivateChildrenAsWell
+
|getHotkeyByID(id)
| Activating this record also activates its children.
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
 +
|Returns the hotkey with the given ID.
 
|-
 
|-
| moDeactivateChildrenAsWell
+
|reinterpret()
| Deactivating this record also deactivates its children.
+
|void
 +
|Reinterprets the memory record.
 
|-
 
|-
| moRecursiveSetValue
+
|createHotkey(keys, action, value, description)
| Setting the value will also set the value of all children recursively.
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
 +
|Creates a hotkey object for this memory record.
 
|-
 
|-
| moAllowManualCollapseAndExpand
+
|disableWithoutExecute()
| Allows the user to manually collapse or expand this record in the address list.
+
|void
 +
|Disables the entry without executing its disable section.
 
|-
 
|-
| moManualExpandCollapse
+
|beginEdit()
| Enables manual expand/collapse behavior for this record.
+
|void
 +
|Call this before a long edit sequence. This prevents the record from being deleted while editing.
 
|-
 
|-
| moAlwaysHideChildren
+
|endEdit()
| Always hides the children, regardless of other settings.
+
|void
 +
|Marks the end of a long edit sequence started with beginEdit().
 
|}
 
|}
  
== Methods ==
+
===Value Types===
{|class="wikitable" style="width:100%"
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
! Method
+
!align="left"|Constant
! Parameters
+
!align="left"|Value
! Returns
+
!style="width: 80%;background-color:white;" align="left"|Description
! Description
 
 
|-
 
|-
| getDescription
+
|vtByte
| None
+
|0
| String
+
|1-byte integer.
| Gets the description.
 
 
|-
 
|-
| setDescription
+
|vtWord
| String
+
|1
| None
+
|2-byte integer.
| Sets the description.
 
 
|-
 
|-
| getAddress
+
|vtDword
| None
+
|2
| String [, Table]
+
|4-byte integer.
| Returns the interpretable address string. For pointer records, returns two values: the base address string and a table of offsets (1-indexed).
 
 
|-
 
|-
| setAddress
+
|vtQword
| String [, Table]
+
|3
| None
+
|8-byte integer.
| Sets the interpretable address string. Optional second parameter: offset table (1-indexed) for pointer records.
 
 
|-
 
|-
| getOffsetCount
+
|vtSingle
| None
+
|4
| Integer
+
|Single-precision float.
| Returns the number of offsets.
 
 
|-
 
|-
| setOffsetCount
+
|vtDouble
| Integer
+
|5
| None
+
|Double-precision float.
| Sets the number of offsets.
 
 
|-
 
|-
| getOffset
+
|vtString
| Integer (index)
+
|6
| Integer
+
|String.
| Gets the offset at the given index (0-based).
 
 
|-
 
|-
| setOffset
+
|vtUnicodeString
| Integer (index), Integer (value)
+
|7
| None
+
|Unicode string.
| Sets the offset at the given index (0-based).
 
 
|-
 
|-
| getCurrentAddress
+
|vtByteArray
| None
+
|8
| Integer
+
|Array of bytes.
| Returns the current address as an integer.
 
 
|-
 
|-
| appendToEntry
+
|vtBinary
| MemoryRecord
+
|9
| None
+
|Binary bitfield.
| Appends the current memory record to the given memory record as a child.
 
 
|-
 
|-
| getHotkey
+
|vtAll
| Integer (index)
+
|10
| [[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
+
|All value types.
| Returns the hotkey from the hotkey array at the given index (0-based).
 
 
|-
 
|-
| getHotkeyByID
+
|vtAutoAssembler
| Integer (id)
+
|11
| [[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
+
|Auto Assembler script.
| Returns the hotkey with the given id.
 
 
|-
 
|-
| reinterpret
+
|vtPointer
| None
+
|12
| None
+
|Pointer type.
| Reinterprets the memory record's address.
 
 
|-
 
|-
| createHotkey
+
|vtCustom
| Table (keys), Integer (action), String (value, OPTIONAL), String (description, OPTIONAL)
+
|13
| [[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
+
|Custom type.
| Creates a hotkey object and registers it. The '''keys''' table is 1-indexed and contains up to 5 virtual key codes (e.g., {0x70} for F1, {0x11, 0x70} for Ctrl+F1). See [[Lua:Defines|Virtual Key Codes]]. The '''action''' is one of the [[#Hotkey Actions|hotkey action constants]] (0-7). Returns the created and registered hotkey object.
 
 
|-
 
|-
| disableWithoutExecute
+
|vtGrouped
| None
+
|14
| None
+
|Grouped type.
| Sets the entry to disabled without executing the disable section (for AA scripts).
 
 
|-
 
|-
| beginEdit
+
|vtByteArrays
| None
+
|15
| None
+
|Multiple byte arrays.
| Call when you wish to take a long time to edit a record. Prevents automatic updates.
 
 
|-
 
|-
| endEdit
+
|vtCodePageString
| None
+
|16
| None
+
|Codepage string.
| Marks the end of your long edit sequence. Re-enables automatic updates.
 
|-
 
| delete
 
| None
 
| None
 
| Deletes this memory record (frees the object).
 
 
|}
 
|}
  
== Hotkey Actions ==
+
===MemoryRecord Options===
 
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
The following constants define the actions a hotkey can perform:
+
!align="left"|Option
 
+
!style="width: 80%;background-color:white;" align="left"|Description
{|class="wikitable" style="width:60%"
 
! Constant
 
! Value
 
! Description
 
|-
 
| mrhToggleActivation
 
| 0
 
| Toggle the active state of the memory record.
 
 
|-
 
|-
| mrhToggleActivationAllowIncrease
+
|moHideChildren
| 1
+
|Hides the child records of this memory record.
| Toggle activation and allow the value to increase while frozen.
 
 
|-
 
|-
| mrhToggleActivationAllowDecrease
+
|moActivateChildrenAsWell
| 2
+
|Activating this record also activates its children.
| Toggle activation and allow the value to decrease while frozen.
 
 
|-
 
|-
| mrhActivate
+
|moDeactivateChildrenAsWell
| 3
+
|Deactivating this record also deactivates its children.
| Activate (freeze) the memory record.
 
 
|-
 
|-
| mrhDeactivate
+
|moRecursiveSetValue
| 4
+
|Setting the value also sets the value of all children recursively.
| Deactivate (unfreeze) the memory record.
 
 
|-
 
|-
| mrhSetValue
+
|moAllowManualCollapseAndExpand
| 5
+
|Allows the user to manually collapse and expand this record.
| Set the memory record to the specified value.
 
 
|-
 
|-
| mrhIncreaseValue
+
|moManualExpandCollapse
| 6
+
|Enables manual expand/collapse behavior.
| Increase the current value by the specified amount.
 
 
|-
 
|-
| mrhDecreaseValue
+
|moAlwaysHideChildren
| 7
+
|Always hides the child records.
| Decrease the current value by the specified amount.
 
 
|}
 
|}
  
== Events / Callbacks ==
+
===Hotkey Actions===
{|class="wikitable" style="width:100%"
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
! Event
+
!align="left"|Constant
! Parameters
+
!align="left"|Value
! Description
+
!style="width: 80%;background-color:white;" align="left"|Description
 +
|-
 +
|mrhToggleActivation
 +
|0
 +
|Toggles the active state of the memory record.
 
|-
 
|-
| OnActivate
+
|mrhToggleActivationAllowIncrease
| function(memoryrecord, before):boolean
+
|1
| Called when the memoryrecord will change (or changed) Active to true. If '''before''' is true, not returning true will cause the activation to stop. The '''before''' parameter indicates if this is called before (true) or after (false) activation.
+
|Toggles activation and allows the value to increase while frozen.
 
|-
 
|-
| OnDeactivate
+
|mrhToggleActivationAllowDecrease
| function(memoryrecord, before):boolean
+
|2
| Called when the memoryrecord will change (or changed) Active to false. If '''before''' is true, not returning true will cause the deactivation to stop. The '''before''' parameter indicates if this is called before (true) or after (false) deactivation.
+
|Toggles activation and allows the value to decrease while frozen.
 
|-
 
|-
| OnDestroy
+
|mrhActivate
| function()
+
|3
| Called when the memoryrecord is destroyed.
+
|Activates the memory record.
 
|-
 
|-
| <s>OnActivationFailure</s>
+
|mrhDeactivate
| <s>function(memoryrecord, reason, reasonText)</s>
+
|4
| '''Deprecated/Not Implemented''': This callback was mentioned in older documentation but is not exposed in the Lua API. To detect activation failures, check the '''LastAAExecutionFailed''' property after attempting to activate an auto-assembler script.
+
|Deactivates the memory record.
 
|-
 
|-
| OnGetDisplayValue
+
|mrhSetValue
| function(memoryrecord, valuestring):boolean,string
+
|5
| Called when rendering the value of a memory record. The function receives the memoryrecord and current value string. Return true and a modified string to override the displayed value, or false to use the default.
+
|Sets the memory record to the specified value.
 
|-
 
|-
| OnValueChanged
+
|mrhIncreaseValue
| function(memoryrecord, oldvalue, newvalue)
+
|6
| Called whenever the value of a memory record has changed. Parameters are the memoryrecord object, old value string, and new value string.
+
|Increases the current value by the specified amount.
 
|-
 
|-
| OnValueChangedByUser
+
|mrhDecreaseValue
| function(memoryrecord, oldvalue, newvalue)
+
|7
| Called whenever the value of a memory record has changed by the user (not by the freezer). Parameters are the memoryrecord object, old value string, and new value string.
+
|Decreases the current value by the specified amount.
 
|}
 
|}
  
== Global Events ==
+
===Global Events===
 +
{{CodeBox|'''function''' onMemRecPreExecute(''memoryrecord'', ''newstate'') ''':''' boolean}}
  
'''Note:''' These global event functions can be defined in your Lua scripts to monitor all memory record activation/deactivation events globally.
+
If defined, this function is called before a memory record action is performed. The Active property is about to change to newstate.
  
<pre>
+
{{CodeBox|'''function''' onMemRecPostExecute(''memoryrecord'', ''newstate'', ''succeeded'') ''':''' void}}
function onMemRecPreExecute(memoryrecord, newstate BOOLEAN)
+
 
  -- Called before action is performed. Active property is about to change to newState.
+
If defined, this function is called after a memory record action has been performed. If succeeded is true, the Active state changed to newstate.
   -- Return false to cancel the operation.
+
 
 +
===Examples===
 +
 
 +
====Get the first MemoryRecord====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList[0]
 +
 
 +
if record ~= nil then
 +
  print(record.Description)
 +
   print(record.Value)
 
end
 
end
 +
</syntaxhighlight>
 +
 +
====Create a simple 4-byte record====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 +
record.Description = "Player Health"
 +
record.Address = "game.exe+12345"
 +
record.Type = vtDword
 +
record.Value = "1000"
 +
</syntaxhighlight>
 +
 +
====Create a float record====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 +
record.Description = "Player Speed"
 +
record.Address = "game.exe+23456"
 +
record.Type = vtSingle
 +
record.Value = "1.5"
 +
</syntaxhighlight>
 +
 +
====Create a pointer record with setAddress====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 +
record.Description = "Player Health Pointer"
 +
record.Type = vtDword
 +
record.setAddress("player_base", {0x10, 0x8, 0x120})
  
function onMemRecPostExecute(memoryrecord, newState BOOLEAN, succeeded BOOLEAN)
+
print(string.format("%X", record.CurrentAddress))
   -- Called after action is performed. Active property was supposed to change to newState.
+
</syntaxhighlight>
   -- If 'succeeded' is true, Active state has changed and is newState.
+
 
 +
====Create a pointer record with Offset properties====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Player Ammo Pointer"
 +
record.Type = vtDword
 +
record.Address = "player_base"
 +
record.OffsetCount = 3
 +
record.Offset[0] = 0x10
 +
record.Offset[1] = 0x8
 +
record.Offset[2] = 0x120
 +
</syntaxhighlight>
 +
 
 +
====Use OffsetText for interpretable offsets====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Pointer With Text Offsets"
 +
record.Type = vtDword
 +
record.Address = "player_base"
 +
record.OffsetCount = 2
 +
record.OffsetText[0] = "10"
 +
record.OffsetText[1] = "someSymbol+20"
 +
</syntaxhighlight>
 +
 
 +
====Read the resolved current address====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Player Health")
 +
 
 +
if record ~= nil then
 +
   local address = record.getCurrentAddress()
 +
 
 +
   print(string.format("%X", address))
 
end
 
end
</pre>
+
</syntaxhighlight>
  
== Examples ==
+
====Activate and deactivate a record====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Player Health")
  
=== Basic Usage ===
+
if record ~= nil then
<pre>
+
  record.Active = true
-- Get the first memory record in the address list
+
  sleep(1000)
local mr = AddressList[0]
+
  record.Active = false
 +
end
 +
</syntaxhighlight>
  
-- Print some basic properties
+
====Disable without executing the disable section====
print("ID:", mr.ID)
+
<syntaxhighlight lang="lua" line>
print("Description:", mr.Description)
+
local record = AddressList.getMemoryRecordByDescription("Infinite Ammo")
print("Address:", mr.Address)
 
print("Current Value:", mr.Value)
 
print("Active:", mr.Active)
 
  
-- Change the value and activate the record
+
if record ~= nil then
mr.Value = "999"
+
  record.disableWithoutExecute()
mr.Active = true
+
end
</pre>
+
</syntaxhighlight>
 +
 
 +
====Show a value as hexadecimal====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
  
=== Working with Pointers ===
+
record.Description = "Flags"
<pre>
+
record.Address = "game.exe+4000"
-- Create a pointer-based memory record
+
record.Type = vtDword
local mr = AddressList.createMemoryRecord()
+
record.ShowAsHex = true
mr.Description = "Player Health"
+
</syntaxhighlight>
  
-- Set as a 4-byte pointer with offsets
+
====Use a string MemoryRecord====
mr.Type = vtDword
+
<syntaxhighlight lang="lua" line>
mr.setAddress("player_base", {0x10, 0x8, 0x120})  -- Base + offsets (1-indexed table)
+
local record = AddressList.createMemoryRecord()
  
-- Alternative: Set offsets individually
+
record.Description = "Player Name"
mr.Address = "player_base"
+
record.Type = vtString
mr.OffsetCount = 3
+
record.Address = "player_name"
mr.Offset[0] = 0x10
+
record.String.Size = 32
mr.Offset[1] = 0x8
+
record.String.Unicode = true
mr.Offset[2] = 0x120
+
</syntaxhighlight>
  
-- Or use interpretable offset text
+
====Use a binary MemoryRecord====
mr.OffsetText[0] = "10"
+
<syntaxhighlight lang="lua" line>
mr.OffsetText[1] = "8"
+
local record = AddressList.createMemoryRecord()
mr.OffsetText[2] = "120"
 
  
print("Resolved Address:", string.format("%X", mr.CurrentAddress))
+
record.Description = "Player Flags"
</pre>
+
record.Type = vtBinary
 +
record.Address = "game.exe+5000"
 +
record.Binary.Startbit = 2
 +
record.Binary.Size = 4
 +
</syntaxhighlight>
  
=== Using Special Type Properties ===
+
====Use an array-of-bytes MemoryRecord====
<pre>
+
<syntaxhighlight lang="lua" line>
-- String type
+
local record = AddressList.createMemoryRecord()
local strRecord = AddressList.createMemoryRecord()
 
strRecord.Description = "Player Name"
 
strRecord.Type = vtString
 
strRecord.Address = "0x00400000"
 
strRecord.String.Size = 20
 
strRecord.String.Unicode = false
 
  
-- Binary type (bitfield)
+
record.Description = "Instruction Bytes"
local bitRecord = AddressList.createMemoryRecord()
+
record.Type = vtByteArray
bitRecord.Description = "Flags"
+
record.Address = "game.exe+6000"
bitRecord.Type = vtBinary
+
record.Aob.Size = 16
bitRecord.Address = "0x00500000"
+
record.ShowAsHex = true
bitRecord.Binary.Startbit = 2
+
</syntaxhighlight>
bitRecord.Binary.Size = 4
 
  
-- Array of Bytes
+
====Use a dropdown list====
local aobRecord = AddressList.createMemoryRecord()
+
<syntaxhighlight lang="lua" line>
aobRecord.Description = "Byte Array"
+
local record = AddressList.createMemoryRecord()
aobRecord.Type = vtByteArray
 
aobRecord.Address = "0x00600000"
 
aobRecord.Aob.Size = 16
 
</pre>
 
  
=== Using Dropdown Lists ===
+
record.Description = "Game State"
<pre>
+
record.Type = vtByte
local mr = AddressList.createMemoryRecord()
+
record.Address = "game_state"
mr.Description = "Game State"
 
mr.Type = vtByte
 
mr.Address = "game_state"
 
  
-- Add dropdown values
+
record.DropDownList.Text = [[0:Menu
mr.DropDownList.Text = [[0:Menu
 
 
1:Playing
 
1:Playing
 
2:Paused
 
2:Paused
3:GameOver]]
+
3:Game Over]]
 +
 
 +
record.DropDownReadOnly = true
 +
record.DropDownDescriptionOnly = true
 +
record.DisplayAsDropDownListItem = true
 +
</syntaxhighlight>
  
mr.DropDownReadOnly = true
+
====Read dropdown values====
mr.DropDownDescriptionOnly = true
+
<syntaxhighlight lang="lua" line>
mr.DisplayAsDropDownListItem = true
+
local record = AddressList.getMemoryRecordByDescription("Game State")
  
-- Access dropdown items
+
if record ~= nil then
for i = 0, mr.DropDownCount - 1 do
+
  for i = 0, record.DropDownCount - 1 do
  print(mr.DropDownValue[i], ":", mr.DropDownDescription[i])
+
    print(record.DropDownValue[i] .. " = " .. record.DropDownDescription[i])
 +
  end
 
end
 
end
</pre>
+
</syntaxhighlight>
 +
 
 +
====Link a dropdown list to another record====
 +
<syntaxhighlight lang="lua" line>
 +
local source = AddressList.createMemoryRecord()
 +
source.Description = "Shared States"
 +
source.DropDownList.Text = [[0:Disabled
 +
1:Enabled]]
 +
 
 +
local target = AddressList.createMemoryRecord()
 +
target.Description = "Current State"
 +
target.Type = vtByte
 +
target.Address = "state_value"
 +
target.DropDownLinked = true
 +
target.DropDownLinkedMemrec = "Shared States"
 +
target.DisplayAsDropDownListItem = true
 +
</syntaxhighlight>
 +
 
 +
====Create a group header====
 +
<syntaxhighlight lang="lua" line>
 +
local group = AddressList.createMemoryRecord()
 +
 
 +
group.Description = "Player Stats"
 +
group.IsGroupHeader = true
 +
group.Options = "[moHideChildren]"
 +
</syntaxhighlight>
  
=== Event Callbacks ===
+
====Append records as children====
<pre>
+
<syntaxhighlight lang="lua" line>
local mr = AddressList.getMemoryRecordByDescription("Player Health")
+
local group = AddressList.createMemoryRecord()
 +
group.Description = "Player Stats"
 +
group.IsGroupHeader = true
  
-- OnActivate callback (called before/after activation)
+
local health = AddressList.createMemoryRecord()
mr.OnActivate = function(memrec, before)
+
health.Description = "Health"
  if before then
+
health.Type = vtDword
    print("About to activate:", memrec.Description)
+
health.Address = "player_base+10"
    -- Return false to prevent activation
+
health.appendToEntry(group)
     return true
+
 
  else
+
local ammo = AddressList.createMemoryRecord()
     print("Activated:", memrec.Description)
+
ammo.Description = "Ammo"
    return true
+
ammo.Type = vtDword
 +
ammo.Address = "player_base+14"
 +
ammo.appendToEntry(group)
 +
</syntaxhighlight>
 +
 
 +
====Iterate through child records====
 +
<syntaxhighlight lang="lua" line>
 +
local group = AddressList.getMemoryRecordByDescription("Player Stats")
 +
 
 +
if group ~= nil then
 +
  for i = 0, group.Count - 1 do
 +
     local child = group.Child[i]
 +
 
 +
     print(child.Description .. " = " .. child.Value)
 
   end
 
   end
 
end
 
end
 +
</syntaxhighlight>
 +
 +
====Use parent and child accessors====
 +
<syntaxhighlight lang="lua" line>
 +
local child = AddressList.getMemoryRecordByDescription("Health")
 +
 +
if child ~= nil and child.Parent ~= nil then
 +
  print("Parent: " .. child.Parent.Description)
 +
end
 +
</syntaxhighlight>
 +
 +
====Create an Auto Assembler script record====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 +
record.Description = "Infinite Ammo"
 +
record.Type = vtAutoAssembler
 +
record.Script = [[
 +
[ENABLE]
 +
alloc(newmem,1024)
 +
 +
newmem:
 +
  ret
  
-- OnValueChanged callback
+
[DISABLE]
mr.OnValueChanged = function(memrec, oldvalue, newvalue)
+
dealloc(newmem)
  print(string.format("%s changed from %s to %s",
+
]]
     memrec.Description, oldvalue, newvalue))
+
</syntaxhighlight>
 +
 
 +
====Activate an Auto Assembler script and check failure====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Infinite Ammo")
 +
 
 +
if record ~= nil then
 +
  record.Active = true
 +
 
 +
  if record.LastAAExecutionFailed then
 +
     print(record.LastAAExecutionFailedReason)
 +
  end
 
end
 
end
 +
</syntaxhighlight>
  
-- OnGetDisplayValue callback (customize display)
+
====Use asynchronous activation====
mr.OnGetDisplayValue = function(memrec, value)
+
<syntaxhighlight lang="lua" line>
   local numValue = tonumber(value)
+
local record = AddressList.getMemoryRecordByDescription("Slow Script")
   if numValue then
+
 
     return true, string.format("%d HP", numValue)
+
if record ~= nil then
 +
  record.Async = true
 +
   record.Active = true
 +
 
 +
   while record.AsyncProcessing do
 +
     print("Processing for " .. tostring(record.AsyncProcessingTime) .. " ms")
 +
    sleep(100)
 
   end
 
   end
  return false  -- Use default display
 
 
end
 
end
</pre>
+
</syntaxhighlight>
 +
 
 +
====Create a hotkey====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("God Mode")
 +
 
 +
if record ~= nil then
 +
  local hotkey = record.createHotkey({VK_F1}, mrhToggleActivation, "", "Toggle God Mode")
 +
 
 +
  print(hotkey.Description)
 +
end
 +
</syntaxhighlight>
  
=== Creating Hotkeys ===
+
====Create a hotkey that sets a value====
<pre>
+
<syntaxhighlight lang="lua" line>
local mr = AddressList.getMemoryRecordByDescription("God Mode")
+
local record = AddressList.getMemoryRecordByDescription("Health")
  
-- Create a hotkey: F1 to toggle
+
if record ~= nil then
local keys = {0x70}  -- VK_F1 (1-indexed table)
+
  record.createHotkey({VK_CONTROL, VK_F2}, mrhSetValue, "100", "Set health to 100")
local action = 0    -- mrhToggleActivation
+
end
local hotkey = mr.createHotkey(keys, action, "", "Toggle God Mode")
+
</syntaxhighlight>
  
print("Hotkey ID:", hotkey.ID)
+
====List hotkeys====
print("Hotkey String:", hotkey.HotkeyString)  -- e.g., "F1"
+
<syntaxhighlight lang="lua" line>
print("Owner Description:", hotkey.Owner.Description)
+
local record = AddressList.getMemoryRecordByDescription("God Mode")
  
-- Create a hotkey: Ctrl+F2 to set value
+
if record ~= nil then
local keys2 = {0x11, 0x71}  -- VK_CONTROL + VK_F2
+
  for i = 0, record.HotkeyCount - 1 do
local action2 = 5          -- mrhSetValue
+
    local hotkey = record.Hotkey[i]
local hotkey2 = mr.createHotkey(keys2, action2, "100", "Set to 100")
 
  
-- Access hotkeys by index or ID
+
    print(hotkey.ID .. ": " .. hotkey.Description)
print("Hotkey count:", mr.HotkeyCount)
+
  end
for i = 0, mr.HotkeyCount - 1 do
 
  local hk = mr.Hotkey[i]
 
  print(string.format("Hotkey %d: %s - %s", hk.ID, hk.HotkeyString, hk.Description))
 
 
end
 
end
 +
</syntaxhighlight>
 +
 +
====Use beginEdit and endEdit====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList[0]
  
-- Get specific hotkey by ID
+
if record ~= nil then
local specificHotkey = mr.getHotkeyByID(hotkey.ID)
+
  record.beginEdit()
  
-- Manually trigger a hotkey
+
  record.Description = "Edited Record"
hotkey.doHotkey()
+
  record.Address = "game.exe+7777"
</pre>
+
  record.Type = vtQword
 +
  record.ShowAsHex = true
  
=== Working with Children ===
+
  record.endEdit()
<pre>
+
end
-- Create a parent group
+
</syntaxhighlight>
local parent = AddressList.createMemoryRecord()
 
parent.Description = "Player Stats"
 
parent.IsGroupHeader = true
 
  
-- Create children
+
====Handle activation====
local health = AddressList.createMemoryRecord()
+
<syntaxhighlight lang="lua" line>
health.Description = "Health"
+
local record = AddressList.getMemoryRecordByDescription("God Mode")
health.Type = vtDword
 
health.Address = "player_base+10"
 
health.appendToEntry(parent)
 
  
local mana = AddressList.createMemoryRecord()
+
if record ~= nil then
mana.Description = "Mana"
+
  record.OnActivate = function(memrec, before, currentstate)
mana.Type = vtDword
+
    if before then
mana.Address = "player_base+14"
+
      print("About to activate: " .. memrec.Description)
mana.appendToEntry(parent)
+
      return true
 +
    end
  
-- Iterate through children
+
    print("Activated: " .. memrec.Description)
print("Child count:", parent.Count)
+
    return true
for i = 0, parent.Count - 1 do
+
   end
  local child = parent.Child[i]
 
   print("Child:", child.Description, "Value:", child.Value)
 
 
end
 
end
 +
</syntaxhighlight>
 +
 +
====Block activation====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Dangerous Script")
  
-- Set options
+
if record ~= nil then
parent.Options = "[moActivateChildrenAsWell,moDeactivateChildrenAsWell]"
+
  record.OnActivate = function(memrec, before, currentstate)
</pre>
+
    if before then
 +
      print("Activation blocked")
 +
      return false
 +
    end
  
=== Auto Assembler Scripts ===
+
    return true
<pre>
+
  end
local script = AddressList.createMemoryRecord()
+
end
script.Description = "Infinite Ammo"
+
</syntaxhighlight>
script.Type = vtAutoAssembler
+
 
script.Script = [[
+
====Handle deactivation====
[ENABLE]
+
<syntaxhighlight lang="lua" line>
aobscan(ammo_code,FF 0D * * * * 83 C4 08)
+
local record = AddressList.getMemoryRecordByDescription("God Mode")
alloc(newmem,32)
 
  
label(code)
+
if record ~= nil then
label(return)
+
  record.OnDeactivate = function(memrec, before, currentstate)
 +
    if before then
 +
      print("About to deactivate: " .. memrec.Description)
 +
      return true
 +
    end
  
newmem:
+
    print("Deactivated: " .. memrec.Description)
code:
+
    return true
   // Don't decrease ammo
+
   end
  nop
+
end
  nop
+
</syntaxhighlight>
  nop
 
  nop
 
  nop
 
  nop
 
  jmp return
 
  
ammo_code:
+
====Override the displayed value====
  jmp newmem
+
<syntaxhighlight lang="lua" line>
return:
+
local record = AddressList.getMemoryRecordByDescription("Health")
registersymbol(ammo_code)
 
  
[DISABLE]
+
if record ~= nil then
ammo_code:
+
   record.OnGetDisplayValue = function(memrec, valuestring)
   db FF 0D * * * * 83 C4 08
+
    return true, valuestring .. " HP"
unregistersymbol(ammo_code)
+
  end
dealloc(newmem)
+
end
]]
+
</syntaxhighlight>
  
-- Activate the script
+
====Handle value changes====
script.Active = true
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Health")
  
-- Check if execution failed
+
if record ~= nil then
if script.LastAAExecutionFailed then
+
  record.OnValueChanged = function(memrec, oldvalue, newvalue)
  print("Script failed:", script.LastAAExecutionFailedReason)
+
    print(memrec.Description .. " changed from " .. oldvalue .. " to " .. newvalue)
 +
  end
 
end
 
end
</pre>
+
</syntaxhighlight>
 +
 
 +
====Handle user value changes====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Health")
  
=== Async Script Execution ===
+
if record ~= nil then
<pre>
+
  record.OnValueChangedByUser = function(memrec, oldvalue, newvalue)
local asyncScript = AddressList.createMemoryRecord()
+
    print("User changed " .. memrec.Description .. " from " .. oldvalue .. " to " .. newvalue)
asyncScript.Description = "Slow Script"
+
  end
asyncScript.Type = vtAutoAssembler
+
end
asyncScript.Async = true  -- Enable async processing
+
</syntaxhighlight>
asyncScript.Script = [[
 
[ENABLE]
 
// ... complex AA script ...
 
  
[DISABLE]
+
====Handle destroy====
// ... disable code ...
+
<syntaxhighlight lang="lua" line>
]]
+
local record = AddressList.getMemoryRecordByDescription("Temporary Record")
  
asyncScript.Active = true
+
if record ~= nil then
 +
  record.OnDestroy = function()
 +
    print("MemoryRecord destroyed")
 +
  end
  
-- Check processing status
+
  record.destroy()
if asyncScript.AsyncProcessing then
 
  print("Processing... Time:", asyncScript.AsyncProcessingTime, "ms")
 
 
end
 
end
</pre>
+
</syntaxhighlight>
 +
 
 +
====Use global pre/post execute events====
 +
<syntaxhighlight lang="lua" line>
 +
function onMemRecPreExecute(memoryrecord, newstate)
 +
  print("Before execution: " .. memoryrecord.Description .. " -> " .. tostring(newstate))
  
=== Editing Records Efficiently ===
+
  return true
<pre>
+
end
local mr = AddressList[0]
 
  
-- Begin edit to prevent updates during batch changes
+
function onMemRecPostExecute(memoryrecord, newstate, succeeded)
mr.beginEdit()
+
  print("After execution: " .. memoryrecord.Description)
 +
  print("New state: " .. tostring(newstate))
 +
  print("Succeeded: " .. tostring(succeeded))
 +
end
 +
</syntaxhighlight>
  
mr.Description = "Modified Entry"
+
====Do not save a record====
mr.Address = "new_address"
+
<syntaxhighlight lang="lua" line>
mr.Type = vtQword
+
local record = AddressList.createMemoryRecord()
mr.ShowAsHex = true
 
  
-- End edit to re-enable updates
+
record.Description = "Temporary Runtime Record"
mr.endEdit()
+
record.Address = "game.exe+1234"
</pre>
+
record.Type = vtDword
 +
record.DontSave = true
 +
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
  
=== Related Functions ===
+
{{Forms}}
* [[Lua:getMainForm|getMainForm]] - Get the main Cheat Engine form
 
* [[Lua:getAddressList|getAddressList]] - Get the address list containing memory records
 
* [[Lua:readInteger|readInteger]] - Read integer values from memory
 
* [[Lua:readFloat|readFloat]] - Read float values from memory
 
* [[Lua:readString|readString]] - Read string values from memory
 
* [[Lua:writeInteger|writeInteger]] - Write integer values to memory
 
* [[Lua:writeFloat|writeFloat]] - Write float values to memory
 
* [[Lua:writeString|writeString]] - Write string values to memory
 
* [[Lua:AOBScan|AOBScan]] - Scan for array of bytes patterns
 
* [[Lua:autoAssemble|autoAssemble]] - Execute auto assembler scripts
 
 
 
=== Related Classes ===
 
* [[Lua:Class:Addresslist|Addresslist]] - The address list that contains memory records
 
* [[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]] - Hotkey objects attached to memory records
 
* [[Lua:Class:CustomType|CustomType]] - Custom variable type definitions
 
* [[Lua:Class:Stringlist|Stringlist]] - String list used for dropdown values
 
* [[Lua:Class:Object|Object]] - Base class for all Lua-exposed objects
 

Latest revision as of 18:48, 25 June 2026

{} Class

class MemoryRecord : Object

The MemoryRecord class represents an entry in Cheat Engine's Addresslist.

A memory record can represent a normal address, a pointer, an Auto Assembler script, a Lua script entry, a group header, or another cheat table entry. MemoryRecord objects expose properties for address handling, value display, activation, child records, dropdown lists, hotkeys, and event callbacks.

Inheritance[edit]

Class Inherits From Description
MemoryRecord Object Represents one entry in the Cheat Engine address list.

Properties[edit]

Property Type Description
ID Integer Unique ID of the memory record.
Index Integer The index of this record in the address list. 0 is the top entry. Read-only.
Description String The description of the memory record.
Address String Gets or sets the interpretable address string. This is useful for simple address settings and can contain symbols, module offsets, or expressions.
AddressString String The address string shown in Cheat Engine. Read-only.
OffsetCount Integer The number of offsets. Set this to 0 for a normal non-pointer address.
Offset[index] Integer Array-style access to each pointer offset.
OffsetText[index] String Array-style access to each pointer offset using interpretable text.
CurrentAddress Integer The resolved address the memory record points to.
VarType String The variable type of this record as a string.
Type ValueType The variable type of this record as a numeric ValueType constant.
CustomTypeName String If the type is vtCustom, this contains the name of the custom type.
Script String If the type is vtAutoAssembler, this contains the Auto Assembler script.
Value String The value in string form.
NumericalValue Number The value in numerical form, or nil if it cannot be parsed as a number.
Selected Boolean True if this record is selected. Read-only.
Active Boolean Set to true to activate or freeze the record. Set to false to deactivate or unfreeze it.
Color Integer The display color of the memory record.
ShowAsHex Boolean If true, the value is shown as hexadecimal.
ShowAsSigned Boolean If true, the value is shown as signed.
AllowIncrease Boolean Allows the value to increase while frozen. Unfreezing resets this to false.
AllowDecrease Boolean Allows the value to decrease while frozen. Unfreezing resets this to false.
Collapsed Boolean Set to true to collapse this record or false to expand it. Use expand/collapse methods for recursive operations where available.
IsGroupHeader Boolean Set to true if the record was created as a group header with no address or value information.
IsAddressGroupHeader Boolean Set to true if the record was created as a group header with an address.
IsReadable Boolean Set to false if the record contains an unreadable address. Read-only. This is only updated after the Value property has been accessed at least once.
Options String set A string enclosed by square brackets containing comma-separated options. See MemoryRecord Options.
DropDownLinked Boolean True if the dropdown list refers to the dropdown list of another memory record.
DropDownLinkedMemrec String Description of the linked memory record, or an empty string if no record is linked.
DropDownList Stringlist List of "value:description" lines used for dropdown display.
DropDownReadOnly Boolean True if manual user input is disallowed.
DropDownDescriptionOnly Boolean If true, only the dropdown description is displayed.
DisplayAsDropDownListItem Boolean If true, the value is displayed as a dropdown list item.
DropDownCount Integer Equivalent to DropDownList.Count. Read-only.
DropDownValue[index] String Array-style access to dropdown values. Read-only.
DropDownDescription[index] String Array-style access to dropdown descriptions. Read-only.
Count Integer The number of child records.
Child[index] MemoryRecord Array-style access to child records.
[index] MemoryRecord Default accessor for child records.
Parent MemoryRecord The parent memory record.
HotkeyCount Integer The number of hotkeys attached to this memory record.
Hotkey[index] MemoryRecordHotkey Array-style access to hotkeys attached to this memory record.
Async Boolean Set to true if activating this entry should be asynchronous. This only applies to Auto Assembler or Lua script records.
AsyncProcessing Boolean True when Async is true and the record is currently being processed.
AsyncProcessingTime Qword The time in milliseconds that the record has been processing asynchronously.
HasMouseOver Boolean True if the mouse is currently over this memory record.
DontSave Boolean If true, this memory record and its children will not be saved.

Type-Specific Properties[edit]

Record Type Property Description
vtString String.Size The number of characters in the string.
vtString String.Unicode If true, the string is treated as Unicode.
vtString String.Codepage If true, the string uses codepage handling.
vtBinary Binary.Startbit The first bit to start reading from.
vtBinary Binary.Size The number of bits.
vtByteArray Aob.Size The number of bytes in the byte array.

Events[edit]

Event Callback Description
OnActivate function(memoryrecord, before, currentstate): boolean Called when the memory record will change or has changed Active to true. If before is true, not returning true stops activation.
OnDeactivate function(memoryrecord, before, currentstate): boolean Called when the memory record will change or has changed Active to false. If before is true, not returning true stops deactivation.
OnDestroy function() Called when the memory record is destroyed.
OnGetDisplayValue function(memoryrecord, valuestring): boolean, string Called when rendering the value of a memory record. Return true and a string to override the displayed value.
OnValueChanged function(memoryrecord, oldvalue, newvalue) Called whenever the value of a memory record has changed.
OnValueChangedByUser function(memoryrecord, oldvalue, newvalue) Called whenever the value of a memory record has been changed by the user.

Methods[edit]

Method Return Type Description
getDescription() String Returns the description of the memory record.
setDescription(description) void Sets the description of the memory record.
getAddress() String, Table Returns the interpretable address string. If it is a pointer, it returns a second result containing a table with the offsets.
setAddress(address) void Sets the interpretable address string.
setAddress(address, offsets) void Sets the interpretable address string and pointer offsets.
getOffsetCount() Integer Returns the number of offsets for this memory record.
setOffsetCount(count) void Sets the number of offsets.
getOffset(index) Integer Returns the offset at the given index.
setOffset(index, value) void Sets the offset at the given index.
getCurrentAddress() Integer Returns the current resolved address as an integer.
appendToEntry(memrec) void Appends this memory record to the given memory record as a child.
getHotkey(index) MemoryRecordHotkey Returns the hotkey at the given index.
getHotkeyByID(id) MemoryRecordHotkey Returns the hotkey with the given ID.
reinterpret() void Reinterprets the memory record.
createHotkey(keys, action, value, description) MemoryRecordHotkey Creates a hotkey object for this memory record.
disableWithoutExecute() void Disables the entry without executing its disable section.
beginEdit() void Call this before a long edit sequence. This prevents the record from being deleted while editing.
endEdit() void Marks the end of a long edit sequence started with beginEdit().

Value Types[edit]

Constant Value Description
vtByte 0 1-byte integer.
vtWord 1 2-byte integer.
vtDword 2 4-byte integer.
vtQword 3 8-byte integer.
vtSingle 4 Single-precision float.
vtDouble 5 Double-precision float.
vtString 6 String.
vtUnicodeString 7 Unicode string.
vtByteArray 8 Array of bytes.
vtBinary 9 Binary bitfield.
vtAll 10 All value types.
vtAutoAssembler 11 Auto Assembler script.
vtPointer 12 Pointer type.
vtCustom 13 Custom type.
vtGrouped 14 Grouped type.
vtByteArrays 15 Multiple byte arrays.
vtCodePageString 16 Codepage string.

MemoryRecord Options[edit]

Option Description
moHideChildren Hides the child records of this memory record.
moActivateChildrenAsWell Activating this record also activates its children.
moDeactivateChildrenAsWell Deactivating this record also deactivates its children.
moRecursiveSetValue Setting the value also sets the value of all children recursively.
moAllowManualCollapseAndExpand Allows the user to manually collapse and expand this record.
moManualExpandCollapse Enables manual expand/collapse behavior.
moAlwaysHideChildren Always hides the child records.

Hotkey Actions[edit]

Constant Value Description
mrhToggleActivation 0 Toggles the active state of the memory record.
mrhToggleActivationAllowIncrease 1 Toggles activation and allows the value to increase while frozen.
mrhToggleActivationAllowDecrease 2 Toggles activation and allows the value to decrease while frozen.
mrhActivate 3 Activates the memory record.
mrhDeactivate 4 Deactivates the memory record.
mrhSetValue 5 Sets the memory record to the specified value.
mrhIncreaseValue 6 Increases the current value by the specified amount.
mrhDecreaseValue 7 Decreases the current value by the specified amount.

Global Events[edit]

<> Lua API Reference

function onMemRecPreExecute(memoryrecord, newstate) : boolean

If defined, this function is called before a memory record action is performed. The Active property is about to change to newstate.

<> Lua API Reference

function onMemRecPostExecute(memoryrecord, newstate, succeeded) : void

If defined, this function is called after a memory record action has been performed. If succeeded is true, the Active state changed to newstate.

Examples[edit]

Get the first MemoryRecord[edit]

1 local record = AddressList[0]
2 
3 if record ~= nil then
4   print(record.Description)
5   print(record.Value)
6 end

Create a simple 4-byte record[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Player Health"
4 record.Address = "game.exe+12345"
5 record.Type = vtDword
6 record.Value = "1000"

Create a float record[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Player Speed"
4 record.Address = "game.exe+23456"
5 record.Type = vtSingle
6 record.Value = "1.5"

Create a pointer record with setAddress[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Player Health Pointer"
4 record.Type = vtDword
5 record.setAddress("player_base", {0x10, 0x8, 0x120})
6 
7 print(string.format("%X", record.CurrentAddress))

Create a pointer record with Offset properties[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Player Ammo Pointer"
4 record.Type = vtDword
5 record.Address = "player_base"
6 record.OffsetCount = 3
7 record.Offset[0] = 0x10
8 record.Offset[1] = 0x8
9 record.Offset[2] = 0x120

Use OffsetText for interpretable offsets[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Pointer With Text Offsets"
4 record.Type = vtDword
5 record.Address = "player_base"
6 record.OffsetCount = 2
7 record.OffsetText[0] = "10"
8 record.OffsetText[1] = "someSymbol+20"

Read the resolved current address[edit]

1 local record = AddressList.getMemoryRecordByDescription("Player Health")
2 
3 if record ~= nil then
4   local address = record.getCurrentAddress()
5 
6   print(string.format("%X", address))
7 end

Activate and deactivate a record[edit]

1 local record = AddressList.getMemoryRecordByDescription("Player Health")
2 
3 if record ~= nil then
4   record.Active = true
5   sleep(1000)
6   record.Active = false
7 end

Disable without executing the disable section[edit]

1 local record = AddressList.getMemoryRecordByDescription("Infinite Ammo")
2 
3 if record ~= nil then
4   record.disableWithoutExecute()
5 end

Show a value as hexadecimal[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Flags"
4 record.Address = "game.exe+4000"
5 record.Type = vtDword
6 record.ShowAsHex = true

Use a string MemoryRecord[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Player Name"
4 record.Type = vtString
5 record.Address = "player_name"
6 record.String.Size = 32
7 record.String.Unicode = true

Use a binary MemoryRecord[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Player Flags"
4 record.Type = vtBinary
5 record.Address = "game.exe+5000"
6 record.Binary.Startbit = 2
7 record.Binary.Size = 4

Use an array-of-bytes MemoryRecord[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Instruction Bytes"
4 record.Type = vtByteArray
5 record.Address = "game.exe+6000"
6 record.Aob.Size = 16
7 record.ShowAsHex = true

Use a dropdown list[edit]

 1 local record = AddressList.createMemoryRecord()
 2 
 3 record.Description = "Game State"
 4 record.Type = vtByte
 5 record.Address = "game_state"
 6 
 7 record.DropDownList.Text = [[0:Menu
 8 1:Playing
 9 2:Paused
10 3:Game Over]]
11 
12 record.DropDownReadOnly = true
13 record.DropDownDescriptionOnly = true
14 record.DisplayAsDropDownListItem = true

Read dropdown values[edit]

1 local record = AddressList.getMemoryRecordByDescription("Game State")
2 
3 if record ~= nil then
4   for i = 0, record.DropDownCount - 1 do
5     print(record.DropDownValue[i] .. " = " .. record.DropDownDescription[i])
6   end
7 end

Link a dropdown list to another record[edit]

 1 local source = AddressList.createMemoryRecord()
 2 source.Description = "Shared States"
 3 source.DropDownList.Text = [[0:Disabled
 4 1:Enabled]]
 5 
 6 local target = AddressList.createMemoryRecord()
 7 target.Description = "Current State"
 8 target.Type = vtByte
 9 target.Address = "state_value"
10 target.DropDownLinked = true
11 target.DropDownLinkedMemrec = "Shared States"
12 target.DisplayAsDropDownListItem = true

Create a group header[edit]

1 local group = AddressList.createMemoryRecord()
2 
3 group.Description = "Player Stats"
4 group.IsGroupHeader = true
5 group.Options = "[moHideChildren]"

Append records as children[edit]

 1 local group = AddressList.createMemoryRecord()
 2 group.Description = "Player Stats"
 3 group.IsGroupHeader = true
 4 
 5 local health = AddressList.createMemoryRecord()
 6 health.Description = "Health"
 7 health.Type = vtDword
 8 health.Address = "player_base+10"
 9 health.appendToEntry(group)
10 
11 local ammo = AddressList.createMemoryRecord()
12 ammo.Description = "Ammo"
13 ammo.Type = vtDword
14 ammo.Address = "player_base+14"
15 ammo.appendToEntry(group)

Iterate through child records[edit]

1 local group = AddressList.getMemoryRecordByDescription("Player Stats")
2 
3 if group ~= nil then
4   for i = 0, group.Count - 1 do
5     local child = group.Child[i]
6 
7     print(child.Description .. " = " .. child.Value)
8   end
9 end

Use parent and child accessors[edit]

1 local child = AddressList.getMemoryRecordByDescription("Health")
2 
3 if child ~= nil and child.Parent ~= nil then
4   print("Parent: " .. child.Parent.Description)
5 end

Create an Auto Assembler script record[edit]

 1 local record = AddressList.createMemoryRecord()
 2 
 3 record.Description = "Infinite Ammo"
 4 record.Type = vtAutoAssembler
 5 record.Script = [[
 6 [ENABLE]
 7 alloc(newmem,1024)
 8 
 9 newmem:
10   ret
11 
12 [DISABLE]
13 dealloc(newmem)
14 ]]

Activate an Auto Assembler script and check failure[edit]

1 local record = AddressList.getMemoryRecordByDescription("Infinite Ammo")
2 
3 if record ~= nil then
4   record.Active = true
5 
6   if record.LastAAExecutionFailed then
7     print(record.LastAAExecutionFailedReason)
8   end
9 end

Use asynchronous activation[edit]

 1 local record = AddressList.getMemoryRecordByDescription("Slow Script")
 2 
 3 if record ~= nil then
 4   record.Async = true
 5   record.Active = true
 6 
 7   while record.AsyncProcessing do
 8     print("Processing for " .. tostring(record.AsyncProcessingTime) .. " ms")
 9     sleep(100)
10   end
11 end

Create a hotkey[edit]

1 local record = AddressList.getMemoryRecordByDescription("God Mode")
2 
3 if record ~= nil then
4   local hotkey = record.createHotkey({VK_F1}, mrhToggleActivation, "", "Toggle God Mode")
5 
6   print(hotkey.Description)
7 end

Create a hotkey that sets a value[edit]

1 local record = AddressList.getMemoryRecordByDescription("Health")
2 
3 if record ~= nil then
4   record.createHotkey({VK_CONTROL, VK_F2}, mrhSetValue, "100", "Set health to 100")
5 end

List hotkeys[edit]

1 local record = AddressList.getMemoryRecordByDescription("God Mode")
2 
3 if record ~= nil then
4   for i = 0, record.HotkeyCount - 1 do
5     local hotkey = record.Hotkey[i]
6 
7     print(hotkey.ID .. ": " .. hotkey.Description)
8   end
9 end

Use beginEdit and endEdit[edit]

 1 local record = AddressList[0]
 2 
 3 if record ~= nil then
 4   record.beginEdit()
 5 
 6   record.Description = "Edited Record"
 7   record.Address = "game.exe+7777"
 8   record.Type = vtQword
 9   record.ShowAsHex = true
10 
11   record.endEdit()
12 end

Handle activation[edit]

 1 local record = AddressList.getMemoryRecordByDescription("God Mode")
 2 
 3 if record ~= nil then
 4   record.OnActivate = function(memrec, before, currentstate)
 5     if before then
 6       print("About to activate: " .. memrec.Description)
 7       return true
 8     end
 9 
10     print("Activated: " .. memrec.Description)
11     return true
12   end
13 end

Block activation[edit]

 1 local record = AddressList.getMemoryRecordByDescription("Dangerous Script")
 2 
 3 if record ~= nil then
 4   record.OnActivate = function(memrec, before, currentstate)
 5     if before then
 6       print("Activation blocked")
 7       return false
 8     end
 9 
10     return true
11   end
12 end

Handle deactivation[edit]

 1 local record = AddressList.getMemoryRecordByDescription("God Mode")
 2 
 3 if record ~= nil then
 4   record.OnDeactivate = function(memrec, before, currentstate)
 5     if before then
 6       print("About to deactivate: " .. memrec.Description)
 7       return true
 8     end
 9 
10     print("Deactivated: " .. memrec.Description)
11     return true
12   end
13 end

Override the displayed value[edit]

1 local record = AddressList.getMemoryRecordByDescription("Health")
2 
3 if record ~= nil then
4   record.OnGetDisplayValue = function(memrec, valuestring)
5     return true, valuestring .. " HP"
6   end
7 end

Handle value changes[edit]

1 local record = AddressList.getMemoryRecordByDescription("Health")
2 
3 if record ~= nil then
4   record.OnValueChanged = function(memrec, oldvalue, newvalue)
5     print(memrec.Description .. " changed from " .. oldvalue .. " to " .. newvalue)
6   end
7 end

Handle user value changes[edit]

1 local record = AddressList.getMemoryRecordByDescription("Health")
2 
3 if record ~= nil then
4   record.OnValueChangedByUser = function(memrec, oldvalue, newvalue)
5     print("User changed " .. memrec.Description .. " from " .. oldvalue .. " to " .. newvalue)
6   end
7 end

Handle destroy[edit]

1 local record = AddressList.getMemoryRecordByDescription("Temporary Record")
2 
3 if record ~= nil then
4   record.OnDestroy = function()
5     print("MemoryRecord destroyed")
6   end
7 
8   record.destroy()
9 end

Use global pre/post execute events[edit]

 1 function onMemRecPreExecute(memoryrecord, newstate)
 2   print("Before execution: " .. memoryrecord.Description .. " -> " .. tostring(newstate))
 3 
 4   return true
 5 end
 6 
 7 function onMemRecPostExecute(memoryrecord, newstate, succeeded)
 8   print("After execution: " .. memoryrecord.Description)
 9   print("New state: " .. tostring(newstate))
10   print("Succeeded: " .. tostring(succeeded))
11 end

Do not save a record[edit]

1 local record = AddressList.createMemoryRecord()
2 
3 record.Description = "Temporary Runtime Record"
4 record.Address = "game.exe+1234"
5 record.Type = vtDword
6 record.DontSave = true

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes