Difference between revisions of "Lua:Class:MemoryRecord"

From Cheat Engine
Jump to navigation Jump to search
m (Link to GenericHotkey)
m
 
(4 intermediate revisions by 3 users 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
 +
|-
 +
|MemoryRecord
 +
|[[Lua:Class:Object|Object]]
 +
|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
 +
|-
 +
|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.
 
|-
 
|-
| ID
+
|OffsetCount
| Integer
+
|Integer
| Unique ID of the memory record.
+
|The number of offsets. Set this to 0 for a normal non-pointer address.
 
|-
 
|-
| Index
+
|Offset[index]
| Integer
+
|Integer
| The index of this record in the address list (0 is top, ReadOnly).
+
|Array-style access to each pointer offset.
 
|-
 
|-
| Description
+
|OffsetText[index]
| String
+
|String
| The description of the memory record.
+
|Array-style access to each pointer offset using interpretable text.
 
|-
 
|-
| Address
+
|CurrentAddress
| String
+
|Integer
| Get/set the interpretable address string.
+
|The resolved address the memory record points to.
 
|-
 
|-
| AddressString
+
|VarType
| String
+
|String
| The address string shown in CE (ReadOnly).
+
|The variable type of this record as a string.
 
|-
 
|-
| OffsetCount
+
|Type
| Integer
+
|ValueType
| The number of offsets. Set to 0 for a normal address.
+
|The variable type of this record as a numeric ValueType constant.
 
|-
 
|-
| Offset[]
+
|CustomTypeName
| Integer
+
|String
| Array to access each offset.
+
|If the type is vtCustom, this contains the name of the custom type.
 
|-
 
|-
| OffsetText[]
+
|Script
| String
+
|String
| Array to access each offset using interpretable text style.
+
|If the type is vtAutoAssembler, this contains the Auto Assembler script.
 
|-
 
|-
| CurrentAddress
+
|Value
| Integer
+
|String
| The address the memory record points to.
+
|The value in string form.
 
|-
 
|-
| VarType
+
|NumericalValue
| ValueType (string)
+
|Number
| The variable type of this record. See vtByte to vtCustom.
+
|The value in numerical form, or nil if it cannot be parsed as a number.
 
|-
 
|-
| Type
+
|Selected
| ValueType (number)
+
|Boolean
| The variable type of this record. See vtByte to vtCustom.
+
|True if this record is selected. Read-only.
 
|-
 
|-
| CustomTypeName
+
|Active
| String
+
|Boolean
| If the type is vtCustom, this contains the name of the CustomType.
+
|Set to true to activate or freeze the record. Set to false to deactivate or unfreeze it.
 
|-
 
|-
| Script
+
|Color
| String
+
|Integer
| If the type is vtAutoAssembler, this contains the auto assembler script.
+
|The display color of the memory record.
 
|-
 
|-
| Value
+
|ShowAsHex
| String
+
|Boolean
| The value in string form.
+
|If true, the value is shown as hexadecimal.
 
|-
 
|-
| NumericalValue
+
|ShowAsSigned
| Number
+
|Boolean
| The value in numerical form, or nil if it cannot be parsed.
+
|If true, the value is shown as signed.
 
|-
 
|-
| Selected
+
|AllowIncrease
| Boolean
+
|Boolean
| True if selected (ReadOnly).
+
|Allows the value to increase while frozen. Unfreezing resets this to false.
 
|-
 
|-
| Active
+
|AllowDecrease
| Boolean
+
|Boolean
| Set to true to activate/freeze, false to deactivate/unfreeze.
+
|Allows the value to decrease while frozen. Unfreezing resets this to false.
 
|-
 
|-
| Color
+
|Collapsed
| Integer
+
|Boolean
| The color of the memory record.
+
|Set to true to collapse this record or false to expand it. Use expand/collapse methods for recursive operations where available.
 
|-
 
|-
| ShowAsHex
+
|IsGroupHeader
| Boolean
+
|Boolean
| Show value as hexadecimal.
+
|Set to true if the record was created as a group header with no address or value information.
 
|-
 
|-
| ShowAsSigned
+
|IsAddressGroupHeader
| Boolean
+
|Boolean
| Show value as signed.
+
|Set to true if the record was created as a group header with an address.
 
|-
 
|-
| AllowIncrease
+
|IsReadable
| Boolean
+
|Boolean
| Allow value increasing; unfreeze resets to false.
+
|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.
 
|-
 
|-
| AllowDecrease
+
|Options
| Boolean
+
|String set
| Allow value decreasing; unfreeze resets to false.
+
|A string enclosed by square brackets containing comma-separated options. See [[#MemoryRecord Options|MemoryRecord Options]].
 
|-
 
|-
| Collapsed
+
|DropDownLinked
| Boolean
+
|Boolean
| Set to true to collapse this record, false to expand.
+
|True if the dropdown list refers to the dropdown list of another memory record.
 
|-
 
|-
| IsGroupHeader
+
|DropDownLinkedMemrec
| Boolean
+
|String
| True if the record is a group header with no address or value info.
+
|Description of the linked memory record, or an empty string if no record is linked.
 
|-
 
|-
| IsAddressGroupHeader
+
|DropDownList
| Boolean
+
|[[Lua:Class:Stringlist|Stringlist]]
| True if the record is a group header with address.
+
|List of "value:description" lines used for dropdown display.
 
|-
 
|-
| IsReadable
+
|DropDownReadOnly
| Boolean
+
|Boolean
| False if record contains an unreadable address (ReadOnly, set after value is accessed).
+
|True if manual user input is disallowed.
 
|-
 
|-
| Options
+
|DropDownDescriptionOnly
| String set
+
|Boolean
| A string enclosed by square brackets with options separated by commas (e.g., [moHideChildren,moActivateChildrenAsWell]).
+
|If true, only the dropdown description is displayed.
 
|-
 
|-
| DropDownLinked
+
|DisplayAsDropDownListItem
| Boolean
+
|Boolean
| True if dropdown list refers to another memory record's list.
+
|If true, the value is displayed as a dropdown list item.
 
|-
 
|-
| DropDownLinkedMemrec
+
|DropDownCount
| String
+
|Integer
| Description of linked memory record or empty string if not linked.
+
|Equivalent to DropDownList.Count. Read-only.
 
|-
 
|-
| DropDownList
+
|DropDownValue[index]
| StringList
+
|String
| List of "value:description" lines; read-write.
+
|Array-style access to dropdown values. Read-only.
 
|-
 
|-
| DropDownReadOnly
+
|DropDownDescription[index]
| Boolean
+
|String
| True if 'Disallow manual user input' is set.
+
|Array-style access to dropdown descriptions. Read-only.
 
|-
 
|-
| DropDownDescriptionOnly
+
|Count
| Boolean
+
|Integer
| Self-explanatory.
+
|The number of child records.
 
|-
 
|-
| DisplayAsDropDownListItem
+
|Child[index]
| Boolean
+
|[[Lua:Class:MemoryRecord|MemoryRecord]]
| Self-explanatory.
+
|Array-style access to child records.
 
|-
 
|-
| DropDownCount
+
|[index]
| Integer
+
|[[Lua:Class:MemoryRecord|MemoryRecord]]
| Equivalent to .DropDownList.Count.
+
|Default accessor for child records.
 
|-
 
|-
| DropDownValue[index]
+
|Parent
| String
+
|[[Lua:Class:MemoryRecord|MemoryRecord]]
| Array to access values in DropDownList (ReadOnly).
+
|The parent memory record.
 
|-
 
|-
| DropDownDescription[index]
+
|HotkeyCount
| String
+
|Integer
| Array to access descriptions in DropDownList (ReadOnly).
+
|The number of hotkeys attached to this memory record.
 
|-
 
|-
| Count
+
|Hotkey[index]
| Integer
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
| Number of child records.
+
|Array-style access to hotkeys attached to this memory record.
 
|-
 
|-
| Child[index]
+
|Async
| MemoryRecord
+
|Boolean
| Array to access child records.
+
|Set to true if activating this entry should be asynchronous. This only applies to Auto Assembler or Lua script records.
 
|-
 
|-
| Parent
+
|AsyncProcessing
| MemoryRecord
+
|Boolean
| The parent of the memory record.
+
|True when Async is true and the record is currently being processed.
 
|-
 
|-
| HotkeyCount
+
|AsyncProcessingTime
| Integer
+
|Qword
| Number of hotkeys attached to this memory record.
+
|The time in milliseconds that the record has been processing asynchronously.
 
|-
 
|-
| Hotkey[index]
+
|HasMouseOver
| [[Lua:Class:GenericHotkey|GenericHotkey]]
+
|Boolean
| Array to index the hotkeys.
+
|True if the mouse is currently over this memory record.
 
|-
 
|-
| Async
+
|DontSave
| Boolean
+
|Boolean
| Set to true if activating this entry will be asynchronous (only for AA/Lua scripts).
+
|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
 
|-
 
|-
| AsyncProcessing
+
|vtString
| Boolean
+
|String.Size
| True when async is true and it's being processed.
+
|The number of characters in the string.
 
|-
 
|-
| AsyncProcessingTime
+
|vtString
| Qword
+
|String.Unicode
| The time that it has been processing in milliseconds.
+
|If true, the string is treated as Unicode.
 
|-
 
|-
| HasMouseOver
+
|vtString
| Boolean
+
|String.Codepage
| True if the mouse is currently over it.
+
|If true, the string uses codepage handling.
 
|-
 
|-
| DontSave
+
|vtBinary
| Boolean
+
|Binary.Startbit
| Don't save this memoryrecord and its children.
+
|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.
 
|}
 
|}
  
=== Special Properties by Type ===
+
===Events===
* '''vtString''': <code>String.Size</code>, <code>String.Unicode</code>, <code>String.Codepage</code>
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
* '''vtBinary''': <code>Binary.Startbit</code>, <code>Binary.Size</code>
+
!align="left"|Event
* '''vtByteArray''': <code>Aob.Size</code>
+
!align="left"|Callback
 +
!style="width: 80%;background-color:white;" align="left"|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.
 +
|}
  
