Difference between revisions of "Lua:Class:MemoryRecord"

From Cheat Engine
Jump to navigation Jump to search
(Examples: syntax highlight)
m
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
MemoryRecord '''class''': ('''Inheritance''': ''[[Lua:Class:Object|Object]]'')
+
{{Class|'''class''' MemoryRecord ''':''' Object}}
  
The memory record objects are the entries you see in the address list.
+
The MemoryRecord class represents an entry in Cheat Engine's [[Lua:Class:Addresslist|Addresslist]].
  
== 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.
; ID : integer
 
: Unique ID.
 
  
; Index : integer
+
===Inheritance===
: The index ID for this record. 0 is top. (ReadOnly)
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!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.
 +
|}
  
; Description : string- The description of the memory record.
+
===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.
 +
|-
 +
|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|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
 +
|[[Lua:Class:Stringlist|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]
 +
|[[Lua:Class:MemoryRecord|MemoryRecord]]
 +
|Array-style access to child records.
 +
|-
 +
|[index]
 +
|[[Lua:Class:MemoryRecord|MemoryRecord]]
 +
|Default accessor for child records.
 +
|-
 +
|Parent
 +
|[[Lua:Class:MemoryRecord|MemoryRecord]]
 +
|The parent memory record.
 +
|-
 +
|HotkeyCount
 +
|Integer
 +
|The number of hotkeys attached to this memory record.
 +
|-
 +
|Hotkey[index]
 +
|[[Lua:Class:MemoryRecordHotkey|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.
 +
|}
  
; Address : string
+
===Type-Specific Properties===
: Get/set the interpretable address string. Useful for simple address settings.
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Record Type
 +
!align="left"|Property
 +
!style="width: 80%;background-color:white;" align="left"|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.
 +
|}
  
; OffsetCount : integer
+
===Events===
: The number of offsets. Set to 0 for a normal address.
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Event
 +
!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.
 +
|}
  
; Offset[''index''] : integer
+
===Methods===
: Array to access each offset.
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Method
 +
!align="left"|Return Type
 +
!style="width: 80%;background-color:white;" align="left"|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)
 +
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
 +
|Returns the hotkey at the given index.
 +
|-
 +
|getHotkeyByID(id)
 +
|[[Lua:Class:MemoryRecordHotkey|MemoryRecordHotkey]]
 +
|Returns the hotkey with the given ID.
 +
|-
 +
|reinterpret()
 +
|void
 +
|Reinterprets the memory record.
 +
|-
 +
|createHotkey(keys, action, value, description)
 +
|[[Lua:Class:MemoryRecordHotkey|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().
 +
|}
  
; CurrentAddress : integer
+
===Value Types===
: The address the memoryrecord points to.
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Constant
 +
!align="left"|Value
 +
!style="width: 80%;background-color:white;" align="left"|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.
 +
|}
  
; Type : integer
+
===MemoryRecord Options===
: The variable type of this record. See vtByte to vtCustom
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
:* If the type is vtString then the following properties are available:
+
!align="left"|Option
:** String.Size: Number of characters in the string
+
!style="width: 80%;background-color:white;" align="left"|Description
:** String.Unicode: boolean
+
|-
:* If the type is vtBinary then the following properties are available
+
|moHideChildren
:** Binary.Startbit: First bit to start reading from
+
|Hides the child records of this memory record.
:** Binary.Size: Number of bits
+
|-
:* If the type is vtByteArray then the following properties are available
+
|moActivateChildrenAsWell
:** Aob.Size: Number of bytes
+
|Activating this record also activates its children.
:'''From ''defines.lua''''':
+
|-
vtByte=0
+
|moDeactivateChildrenAsWell
vtWord=1
+
|Deactivating this record also deactivates its children.
vtDword=2
+
|-
vtQword=3
+
|moRecursiveSetValue
vtSingle=4
+
|Setting the value also sets the value of all children recursively.
vtDouble=5
+
|-
vtString=6
+
|moAllowManualCollapseAndExpand
vtUnicodeString=7 --Only used by autoguess
+
|Allows the user to manually collapse and expand this record.
vtByteArray=8
+
|-
vtBinary=9
+
|moManualExpandCollapse
vtAutoAssembler=11
+
|Enables manual expand/collapse behavior.
vtPointer=12 --Only used by autoguess and structures
+
|-
vtCustom=13
+
|moAlwaysHideChildren
vtGrouped=14
+
|Always hides the child records.
 +
|}
  
; CustomTypeName : string
+
===Hotkey Actions===
: If the type is vtCustomType this will contain the name of the CustomType
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
 +
!align="left"|Constant
 +
!align="left"|Value
 +
!style="width: 80%;background-color:white;" align="left"|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.
 +
|}
  
; Script : string
+
===Global Events===
: If the type is vtAutoAssembler this will contain the auto assembler script
+
{{CodeBox|'''function''' onMemRecPreExecute(''memoryrecord'', ''newstate'') ''':''' boolean}}
  
