Difference between revisions of "Lua:Class:MemoryRecord"

From Cheat Engine
Jump to navigation Jump to search
m (added a simple description...)
m (Properties: Fixed typo in Color's description.)
 
(20 intermediate revisions by 6 users not shown)
Line 1: Line 1:
--Under Construction
+
[[Category:Lua]]
 +
MemoryRecord '''class''': ('''Inheritance''': ''[[Lua:Class:Object|Object]]'')
  
The class MemoryRecord are the entries in Cheat tables. This class is commonly used with [[Addresslist]].
+
The memory record objects are the entries you see in the address list.
  
----
+
== Properties ==
 +
; ID : integer
 +
: Unique ID.
  
 +
; Index : integer
 +
: The index ID for this record. 0 is top. (ReadOnly)
  
'''MemoryRecord Class'''
+
; Description : string- The description of the memory record.
  The Memoryrecord class object describes a Cheat Table's Cheat Entry.
 
  
 +
; Address : string
 +
: Get/set the interpretable address string. Useful for simple address settings.
  
'''memoryrecord_getID'''(memoryrecord)
+
; OffsetCount : integer
  Returns the unique id of this memory record. Every memory record has an unique id
+
: The number of offsets. Set to 0 for a normal address.
  
 +
; Offset[''index''] : integer
 +
: Array to access each offset.
  
'''memoryrecord_getHotkeyCount'''(memoryrecord)
+
; CurrentAddress : integer
  Returns the number of hotkeys assigned to this Cheat Entry
+
: The address the memoryrecord points to.
  
 +
; Type : integer
 +
: The variable type of this record. See vtByte to vtCustom
 +
:* If the type is vtString then the following properties are available:
 +
:** String.Size: Number of characters in the string
 +
:** String.Unicode: boolean
 +
:* If the type is vtBinary then the following properties are available
 +
:** Binary.Startbit: First bit to start reading from
 +
:** Binary.Size: Number of bits
 +
:* If the type is vtByteArray then the following properties are available
 +
:** Aob.Size: Number of bytes
 +
:'''From ''defines.lua''''':
 +
vtByte=0
 +
vtWord=1
 +
vtDword=2
 +
vtQword=3
 +
vtSingle=4
 +
vtDouble=5
 +
vtString=6
 +
vtUnicodeString=7 --Only used by autoguess
 +
vtByteArray=8
 +
vtBinary=9
 +
vtAutoAssembler=11
 +
vtPointer=12 --Only used by autoguess and structures
 +
vtCustom=13
 +
vtGrouped=14
  
'''memoryrecord_getHotkey'''(memoryrecord, index)
+
; CustomTypeName : string
  Returns a memoryrecordhotkey class
+
: If the type is vtCustomType this will contain the name of the CustomType
  
 +
; Script : string
 +
: If the type is vtAutoAssembler this will contain the auto assembler script
  
'''memoryrecord_getHotkeyByID'''(memoryrecord, ID)
+
; Value : string
  Every hotkey in a memoryrecord gets an unique ID. This way you can always find the hotkey even if the order of hotkeys has changed (or deleted)
+
: The value in stringform.
  
 +
; IsGroupHeader : boolean
 +
: Set to true to change the memory record into a group header.
 +
: All properties and functions related to address, type, and value are ignored when true.
  
'''memoryrecord_setDescription'''(memoryrecord, description)  
+
; Selected : boolean
  Sets the specified description for this entry
+
: Set to true if selected (ReadOnly)
  
 +
; Active : boolean
 +
: Set to true to activate/freeze, false to deactivate/unfreeze
  
'''memoryrecord_getDescription'''(memoryrecord)
+
; Color : integer
  Gets the current description of this entry
+
: The memory record's RGB color integer.
  
 +
; ShowAsHex : boolean
 +
: Self explanatory
  
'''memoryrecord_getAddress'''(memoryrecord)
+
; ShowAsSigned : boolean
  Returns the address and optional offsets for a pointer (note that in 64-bit kernelmode addresses will be rounded down...)
+
: Self explanatory
  
 +
; AllowIncrease : boolean
 +
: Allow value increasing, unfreeze will reset it to false
  
'''memoryrecord_setAddress'''(memoryrecord,address,offsets OPTIONAL) 
+
; AllowDecrease : boolean
  Sets the address of a entry. You can give as many offsets as you need
+
: Allow value decreasing, unfreeze will reset it to false
  
 +
; Count : integer
 +
: Number of children
  
'''memoryrecord_getType'''(memoryrecord) 
+
; Child[''index''] : MemoryRecord
  Returns the Variable type. (vtByte to vtCustom)
+
: Array to access the child records
  
 +
; HotkeyCount : integer
 +
: Number of hotkeys attached to this memory record.
  
'''memoryrecord_setType'''(memoryrecord, vartype) 
+
; Hotkey[''index''] : [[Lua:Class:GenericHotkey|GenericHotkey]]
  Sets the type of the entry
+
: Array to index the hotkeys.
  
 +
; Options : string
 +
: A string of the set "Group Config" options in the format ''''[optionName,...]''''
 +
: Valid options are:
 +
moHideChildren
 +
moActivateChildrenAsWell
 +
moDeactivateChildrenAsWell
 +
moRecursiveSetValue
 +
moAllowManualCollapseAndExpand
 +
moManualExpandCollapse
 +
: example: '[moHideChildren,moAllowManualCollapseAndExpand,moManualExpandCollapse]'
  
'''memoryrecord_getValue'''(memoryrecord)  
+
; Collapsed : boolean
  Returns the current value of the cheat table entry as a string
+
: only works when manual expand/collapse is set in group config options ('''moManualExpandCollapse''')
  
 +
; OnActivate : function(''memoryrecord'', ''before'', ''currentstate'') : boolean
 +
: The function to call when the memoryrecord will change (or changed) Active to true.
 +
: If before is true, not returning true will cause the activation to stop.
  
'''memoryrecord_setValue'''(memoryrecord, value)  
+
; OnDeactivate : function(memoryrecord,before,currentstate) : boolean
  Sets the value of a cheat table entry
+
: The function to call when the memoryrecord will change (or changed) Active to false.
 +
: If before is true, not returning true will cause the deactivation to stop.
  
 +
; OnDestroy : function
 +
: Called when the memoryrecord is destroyed.
  
'''memoryrecord_getScript'''(memoryrecord) 
+
; DontSave : boolean
  If the entry is of type vtAutoAssembler then you can get the script with this routine
+
: Don't save this memoryrecord and it's children
  
 +
; DropDownLinked: boolean
 +
: if dropdown list refers to list of another memory record eg. (memrec name)
  
'''memoryrecord_setScript'''(memoryrecord, script)
+
; DropDownLinkedMemrec: string
 +
: Description of linked memrec or emptystring if not linked
  
 +
; DropDownList: StringList
 +
: list of "value:description" lines, lists are still separate objects when linked, read-write
  
'''memoryrecord_isActive'''(memoryrecord)
+
; DropDownReadOnly: boolean
 +
: true if 'Disallow manual user input' is set
  
 +
; DropDownDescriptionOnly: boolean
 +
: self explanatory
  
'''memoryrecord_freeze'''(memoryrecord, updownfreeze OPTIONAL)
+
; DisplayAsDropDownListItem: boolean
  Sets the entry to frozen state. updownfreeze is optional. 0=freeze, 1=allow increase, 2=allow decrease
+
: self explanatory
  
 +
; DropDownCount: integer
 +
: equivalent to .DropDownList.Count
  
'''memoryrecord_unfreeze'''(memoryrecord)  
+
; DropDownValue: Array
  Unfreezes an entry
+
: Array to access values in DropDownList (ReadOnly)
  
 +
; DropDownDescription: Array
 +
: Array to access Descriptions in DropDownList (ReadOnly)
  
'''memoryrecord_setColor'''(memoryrecord, colorrgb)  
+
== Methods ==
  Sets the color of the entry
+
; getDescription() : string
 +
: Returns the memory record's description.
  
 +
; setDescription()
 +
: Sets the memory record's description.
  
'''memoryrecord_appendToEntry'''(memoryrecord,memoryrecord)
+
; getAddress() : integer - (integer, table)
  Adds the entry to another entry
+
: Returns the interpretable addressstring of this record.
 +
: If it is a pointer, it returns a second result as a table filled with the offsets
  
 +
; setAddress(''string'')
 +
: Sets the interpretable address string, and if offsets are provided make it a pointer
  
'''memoryrecord_delete'''(memoryrecord)  
+
; getOffsetCount() : integer
  It's unknown what this function does, all that is known is that after using this command other memrec routines with this table entry value don't work anymore...
+
: Returns the number of offsets for this memoryrecord
  
 +
; setOffsetCount(''integer'')
 +
: Lets you set the number of offsets
  
'''memoryrecord_onActivate'''(memoryrecord, function)  
+
; getOffset(''index'') : integer
  Registers a function to be called when a cheat entry is Activated
+
: Gets the offset at the given index
    function (memoryrecord, before, currentstate) boolean
 
    If before is true returning false will cause the activation to stop
 
  
 +
; setOffset(''index'', ''value'')
 +
: Sets the offset at the given index
  
'''memoryrecord_onDeactivate'''(memoryrecord, function)
+
; getCurrentAddress() : integer
  Registers a function to be called when a cheat entry is Deactivated
+
: Returns the current address as an integer (the final result of the interpretable address and pointer offsets)
    function (memoryrecord, before, currentstate) boolean
 
    If before is true returning false will cause the deactivation to stop
 
  
 +
; appendToEntry(''memrec'')
 +
: Appends the current memory record to the given memory record
  
'''memoryrecord_onDestroy'''(memoryrecord, function)  
+
; getHotkey(''index'') : [[Lua:Class:GenericHotkey|GenericHotkey]]
  Registers a function to be called when a cheat entry is delete
+
: Returns the hotkey from the hotkey array
    function (memoryrecord)
 
  
 +
; getHotkeyByID(''integer'') : [[Lua:Class:GenericHotkey|GenericHotkey]]
 +
: Returns the hotkey with the given id
  
 +
; [''index''] : MemoryRecord
 +
: Same as 'Child[''index'']'
 +
: Default accessor.
  
Example:
+
== Examples ==
<pre>
+
<syntaxhighlight lang="lua">
addresslist = getAddressList()
+
local addressList = getAddressList()
description1= [[Health]]
+
local mrHealth = addressList.getMemoryRecordByDescription('Health')
description2= [[Health Pointer]]
+
print(mrHealth.Description)
memoryrec1 = addresslist_getMemoryRecordByDescription(addresslist, description1)
+
print(mrHealth.Active and 'True' or 'False')
memoryrec2 = addresslist_getMemoryRecordByDescription(addresslist, description2)
+
</syntaxhighlight>
  
desc = memoryrecord_getDescription(memoryrec1)    --Gets the current memroyrecord's description
+
{{LuaSeeAlso}}
print(desc)
 
  
memoryrecord_setDescription(memoryrec1, [[My new health description]])  --sets the memorydescription
+
=== Related Functions ===
 +
* [[Lua:getMainForm|getMainForm]]
 +
* [[Lua:getAddressList|getAddressList]]
  
 
+
=== Related Classes ===
value = memoryrecord_getValue(memoryrec2)    --Gets the current value of the memory record.
+
* [[Lua:Class:Addresslist|Addresslist]]
print(value)
 
 
 
newvalue = 66
 
memoryrecord_setValue(memoryrec2, newvalue)  --sets value for the memoryrecord
 
 
 
if memoryrecord_isActive(memoryrecord) then  --Checks if memoryrecord is in frozen state or not
 
else
 
memoryrecord_freeze(memoryrec2)  -- freezes the memoryrecord, to unfreeze use memoryrecord_freeze
 
end
 
 
 
memoryrecord_setColor(memoryrec2,0x0000FF)  --Sets the color of the memoryrecord. Here Red. Color range {0x000000 to 0xFFFFFF)
 
 
 
count = memoryrecord_getHotkeyCount(memoryrec2)  --Gets number of hotkeys associated with memoryrecord
 
print(count)                                    --From the image, We can see it is 2.   
 
</pre>[[Image:Image.png|frame|CheatEngine Encyclopedia]]
 
[[Image:Hotkey.png|frame|CheatEngine Encyclopedia]]
 

Latest revision as of 20:02, 6 September 2021

MemoryRecord class: (Inheritance: Object)

The memory record objects are the entries you see in the address list.

Properties[edit]

ID : integer
Unique ID.
Index : integer
The index ID for this record. 0 is top. (ReadOnly)
Description : string- The description of the memory record.
Address : string
Get/set the interpretable address string. Useful for simple address settings.
OffsetCount : integer
The number of offsets. Set to 0 for a normal address.
Offset[index] : integer
Array to access each offset.
CurrentAddress : integer
The address the memoryrecord points to.
Type : integer
The variable type of this record. See vtByte to vtCustom
  • If the type is vtString then the following properties are available:
    • String.Size: Number of characters in the string
    • String.Unicode: boolean
  • If the type is vtBinary then the following properties are available
    • Binary.Startbit: First bit to start reading from
    • Binary.Size: Number of bits
  • If the type is vtByteArray then the following properties are available
    • Aob.Size: Number of bytes
From defines.lua:
vtByte=0
vtWord=1
vtDword=2
vtQword=3
vtSingle=4
vtDouble=5
vtString=6
vtUnicodeString=7 --Only used by autoguess
vtByteArray=8
vtBinary=9
vtAutoAssembler=11
vtPointer=12 --Only used by autoguess and structures
vtCustom=13
vtGrouped=14
CustomTypeName : string
If the type is vtCustomType this will contain the name of the CustomType
Script : string
If the type is vtAutoAssembler this will contain the auto assembler script
Value : string
The value in stringform.
IsGroupHeader : boolean
Set to true to change the memory record into a group header.
All properties and functions related to address, type, and value are ignored when true.
Selected : boolean
Set to true if selected (ReadOnly)
Active : boolean
Set to true to activate/freeze, false to deactivate/unfreeze
Color : integer
The memory record's RGB color integer.
ShowAsHex : boolean
Self explanatory
ShowAsSigned : boolean
Self explanatory
AllowIncrease : boolean
Allow value increasing, unfreeze will reset it to false
AllowDecrease : boolean
Allow value decreasing, unfreeze will reset it to false
Count : integer
Number of children
Child[index] : MemoryRecord
Array to access the child records
HotkeyCount : integer
Number of hotkeys attached to this memory record.
Hotkey[index] : GenericHotkey
Array to index the hotkeys.
Options : string
A string of the set "Group Config" options in the format '[optionName,...]'
Valid options are:
moHideChildren
moActivateChildrenAsWell
moDeactivateChildrenAsWell
moRecursiveSetValue
moAllowManualCollapseAndExpand
moManualExpandCollapse
example: '[moHideChildren,moAllowManualCollapseAndExpand,moManualExpandCollapse]'
Collapsed : boolean
only works when manual expand/collapse is set in group config options (moManualExpandCollapse)
OnActivate : function(memoryrecord, before, currentstate) : boolean
The function to call when the memoryrecord will change (or changed) Active to true.
If before is true, not returning true will cause the activation to stop.
OnDeactivate : function(memoryrecord,before,currentstate) : boolean
The function to call when the memoryrecord will change (or changed) Active to false.
If before is true, not returning true will cause the deactivation to stop.
OnDestroy : function
Called when the memoryrecord is destroyed.
DontSave : boolean
Don't save this memoryrecord and it's children
DropDownLinked: boolean
if dropdown list refers to list of another memory record eg. (memrec name)
DropDownLinkedMemrec: string
Description of linked memrec or emptystring if not linked
DropDownList: StringList
list of "value:description" lines, lists are still separate objects when linked, read-write
DropDownReadOnly: boolean
true if 'Disallow manual user input' is set
DropDownDescriptionOnly: boolean
self explanatory
DisplayAsDropDownListItem: boolean
self explanatory
DropDownCount: integer
equivalent to .DropDownList.Count
DropDownValue: Array
Array to access values in DropDownList (ReadOnly)
DropDownDescription: Array
Array to access Descriptions in DropDownList (ReadOnly)

Methods[edit]

getDescription() : string
Returns the memory record's description.
setDescription()
Sets the memory record's description.
getAddress() : integer - (integer, table)
Returns the interpretable addressstring of this record.
If it is a pointer, it returns a second result as a table filled with the offsets
setAddress(string)
Sets the interpretable address string, and if offsets are provided make it a pointer
getOffsetCount() : integer
Returns the number of offsets for this memoryrecord
setOffsetCount(integer)
Lets you set the number of offsets
getOffset(index) : integer
Gets the offset at the given index
setOffset(index, value)
Sets the offset at the given index
getCurrentAddress() : integer
Returns the current address as an integer (the final result of the interpretable address and pointer offsets)
appendToEntry(memrec)
Appends the current memory record to the given memory record
getHotkey(index) : GenericHotkey
Returns the hotkey from the hotkey array
getHotkeyByID(integer) : GenericHotkey
Returns the hotkey with the given id
[index
MemoryRecord
Same as 'Child[index]'
Default accessor.

Examples[edit]

 local addressList = getAddressList()
 local mrHealth = addressList.getMemoryRecordByDescription('Health')
 print(mrHealth.Description)
 print(mrHealth.Active and 'True' or 'False')

See also[edit]

Related Functions[edit]

Related Classes[edit]