== Variable Types ==
+
===Methods===
{| class="wikitable" style="width:60%"
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
! Constant
+
!align="left"|Method
! Value
+
!align="left"|Return Type
! Description
+
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
| vtByte
+
|getDescription()
| 0
+
|String
| 1 byte (unsigned)
+
|Returns the description of the memory record.
 
|-
 
|-
| vtWord
+
|setDescription(description)
| 1
+
|void
| 2 bytes (unsigned)
+
|Sets the description of the memory record.
 
|-
 
|-
| vtDword
+
|getAddress()
| 2
+
|String, Table
| 4 bytes (unsigned)
+
|Returns the interpretable address string. If it is a pointer, it returns a second result containing a table with the offsets.
 
|-
 
|-
| vtQword
+
|setAddress(address)
| 3
+
|void
| 8 bytes (unsigned)
+
|Sets the interpretable address string.
 
|-
 
|-
| vtSingle
+
|setAddress(address, offsets)
| 4
+
|void
| 4 bytes (float)
+
|Sets the interpretable address string and pointer offsets.
 
|-
 
|-
| vtDouble
+
|getOffsetCount()
| 5
+
|Integer
| 8 bytes (double/float)
+
|Returns the number of offsets for this memory record.
 
|-
 
|-
| vtString
+
|setOffsetCount(count)
| 6
+
|void
| String (ASCII)
+
|Sets the number of offsets.
 
|-
 
|-
| vtUnicodeString<br>vtWideString
+
|getOffset(index)
| 7
+
|Integer
| Unicode string (Only used by autoguess)
+
|Returns the offset at the given index.
 
|-
 
|-
| vtByteArray
+
|setOffset(index, value)
| 8
+
|void
| Array of bytes
+
|Sets the offset at the given index.
 
|-
 
|-
| vtBinary
+
|getCurrentAddress()
| 9
+
|Integer
| Binary (bitfield)
+
|Returns the current resolved address as an integer.
 
|-
 
|-
| vtAll
+
|appendToEntry(memrec)
| 10
+
|void
| All types (used for scans)
+
|Appends this memory record to the given memory record as a child.
 
|-
 
|-
| vtAutoAssembler
+
|getHotkey(index)
| 11
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
| Auto Assembler script
+
|Returns the hotkey at the given index.
 
|-
 
|-
| vtPointer
+
|getHotkeyByID(id)
| 12
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
| Pointer (Only used by autoguess and structures)
+
|Returns the hotkey with the given ID.
 
|-
 
|-
| vtCustom
+
|reinterpret()
| 13
+
|void
| Custom type
+
|Reinterprets the memory record.
 
|-
 
|-
| vtGrouped
+
|createHotkey(keys, action, value, description)
| 14
+
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
| Grouped type
+
|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().
 
|}
 