; Value : string
+
If defined, this function is called before a memory record action is performed. The Active property is about to change to newstate.
: The value in stringform.
 
  
; Selected : boolean
+
{{CodeBox|'''function''' onMemRecPostExecute(''memoryrecord'', ''newstate'', ''succeeded'') ''':''' void}}
: Set to true if selected (ReadOnly)
 
  
; Active : boolean
+
If defined, this function is called after a memory record action has been performed. If succeeded is true, the Active state changed to newstate.
: Set to true to activate/freeze, false to deactivate/unfreeze
 
  
; Color : integer
+
===Examples===
: The memory record's RBG color integer.
 
  
; ShowAsHex : boolean
+
====Get the first MemoryRecord====
: Self explanatory
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList[0]
  
; ShowAsSigned &#58; boolean
+
if record ~= nil then
: Self explanatory
+
  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")
  
; AllowIncrease &#58; boolean
+
if record ~= nil then
: Allow value increasing, unfreeze will reset it to false
+
  for i = 0, record.DropDownCount - 1 do
 +
    print(record.DropDownValue[i] .. " = " .. record.DropDownDescription[i])
 +
  end
 +
end
 +
</syntaxhighlight>
  
; AllowDecrease &#58; boolean
+
====Link a dropdown list to another record====
: Allow value decreasing, unfreeze will reset it to false
+
<syntaxhighlight lang="lua" line>
 +
local source = AddressList.createMemoryRecord()
 +
source.Description = "Shared States"
 +
source.DropDownList.Text = [[0:Disabled
 +
1:Enabled]]
  
; Count &#58; integer
+
local target = AddressList.createMemoryRecord()
: Number of children
+
target.Description = "Current State"
 +
target.Type = vtByte
 +
target.Address = "state_value"
 +
target.DropDownLinked = true
 +
target.DropDownLinkedMemrec = "Shared States"
 +
target.DisplayAsDropDownListItem = true
 +
</syntaxhighlight>
  
; Child[''index''] &#58; MemoryRecord
+
====Create a group header====
: Array to access the child records
+
<syntaxhighlight lang="lua" line>
 +
local group = AddressList.createMemoryRecord()
  
; HotkeyCount &#58; integer
+
group.Description = "Player Stats"
: Number of hotkeys attached to this memory record.
+
group.IsGroupHeader = true
 +
group.Options = "[moHideChildren]"
 +
</syntaxhighlight>
  
; Hotkey[''index''] &#58; [[Lua:Class:GenericHotkey|GenericHotkey]]
+
====Append records as children====
: Array to index the hotkeys.
+
<syntaxhighlight lang="lua" line>
 +
local group = AddressList.createMemoryRecord()
 +
group.Description = "Player Stats"
 +
group.IsGroupHeader = true
  
; Options &#58; string
+
local health = AddressList.createMemoryRecord()
: A string of the set "Group Config" options in the format ''''[optionName,...]''''
+
health.Description = "Health"
: Valid options are:
+
health.Type = vtDword
moHideChildren
+
health.Address = "player_base+10"
moActivateChildrenAsWell
+
health.appendToEntry(group)
moDeactivateChildrenAsWell
 
moRecursiveSetValue
 
moAllowManualCollapseAndExpand
 
moManualExpandCollapse
 
: example: '[moHideChildren,moAllowManualCollapseAndExpand,moManualExpandCollapse]'
 
  
; Collapsed &#58; boolean
+
local ammo = AddressList.createMemoryRecord()
: only works when manual expand/collapse is set in group config options ('''moManualExpandCollapse''')
+
ammo.Description = "Ammo"
 +
ammo.Type = vtDword
 +
ammo.Address = "player_base+14"
 +
ammo.appendToEntry(group)
 +
</syntaxhighlight>
  
; OnActivate &#58; function(''memoryrecord'', ''before'', ''currentstate'') &#58; boolean
+
====Iterate through child records====
: The function to call when the memoryrecord will change (or changed) Active to true.
+
<syntaxhighlight lang="lua" line>
: If before is true, not returning true will cause the activation to stop.
+
local group = AddressList.getMemoryRecordByDescription("Player Stats")
  
; OnDeactivate &#58; function(memoryrecord,before,currentstate) &#58; boolean
+
if group ~= nil then
: The function to call when the memoryrecord will change (or changed) Active to false.  
+
  for i = 0, group.Count - 1 do
: If before is true, not returning true will cause the deactivation to stop.
+
    local child = group.Child[i]
  
; OnDestroy &#58; function
+
    print(child.Description .. " = " .. child.Value)
: Called when the memoryrecord is destroyed.
+
  end
 +
end
 +
</syntaxhighlight>
  
; DontSave &#58; boolean
+
====Use parent and child accessors====
: Don't save this memoryrecord and it's children
+
<syntaxhighlight lang="lua" line>
 +
local child = AddressList.getMemoryRecordByDescription("Health")
  
