Difference between revisions of "Lua:Class:MemoryRecord"

From Cheat Engine
Jump to navigation Jump to search
(Properties)
(Properties)
Line 19: Line 19:
 
   Offset[] : integer - Array to access each offset
 
   Offset[] : integer - Array to access each offset
 
   OffsetText[] : string - Array to access each offset using the interpretable text style
 
   OffsetText[] : string - Array to access each offset using the interpretable text style
 
 
   CurrentAddress: integer - The address the memoryrecord points to
 
   CurrentAddress: integer - The address the memoryrecord points to
 
   Type: ValueType - The variable type of this record. See vtByte to vtCustom
 
   Type: ValueType - The variable type of this record. See vtByte to vtCustom
Line 25: Line 24:
 
     String.Size: Number of characters in the string
 
     String.Size: Number of characters in the string
 
     String.Unicode: boolean
 
     String.Unicode: boolean
 
 
     If the type is vtBinary then the following properties are available
 
     If the type is vtBinary then the following properties are available
 
       Binary.Startbit: First bit to start reading from
 
       Binary.Startbit: First bit to start reading from
 
       Binary.Size : Number of bits
 
       Binary.Size : Number of bits
 
 
     If the type is vtByteArray then the following properties are available
 
     If the type is vtByteArray then the following properties are available
 
       Aob.Size : Number of bytes
 
       Aob.Size : Number of bytes
 
 
   CustomTypeName: String - If the type is vtCustomType this will contain the name of the CustomType
 
   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
 
   Script: String - If the type is vtAutoAssembler this will contain the auto assembler script
Line 46: Line 42:
 
   IsGroupHeader: boolean - Set to true if the record was created as a Group Header with no address or value info. (ReadOnly)
 
   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)
 
   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
 
   Count: Number of children
 
   Child[index] : Array to access the child records
 
   Child[index] : Array to access the child records
 
   [index] = Child[index]
 
   [index] = Child[index]
 
 
   HotkeyCount: integer - Number of hotkeys attached to this memory record
 
   HotkeyCount: integer - Number of hotkeys attached to this memory record
 
   Hotkey[] : Array to index the hotkeys
 
   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.
 
   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.
 
   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.

Revision as of 19:58, 17 January 2017

--Under Construction

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.




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[] : 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

getID()

 Returns the unique id of this memory record. Every memory record has an unique id


getHotkeyCount()

 Returns the number of hotkeys assigned to this Cheat Entry


getHotkey(index)

 Returns a memoryrecordhotkey class


getHotkeyByID(ID)

 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)


setDescription(description)

 Sets the specified description for this entry


getDescription()

 Gets the current description of this entry


getAddress()

 Returns the address and optional offsets for a pointer (note that in 64-bit kernelmode addresses will be rounded down...)


setAddress(address,offsets OPTIONAL)

 Sets the address of a entry. You can give as many offsets as you need


getType()

 Returns the Variable type. (vtByte to vtCustom)


setType(vartype)

 Sets the type of the entry


getValue()

 Returns the current value of the cheat table entry as a string


setValue(value)

 Sets the value of a cheat table entry


getScript()

 If the entry is of type vtAutoAssembler then you can get the script with this routine


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)

 Registers a function to be called when a cheat entry is delete
   function (memoryrecord)


Example:

al = getAddressList()
description1= Health
description2= Health Pointer
memoryrec1 = al.getMemoryRecordByDescription(description1)
memoryrec2 = al.getMemoryRecordByDescription(description2)

desc = memoryrec1.Description    --Gets the current memoryrecord's description
print(desc)

memoryrec1.Description=My new health description  --sets the memorydescription


value = memoryrec2.Value  --Gets the current value of the memory record.
print(value)

newvalue = 66
memoryrec2.Value=newvalue   --sets value for the memoryrecord

if memoryrecord.Active then   --Checks if memoryrecord is in frozen state or not
else
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)

count = memoryrec2.HotkeyCount --Gets number of hotkeys associated with memoryrecord
print(count)                                     --From the image, We can see it is 2.     


* Lua Functions and Classes