|}
  
== MemoryRecord Options ==
+
===Value Types===
 
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
The following options can be set in the `Options` property of a MemoryRecord. 
+
!align="left"|Constant
The value is a string enclosed in square brackets, with options separated by commas (e.g., `[moHideChildren,moActivateChildrenAsWell]`).
+
!align="left"|Value
 
+
!style="width: 80%;background-color:white;" align="left"|Description
{| class="wikitable" style="width:60%"
 
! Option
 
! Description
 
 
|-
 
|-
| moHideChildren
+
|vtByte
| Hides the child records of this memory record.
+
|0
 +
|1-byte integer.
 
|-
 
|-
| moActivateChildrenAsWell
+
|vtWord
| Activating this record also activates its children.
+
|1
 +
|2-byte integer.
 
|-
 
|-
| moDeactivateChildrenAsWell
+
|vtDword
| Deactivating this record also deactivates its children.
+
|2
 +
|4-byte integer.
 
|-
 
|-
| moRecursiveSetValue
+
|vtQword
| Setting the value will also set the value of all children recursively.
+
|3
 +
|8-byte integer.
 
|-
 
|-
| moAllowManualCollapseAndExpand
+
|vtSingle
| Allows the user to manually collapse or expand this record in the address list.
+
|4
 +
|Single-precision float.
 
|-
 
|-
| moManualExpandCollapse
+
|vtDouble
| Enables manual expand/collapse behavior for this record.
+
|5
 +
|Double-precision float.
 
|-
 
|-
| moAlwaysHideChildren
+
|vtString
| Always hides the children, regardless of other settings.
+
|6
|}
+
|String.
 
 
== Methods ==
 
