Difference between revisions of "Lua:Class:MemoryRecord"

From Cheat Engine
Jump to navigation Jump to search
(Properties)
Line 1: Line 1:
--Under Construction
+
MemoryRecord '''class''': ('''Inheritance''': ''[[Object]]'')
 
 
The class MemoryRecord are the entries in Cheat tables. This class is commonly used with [[Addresslist]].
 
 
 
 
 
'''MemoryRecord Class'''
 
  The Memoryrecord class object describes a Cheat Table's Cheat Entry.
 
 
 
 
 
----
 
  
 +
The memory record objects are the entries you see in the address list.
  
 
== Properties ==
 
== Properties ==
  ID: Integer - Unique ID
+
; ID : integer
  Index: Integer - The index ID for this record. 0 is top. (ReadOnly)
+
: Unique ID.
  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[] : integer - Array to access each offset
 
  OffsetText[] : string - Array to access each offset using the interpretable text style
 
  CurrentAddress: integer - The address the memoryrecord points to
 
  Type: ValueType - 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
 
  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.
 
  Selected: boolean - Set to true if selected (ReadOnly)
 
  Active: boolean - Set to true to activate/freeze, false to deactivate/unfreeze
 
  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
 
  Collapsed: boolean - Set to true to collapse this record or false to expand it. Use expand/collapse methods for recursive operations.
 
  IsGroupHeader: boolean - Set to true if the record was created as a Group Header with no address or value info. (ReadOnly)
 
  IsReadable: boolean - Set to false if record contains an unreadable address. NOTE: This property will not be set until the value property is accessed at least once. (ReadOnly)
 
  Count: Number of children
 
  Child[index] : Array to access the child records
 
  [index] = Child[index]
 
  HotkeyCount: integer - Number of hotkeys attached to this memory record
 
  Hotkey[] : Array to index the hotkeys
 
  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.
 
  OnGetDisplayValue: function(memoryrecord,valuestring):boolean,string - This function gets called when rendering the value of a memory record. Return true and a new string to override the value shown
 
  DontSave: boolean - Don't save this memoryrecord and it's children
 
  
== Methods ==
+
; Index : integer
 +
: The index ID for this record. 0 is top. (ReadOnly)
  
 +
; Description : string- The description of the memory record.
  
'''getID'''()
+
; Address : string
  Returns the unique id of this memory record. Every memory record has an unique id
+
: Get/set the interpretable address string. Useful for simple address settings.
  
 +
; OffsetCount : integer
 +
: The number of offsets. Set to 0 for a normal address.
  
'''getHotkeyCount'''()
+
; Offset[''index''] : integer
  Returns the number of hotkeys assigned to this Cheat Entry
+
: Array to access each offset.
  
 +
; CurrentAddress : integer
 +
: The address the memoryrecord points to.
  
'''getHotkey'''(index)
+
; Type : [[ValueType]]
  Returns a memoryrecordhotkey class
+
: 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
  
 +
; CustomTypeName : string
 +
: If the type is vtCustomType this will contain the name of the CustomType
  
'''getHotkeyByID'''(ID)
+
; Script : 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)
+
: If the type is vtAutoAssembler this will contain the auto assembler script
  
 +
; Value : string
 +
: The value in stringform.
  