; DropDownLinked&#58; boolean
+
if child ~= nil and child.Parent ~= nil then
: if dropdown list refers to list of another memory record eg. (memrec name)
+
  print("Parent: " .. child.Parent.Description)
 +
end
 +
</syntaxhighlight>
  
; DropDownLinkedMemrec&#58; string
+
====Create an Auto Assembler script record====
: Description of linked memrec or emptystring if not linked
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.createMemoryRecord()
  
; DropDownList&#58; StringList
+
record.Description = "Infinite Ammo"
: list of "value:description" lines, lists are still separate objects when linked, read-write
+
record.Type = vtAutoAssembler
 +
record.Script = [[
 +
[ENABLE]
 +
alloc(newmem,1024)
  
; DropDownReadOnly&#58; boolean
+
newmem:
: true if 'Disallow manual user input' is set
+
  ret
  
; DropDownDescriptionOnly&#58; boolean
+
[DISABLE]
: self explanatory
+
dealloc(newmem)
 +
]]
 +
</syntaxhighlight>
  
; DisplayAsDropDownListItem&#58; boolean
+
====Activate an Auto Assembler script and check failure====
: self explanatory
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Infinite Ammo")
  
; DropDownCount&#58; integer
+
if record ~= nil then
: equivalent to .DropDownList.Count
+
  record.Active = true
  
; DropDownValue&#58; Array
+
  if record.LastAAExecutionFailed then
: Array to access values in DropDownList (ReadOnly)
+
    print(record.LastAAExecutionFailedReason)
 +
  end
 +
end
 +
</syntaxhighlight>
  
; DropDownDescription&#58; Array
+
====Use asynchronous activation====
: Array to access Descriptions in DropDownList (ReadOnly)
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Slow Script")
  
== Methods ==
+
if record ~= nil then
; getDescription() &#58; string
+
  record.Async = true
: Returns the memory record's description.
+
  record.Active = true
  
; setDescription()
+
  while record.AsyncProcessing do
: Sets the memory record's description.
+
    print("Processing for " .. tostring(record.AsyncProcessingTime) .. " ms")
 +
    sleep(100)
 +
  end
 +
end
 +
</syntaxhighlight>
  
; getAddress() &#58; integer - (integer, table)
+
====Create a hotkey====
: Returns the interpretable addressstring of this record.
+
<syntaxhighlight lang="lua" line>
: If it is a pointer, it returns a second result as a table filled with the offsets
+
local record = AddressList.getMemoryRecordByDescription("God Mode")
  
; setAddress(''string'')
+
if record ~= nil then
: Sets the interpretable address string, and if offsets are provided make it a pointer
+
  local hotkey = record.createHotkey({VK_F1}, mrhToggleActivation, "", "Toggle God Mode")
  
; getOffsetCount() &#58; integer
+
  print(hotkey.Description)
: Returns the number of offsets for this memoryrecord
+
end
 +
</syntaxhighlight>
  
; setOffsetCount(''integer'')
+
====Create a hotkey that sets a value====
: Lets you set the number of offsets
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("Health")
  
; getOffset(''index'') &#58; integer
+
if record ~= nil then
: Gets the offset at the given index
+
  record.createHotkey({VK_CONTROL, VK_F2}, mrhSetValue, "100", "Set health to 100")
 +
end
 +
</syntaxhighlight>
  
; setOffset(''index'', ''value'')
+
====List hotkeys====
: Sets the offset at the given index
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList.getMemoryRecordByDescription("God Mode")
  
; getCurrentAddress() &#58; integer
+
if record ~= nil then
: Returns the current address as an integer (the final result of the interpretable address and pointer offsets)
+
  for i = 0, record.HotkeyCount - 1 do
 +
    local hotkey = record.Hotkey[i]
  
; appendToEntry(''memrec'')
+
    print(hotkey.ID .. ": " .. hotkey.Description)
: Appends the current memory record to the given memory record
+
  end
 +
end
 +
</syntaxhighlight>
  
; getHotkey(''index'') &#58; [[Lua:Class:GenericHotkey|GenericHotkey]]
+
====Use beginEdit and endEdit====
: Returns the hotkey from the hotkey array
+
<syntaxhighlight lang="lua" line>
 +
local record = AddressList[0]
  
; getHotkeyByID(''integer'') &#58; [[Lua:Class:GenericHotkey|GenericHotkey]]
+
if record ~= nil then
: Returns the hotkey with the given id
+
  record.beginEdit()
  
; [''index''] : MemoryRecord
+
  record.Description = "Edited Record"
: Same as 'Child[''index'']'
+
  record.Address = "game.exe+7777"
: Default accessor.
+
  record.Type = vtQword
 +
  record.ShowAsHex = true
  
== Examples ==
+
  record.endEdit()
<syntaxhighlight lang="lua">
+
end
local addressList = getAddressList()
+
</syntaxhighlight>
local mrHealth = addressList.getMemoryRecordByDescription('Health')
+
 
print(mrHealth.Description)
+
====Handle activation====
print(mrHealth.Active and 'True' or 'False')
+
<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>
 
</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