{| class="wikitable" style="width:100%"
 
! Method
 
! Parameters
 
! Returns
 
! Description
 
 
|-
 
|-
| getDescription
+
|vtUnicodeString
| None
+
|7
| String
+
|Unicode string.
| Gets the description.
 
 
|-
 
|-
| setDescription
+
|vtByteArray
| String
+
|8
| None
+
|Array of bytes.
| Sets the description.
 
 
|-
 
|-
| getAddress
+
|vtBinary
| None
+
|9
| String, Table
+
|Binary bitfield.
| Returns the interpretable address string. If pointer, returns a table of offsets as second result.
 
 
|-
 
|-
| setAddress
+
|vtAll
| String
+
|10
| None
+
|All value types.
| Sets the interpretable address string (and offsets if pointer).
 
 
|-
 
|-
| getOffsetCount
+
|vtAutoAssembler
| None
+
|11
| Integer
+
|Auto Assembler script.
| Returns the number of offsets.
 
 
|-
 
|-
| setOffsetCount
+
|vtPointer
| Integer
+
|12
| None
+
|Pointer type.
| Sets the number of offsets.
 
 
|-
 
|-
| getOffset
+
|vtCustom
| Integer (index)
+
|13
| Integer
+
|Custom type.
| Gets the offset at the given index.
 
 
|-
 
|-
| setOffset
+
|vtGrouped
| Integer (index), Integer (value)
+
|14
| None
+
|Grouped type.
| Sets the offset at the given index.
 
 
|-
 
|-
| getCurrentAddress
+
|vtByteArrays
| None
+
|15
| Integer
+
|Multiple byte arrays.
| Returns the current address as an integer.
 
 
|-
 
|-
| appendToEntry
+
|vtCodePageString
| MemoryRecord
+
|16
| None
+
|Codepage string.
| Appends the current memory record to the given memory record.
+
|}
 +
 
 +
===MemoryRecord Options===
 +
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Option
 +
!style="width: 80%;background-color:white;" align="left"|Description
 