'''setDescription'''(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
  
'''getDescription'''()
+
; Color : integer
  Gets the current description of this entry
+
: The memory record's RBG color integer.
  
 +
; ShowAsHex : boolean
 +
: Self explanatory
  
'''getAddress'''()
+
; 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
  
'''setAddress'''(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
  
'''getType'''() 
+
; 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.
  
'''setType'''(vartype) 
+
; Hotkey[''index''] : [[GenericHotkey]]
  Sets the type of the entry
+
: Array to index the hotkeys.
  
 +
; 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.
  
'''getValue'''()  
+
; OnDeactivate : function(memoryrecord,before,currentstate) : boolean
  Returns the current value of the cheat table entry as a string
+
: 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.
  
'''setValue'''(value)
+
; DontSave : boolean
  Sets the value of a cheat table entry
+
: Don't save this memoryrecord and it's children
  
 +
== Methods ==
 +
; getDescription() : string
 +
: Returns the memory record's dexcription.
  
'''getScript'''() 
+
; setDescription()
  If the entry is of type vtAutoAssembler then you can get the script with this routine
+
: Sets the memory record's dexcription.
 
 
 
 
'''setScript'''(script)
 
 
 
 
 
'''isActive'''()
 
 
 
 
 
'''freeze'''(updownfreeze OPTIONAL)
 
  Sets the entry to frozen state. updownfreeze is optional. 0=freeze, 1=allow increase, 2=allow decrease
 
 
 
 
 
'''unfreeze'''()
 
  Unfreezes an entry
 
 
 
 
 
'''setColor'''(colorrgb)  
 
  Sets the color of the entry
 
 
 
 
 
'''appendToEntry'''(memoryrecord) 
 
  Adds the entry to another entry
 
 
 
 
 
'''delete'''()
 
  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...
 
 
 
 
 
'''onActivate'''(, function)
 
  Registers a function to be called when a cheat entry is Activated
 
    function (memoryrecord, before, currentstate) boolean
 
    If before is true returning false will cause the activation to stop
 
 
 
 
 
'''onDeactivate'''(function)
 
  Registers a function to be called when a cheat entry is Deactivated
 
    function (memoryrecord, before, currentstate) boolean
 
    If before is true returning false will cause the deactivation to stop
 
 
 
  
'''onDestroy'''(function)  
+
; getAddress() : integer - (integer, table)
  Registers a function to be called when a cheat entry is delete
+
: Returns the interpretable addressstring of this record.
    function (memoryrecord)
+
: 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
  
Example:
+
; setOffsetCount(integer)
<pre>
+
: Lets you set the number of offsets
al = getAddressList()
 
description1= [[Health]]
 
description2= [[Health Pointer]]
 
memoryrec1 = al.getMemoryRecordByDescription(description1)
 
memoryrec2 = al.getMemoryRecordByDescription(description2)
 
  
desc = memoryrec1.Description    --Gets the current memoryrecord's description
+
; getOffset(index) &#58; integer
print(desc)
+
: Gets the offset at the given index
  
memoryrec1.Description=[[My new health description]]  --sets the memorydescription
+
; setOffset(index, value)
 +
: Sets the offset at the given index
  
 +
; getCurrentAddress() &#58; integer
 +
: Returns the current address as an integer (the final result of the interpretable address and pointer offsets)
  
value = memoryrec2.Value  --Gets the current value of the memory record.
+
; appendToEntry(memrec)
print(value)
+
: Appends the current memory record to the given memory record
  
newvalue = 66
+
; getHotkey(index) &#58; [[GenericHotkey]]
memoryrec2.Value=newvalue  --sets value for the memoryrecord
+
: Returns the hotkey from the hotkey array
  
if memoryrecord.Active then  --Checks if memoryrecord is in frozen state or not
+
; getHotkeyByID(integer) &#58; [[GenericHotkey]]
else
+
: Returns the hotkey with the given id
memoryrec2.Active=false  -- freezes the memoryrecord, to unfreeze use memoryrecord_freeze
 
end
 
  
memoryrec2.Color=0x0000ff --Sets the color of the memoryrecord. Here Red. Color range {0x000000 to 0xFFFFFF)
+
== Examples ==
 +
local addressList = getAddressList()
 +
local mrHealth = addressList.getMemoryRecordByDescription('Health')
 +
print(mrHealth.Description)
 +
print(mrHealth.Active and 'Ture' or 'False')
  
count = memoryrec2.HotkeyCount --Gets number of hotkeys associated with memoryrecord
+
== See also ==
print(count)                                    --From the image, We can see it is 2.   
+
* [[Lua]]
 +
* [[Help_File:Script engine|Script engine]]
  
----
+
=== Related Functions ===
 +
* [[getMainForm]]
 +
* [[getAddressList]]
  
* [[Lua|Lua Functions and Classes]]
+
=== Related Classes ===
 +
* [[Addresslist]]

Revision as of 07:38, 11 March 2017

MemoryRecord class: (Inheritance: Object)

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)
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 : ValueType
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
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.
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 RBG 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.
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

Methods

getDescription() : string
Returns the memory record's dexcription.
setDescription()
Sets the memory record's dexcription.
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

Examples

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

See also

Related Functions

Related Classes