|-
 
|-
| getHotkey
+
|moHideChildren
| Integer (index)
+
|Hides the child records of this memory record.
| MemoryRecordHotkey
 
| Returns the hotkey from the hotkey array.
 
 
|-
 
|-
| getHotkeyByID
+
|moActivateChildrenAsWell
| Integer (id)
+
|Activating this record also activates its children.
| MemoryRecordHotkey
 
| Returns the hotkey with the given id.
 
 
|-
 
|-
| reinterpret
+
|moDeactivateChildrenAsWell
| None
+
|Deactivating this record also deactivates its children.
| None
 
| Reinterprets the memory record.
 
 
|-
 
|-
| createHotkey
+
|moRecursiveSetValue
| Table (keys), Integer (action), String (value, optional), String (description, optional)
+
|Setting the value also sets the value of all children recursively.
| MemoryRecordHotkey
 
| Creates a hotkey object.
 
 
|-
 
|-
| disableWithoutExecute
+
|moAllowManualCollapseAndExpand
| None
+
|Allows the user to manually collapse and expand this record.
| None
 
| Sets the entry to disabled without executing the disable section.
 
 
|-
 
|-
| beginEdit
+
|moManualExpandCollapse
| None
+
|Enables manual expand/collapse behavior.
| None
 
| Call when you wish to take a long time to edit a record.
 
 
|-
 
|-
| endEdit
+
|moAlwaysHideChildren
| None
+
|Always hides the child records.
| None
 
| Marks the end of your long edit sequence.
 
 
|}
 
|}
  
== 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
 
|-
 
|-
| OnActivate
+
|mrhToggleActivation
| function(memoryrecord, before, currentstate):boolean
+
|0
| Called when the memoryrecord will change (or changed) Active to true. If before is true, not returning true will cause the activation to stop.
+
|Toggles the active state of the memory record.
 
|-
 
|-
| OnDeactivate
+
|mrhToggleActivationAllowIncrease
| function(memoryrecord, before, currentstate):boolean
+
|1
| Called when the memoryrecord will change (or changed) Active to false. If before is true, not returning true will cause the deactivation to stop.
+
|Toggles activation and allows the value to increase while frozen.
 
|-
 
|-
| OnActivationFailure
+
|mrhToggleActivationAllowDecrease
| function(memoryrecord, reason, reasonText)
+
|2
| Called when activating a record fails. Return true to try again (be careful of infinite loops).
+
|Toggles activation and allows the value to decrease while frozen.
 
|-
 
|-
| OnDestroy
+
|mrhActivate
| function()
+
|3
| Called when the memoryrecord is destroyed.
+
|Activates the memory record.
 
|-
 
|-
| OnGetDisplayValue
+
|mrhDeactivate
| function(memoryrecord, valuestring):boolean,string
+
|4
| Called when rendering the value of a memory record. Return true and a new string to override the value shown.
+
|Deactivates the memory record.
 
|-
 
|-
| OnValueChanged
+
|mrhSetValue
| function(memoryrecord, oldvalue, newvalue)
+
|5
| Called whenever the value of a memory record has changed.
+
|Sets the memory record to the specified value.
 
|-
 
|-
| OnValueChangedByUser
+
|mrhIncreaseValue
| function(memoryrecord, oldvalue, newvalue)
+
|6
| Called whenever the value of a memory record has changed by the user.
+
|Increases the current value by the specified amount.
 +
|-
 +
|mrhDecreaseValue
 +
|7
 +
|Decreases the current value by the specified amount.
 
|}
 
|}
  
== Global Events ==
+
===Global Events===
<pre>
+
{{CodeBox|'''function''' onMemRecPreExecute(''memoryrecord'', ''newstate'') ''':''' boolean}}
function onMemRecPreExecute(memoryrecord, newstate BOOLEAN)
+
 
  -- Called before action is performed. Active property is about to change to newState.
+
If defined, this function is called before a memory record action is performed. The Active property is about to change to newstate.
 +
 
 +
{{CodeBox|'''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===
 +
 
 +
====Get the first MemoryRecord====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList[0]
 +
 
 +
if record ~= nil then
 +
  print(record.Description)
 +
  print(record.Value)
 +
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})
 +
 
 +
print(string.format("%X", record.CurrentAddress))
 +
</syntaxhighlight>
 +
 
 +
====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
 +
</syntaxhighlight>
 +
 
 +
====Activate and deactivate a record====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Player Health")
 +
 
 +
if record ~= nil then
 +
  record.Active = true
 +
  sleep(1000)
 +
  record.Active = false
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Disable without executing the disable section====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Infinite Ammo")
 +
 
 +
if record ~= nil then
 +
  record.disableWithoutExecute()
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Show a value as hexadecimal====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Flags"
 +
record.Address = "game.exe+4000"
 +
record.Type = vtDword
 +
record.ShowAsHex = true
 +
</syntaxhighlight>
 +
 
 +
====Use a string MemoryRecord====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Player Name"
 +
record.Type = vtString
 +
record.Address = "player_name"
 +
record.String.Size = 32
 +
record.String.Unicode = true
 +
</syntaxhighlight>
 +
 
 +
====Use a binary MemoryRecord====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Player Flags"
 +
record.Type = vtBinary
 +
record.Address = "game.exe+5000"
 +
record.Binary.Startbit = 2
 +
record.Binary.Size = 4
 +
</syntaxhighlight>
 +
 
 +
====Use an array-of-bytes MemoryRecord====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Instruction Bytes"
 +
record.Type = vtByteArray
 +
record.Address = "game.exe+6000"
 +
record.Aob.Size = 16
 +
record.ShowAsHex = true
 +
</syntaxhighlight>
 +
 
 +
====Use a dropdown list====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Game State"
 +
record.Type = vtByte
 +
record.Address = "game_state"
 +
 
 +
record.DropDownList.Text = [[0:Menu
 +
1:Playing
 +
2:Paused
 +
3:Game Over]]
 +
 
 +
record.DropDownReadOnly = true
 +
record.DropDownDescriptionOnly = true
 +
record.DisplayAsDropDownListItem = true
 +
</syntaxhighlight>
 +
 
 +
====Read dropdown values====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Game State")
 +
 
 +
if record ~= nil then
 +
  for i = 0, record.DropDownCount - 1 do
 +
    print(record.DropDownValue[i] .. " = " .. record.DropDownDescription[i])
 +
  end
 +
end
 +
</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>
 +
 
 +
====Append records as children====
 +
<syntaxhighlight lang="lua" line>
 +
local group = AddressList.createMemoryRecord()
 +
group.Description = "Player Stats"
 +
group.IsGroupHeader = true
 +
 
 +
local health = AddressList.createMemoryRecord()
 +
health.Description = "Health"
 +
health.Type = vtDword
 +
health.Address = "player_base+10"
 +
health.appendToEntry(group)
 +
 
 +
local ammo = AddressList.createMemoryRecord()
 +
ammo.Description = "Ammo"
 +
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
 +
</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
 +
 
 +
[DISABLE]
 +
dealloc(newmem)
 +
]]
 +
</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
 +
</syntaxhighlight>
 +
 
 +
====Use asynchronous activation====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Slow Script")
 +
 
 +
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
 
end
 +
</syntaxhighlight>
 +
 +
====Create a hotkey====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("God Mode")
  
function onMemRecPostExecute(memoryrecord, newState BOOLEAN, succeeded BOOLEAN)
+
if record ~= nil then
  -- Called after action is performed. Active property was supposed to change to newState.
+
  local hotkey = record.createHotkey({VK_F1}, mrhToggleActivation, "", "Toggle God Mode")
   -- If 'succeeded' is true, Active state has changed and is newState.
+
 
 +
   print(hotkey.Description)
 
end
 
end
</pre>
+
</syntaxhighlight>
  
== Examples ==
+
====Create a hotkey that sets a value====
<pre>
+
<syntaxhighlight lang="lua" line>
-- Get the first memory record in the address list
+
local record = AddressList.getMemoryRecordByDescription("Health")
local mr = AddressList[0]
 
  
-- Print some basic properties
+
if record ~= nil then
print("ID:", mr.ID)
+
  record.createHotkey({VK_CONTROL, VK_F2}, mrhSetValue, "100", "Set health to 100")
print("Description:", mr.Description)
+
end
print("Address:", mr.Address)
+
</syntaxhighlight>
print("Current Value:", mr.Value)
 
print("Active:", mr.Active)
 
  
-- Change the value and activate the record
+
====List hotkeys====
mr.Value = "999"
+
<syntaxhighlight lang="lua" line>
mr.Active = true
+
local record = AddressList.getMemoryRecordByDescription("God Mode")
</pre>
+
 
 +
if record ~= nil then
 +
  for i = 0, record.HotkeyCount - 1 do
 +
    local hotkey = record.Hotkey[i]
 +
 
 +
    print(hotkey.ID .. ": " .. hotkey.Description)
 +
  end
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Use beginEdit and endEdit====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList[0]
 +
 
 +
if record ~= nil then
 +
  record.beginEdit()
 +
 
 +
  record.Description = "Edited Record"
 +
  record.Address = "game.exe+7777"
 +
  record.Type = vtQword
 +
  record.ShowAsHex = true
 +
 
 +
  record.endEdit()
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Handle activation====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("God Mode")
 +
 
 +
if record ~= nil then
 +
  record.OnActivate = function(memrec, before, currentstate)
 +
    if before then
 +
      print("About to activate: " .. memrec.Description)
 +
      return true
 +
    end
 +
 
 +
    print("Activated: " .. memrec.Description)
 +
    return true
 +
  end
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Block activation====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Dangerous Script")
 +
 
 +
if record ~= nil then
 +
  record.OnActivate = function(memrec, before, currentstate)
 +
    if before then
 +
      print("Activation blocked")
 +
      return false
 +
    end
 +
 
 +
    return true
 +
  end
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Handle deactivation====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("God Mode")
 +
 
 +
if record ~= nil then
 +
  record.OnDeactivate = function(memrec, before, currentstate)
 +
    if before then
 +
      print("About to deactivate: " .. memrec.Description)
 +
      return true
 +
    end
 +
 
 +
    print("Deactivated: " .. memrec.Description)
 +
    return true
 +
  end
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Override the displayed value====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Health")
 +
 
 +
if record ~= nil then
 +
  record.OnGetDisplayValue = function(memrec, valuestring)
 +
    return true, valuestring .. " HP"
 +
  end
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Handle value changes====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Health")
 +
 
 +
if record ~= nil then
 +
  record.OnValueChanged = function(memrec, oldvalue, newvalue)
 +
    print(memrec.Description .. " changed from " .. oldvalue .. " to " .. newvalue)
 +
  end
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Handle user value changes====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Health")
 +
 
 +
if record ~= nil then
 +
  record.OnValueChangedByUser = function(memrec, oldvalue, newvalue)
 +
    print("User changed " .. memrec.Description .. " from " .. oldvalue .. " to " .. newvalue)
 +
  end
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Handle destroy====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Temporary Record")
 +
 
 +
if record ~= nil then
 +
  record.OnDestroy = function()
 +
    print("MemoryRecord destroyed")
 +
  end
 +
 
 +
  record.destroy()
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Use global pre/post execute events====
 +
<syntaxhighlight lang="lua" line>
 +
function onMemRecPreExecute(memoryrecord, newstate)
 +
  print("Before execution: " .. memoryrecord.Description .. " -> " .. tostring(newstate))
 +
 
 +
  return true
 +
end
 +
 
 +
function onMemRecPostExecute(memoryrecord, newstate, succeeded)
 +
  print("After execution: " .. memoryrecord.Description)
 +
  print("New state: " .. tostring(newstate))
 +
  print("Succeeded: " .. tostring(succeeded))
 +
end
 +
</syntaxhighlight>
 +
 
 +
====Do not save a record====
 +
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
 +
 
 +
record.Description = "Temporary Runtime Record"
 +
record.Address = "game.exe+1234"
 +
record.Type = vtDword
 +
record.DontSave = true
 +
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
  
=== Related Functions ===
+
{{Forms}}
* [[Lua:getMainForm|getMainForm]]
 
* [[Lua:getAddressList|getAddressList]]
 
 
 
=== Related Classes ===
 
* [[Lua:Class:Addresslist|Addresslist]]
 

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