Difference between revisions of "Lua:Class:MemoryRecord"
Jump to navigation
Jump to search
m (Link to GenericHotkey) |
|||
(27 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
− | + | [[Category:Lua]] | |
+ | MemoryRecord '''class''': ('''Inheritance''': ''[[Lua:Class:Object|Object]]'') | ||
− | + | The MemoryRecord class represents an entry in the Cheat Engine address list. | |
− | + | Each memory record can represent an address, pointer, script, or group header, and provides access to its properties, children, hotkeys, and events. | |
+ | == Properties == | ||
+ | {| class="wikitable" style="width:100%" | ||
+ | ! Property | ||
+ | ! Type | ||
+ | ! Description | ||
+ | |- | ||
+ | | ID | ||
+ | | Integer | ||
+ | | Unique ID of the memory record. | ||
+ | |- | ||
+ | | Index | ||
+ | | Integer | ||
+ | | The index of this record in the address list (0 is top, ReadOnly). | ||
+ | |- | ||
+ | | Description | ||
+ | | String | ||
+ | | The description of the memory record. | ||
+ | |- | ||
+ | | Address | ||
+ | | String | ||
+ | | Get/set the interpretable address string. | ||
+ | |- | ||
+ | | AddressString | ||
+ | | String | ||
+ | | The address string shown in CE (ReadOnly). | ||
+ | |- | ||
+ | | 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 interpretable text style. | ||
+ | |- | ||
+ | | CurrentAddress | ||
+ | | Integer | ||
+ | | The address the memory record points to. | ||
+ | |- | ||
+ | | VarType | ||
+ | | ValueType (string) | ||
+ | | The variable type of this record. See vtByte to vtCustom. | ||
+ | |- | ||
+ | | Type | ||
+ | | ValueType (number) | ||
+ | | The variable type of this record. See vtByte to vtCustom. | ||
+ | |- | ||
+ | | CustomTypeName | ||
+ | | String | ||
+ | | If the type is vtCustom, this contains the name of the CustomType. | ||
+ | |- | ||
+ | | 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. | ||
+ | |- | ||
+ | | Selected | ||
+ | | Boolean | ||
+ | | True if selected (ReadOnly). | ||
+ | |- | ||
+ | | Active | ||
+ | | Boolean | ||
+ | | Set to true to activate/freeze, false to deactivate/unfreeze. | ||
+ | |- | ||
+ | | Color | ||
+ | | Integer | ||
+ | | The color of the memory record. | ||
+ | |- | ||
+ | | ShowAsHex | ||
+ | | Boolean | ||
+ | | Show value as hexadecimal. | ||
+ | |- | ||
+ | | ShowAsSigned | ||
+ | | Boolean | ||
+ | | Show value as signed. | ||
+ | |- | ||
+ | | AllowIncrease | ||
+ | | Boolean | ||
+ | | Allow value increasing; unfreeze resets to false. | ||
+ | |- | ||
+ | | AllowDecrease | ||
+ | | Boolean | ||
+ | | Allow value decreasing; unfreeze resets to false. | ||
+ | |- | ||
+ | | Collapsed | ||
+ | | Boolean | ||
+ | | Set to true to collapse this record, false to expand. | ||
+ | |- | ||
+ | | IsGroupHeader | ||
+ | | Boolean | ||
+ | | True if the record is a group header with no address or value info. | ||
+ | |- | ||
+ | | IsAddressGroupHeader | ||
+ | | Boolean | ||
+ | | True if the record is a group header with address. | ||
+ | |- | ||
+ | | IsReadable | ||
+ | | Boolean | ||
+ | | False if record contains an unreadable address (ReadOnly, set after value is accessed). | ||
+ | |- | ||
+ | | Options | ||
+ | | String set | ||
+ | | A string enclosed by square brackets with options separated by commas (e.g., [moHideChildren,moActivateChildrenAsWell]). | ||
+ | |- | ||
+ | | DropDownLinked | ||
+ | | Boolean | ||
+ | | True if dropdown list refers to another memory record's list. | ||
+ | |- | ||
+ | | DropDownLinkedMemrec | ||
+ | | String | ||
+ | | Description of linked memory record or empty string if not linked. | ||
+ | |- | ||
+ | | DropDownList | ||
+ | | StringList | ||
+ | | List of "value:description" lines; 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[index] | ||
+ | | String | ||
+ | | Array to access values in DropDownList (ReadOnly). | ||
+ | |- | ||
+ | | DropDownDescription[index] | ||
+ | | String | ||
+ | | Array to access descriptions in DropDownList (ReadOnly). | ||
+ | |- | ||
+ | | Count | ||
+ | | Integer | ||
+ | | Number of child records. | ||
+ | |- | ||
+ | | Child[index] | ||
+ | | MemoryRecord | ||
+ | | Array to access child records. | ||
+ | |- | ||
+ | | Parent | ||
+ | | MemoryRecord | ||
+ | | The parent of the memory record. | ||
+ | |- | ||
+ | | HotkeyCount | ||
+ | | Integer | ||
+ | | Number of hotkeys attached to this memory record. | ||
+ | |- | ||
+ | | Hotkey[index] | ||
+ | | [[Lua:Class:GenericHotkey|GenericHotkey]] | ||
+ | | Array to index the hotkeys. | ||
+ | |- | ||
+ | | Async | ||
+ | | Boolean | ||
+ | | Set to true if activating this entry will be asynchronous (only for AA/Lua scripts). | ||
+ | |- | ||
+ | | AsyncProcessing | ||
+ | | Boolean | ||
+ | | True when async is true and it's being processed. | ||
+ | |- | ||
+ | | AsyncProcessingTime | ||
+ | | Qword | ||
+ | | The time that it has been processing in milliseconds. | ||
+ | |- | ||
+ | | HasMouseOver | ||
+ | | Boolean | ||
+ | | True if the mouse is currently over it. | ||
+ | |- | ||
+ | | DontSave | ||
+ | | Boolean | ||
+ | | Don't save this memoryrecord and its children. | ||
+ | |} | ||
− | ''' | + | === Special Properties by Type === |
− | + | * '''vtString''': <code>String.Size</code>, <code>String.Unicode</code>, <code>String.Codepage</code> | |
+ | * '''vtBinary''': <code>Binary.Startbit</code>, <code>Binary.Size</code> | ||
+ | * '''vtByteArray''': <code>Aob.Size</code> | ||
+ | == Variable Types == | ||
+ | {| class="wikitable" style="width:60%" | ||
+ | ! Constant | ||
+ | ! Value | ||
+ | ! Description | ||
+ | |- | ||
+ | | vtByte | ||
+ | | 0 | ||
+ | | 1 byte (unsigned) | ||
+ | |- | ||
+ | | vtWord | ||
+ | | 1 | ||
+ | | 2 bytes (unsigned) | ||
+ | |- | ||
+ | | vtDword | ||
+ | | 2 | ||
+ | | 4 bytes (unsigned) | ||
+ | |- | ||
+ | | vtQword | ||
+ | | 3 | ||
+ | | 8 bytes (unsigned) | ||
+ | |- | ||
+ | | vtSingle | ||
+ | | 4 | ||
+ | | 4 bytes (float) | ||
+ | |- | ||
+ | | vtDouble | ||
+ | | 5 | ||
+ | | 8 bytes (double/float) | ||
+ | |- | ||
+ | | vtString | ||
+ | | 6 | ||
+ | | String (ASCII) | ||
+ | |- | ||
+ | | vtUnicodeString<br>vtWideString | ||
+ | | 7 | ||
+ | | Unicode string (Only used by autoguess) | ||
+ | |- | ||
+ | | vtByteArray | ||
+ | | 8 | ||
+ | | Array of bytes | ||
+ | |- | ||
+ | | vtBinary | ||
+ | | 9 | ||
+ | | Binary (bitfield) | ||
+ | |- | ||
+ | | vtAll | ||
+ | | 10 | ||
+ | | All types (used for scans) | ||
+ | |- | ||
+ | | vtAutoAssembler | ||
+ | | 11 | ||
+ | | Auto Assembler script | ||
+ | |- | ||
+ | | vtPointer | ||
+ | | 12 | ||
+ | | Pointer (Only used by autoguess and structures) | ||
+ | |- | ||
+ | | vtCustom | ||
+ | | 13 | ||
+ | | Custom type | ||
+ | |- | ||
+ | | vtGrouped | ||
+ | | 14 | ||
+ | | Grouped type | ||
+ | |} | ||
− | + | == MemoryRecord Options == | |
− | |||
+ | The following options can be set in the `Options` property of a MemoryRecord. | ||
+ | The value is a string enclosed in square brackets, with options separated by commas (e.g., `[moHideChildren,moActivateChildrenAsWell]`). | ||
− | + | {| class="wikitable" style="width:60%" | |
− | + | ! 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 will also set the value of all children recursively. | ||
+ | |- | ||
+ | | moAllowManualCollapseAndExpand | ||
+ | | Allows the user to manually collapse or expand this record in the address list. | ||
+ | |- | ||
+ | | moManualExpandCollapse | ||
+ | | Enables manual expand/collapse behavior for this record. | ||
+ | |- | ||
+ | | moAlwaysHideChildren | ||
+ | | Always hides the children, regardless of other settings. | ||
+ | |} | ||
+ | == Methods == | ||
+ | {| class="wikitable" style="width:100%" | ||
+ | ! Method | ||
+ | ! Parameters | ||
+ | ! Returns | ||
+ | ! Description | ||
+ | |- | ||
+ | | getDescription | ||
+ | | None | ||
+ | | String | ||
+ | | Gets the description. | ||
+ | |- | ||
+ | | setDescription | ||
+ | | String | ||
+ | | None | ||
+ | | Sets the description. | ||
+ | |- | ||
+ | | getAddress | ||
+ | | None | ||
+ | | String, Table | ||
+ | | Returns the interpretable address string. If pointer, returns a table of offsets as second result. | ||
+ | |- | ||
+ | | setAddress | ||
+ | | String | ||
+ | | None | ||
+ | | Sets the interpretable address string (and offsets if pointer). | ||
+ | |- | ||
+ | | getOffsetCount | ||
+ | | None | ||
+ | | Integer | ||
+ | | Returns the number of offsets. | ||
+ | |- | ||
+ | | setOffsetCount | ||
+ | | Integer | ||
+ | | None | ||
+ | | Sets the number of offsets. | ||
+ | |- | ||
+ | | getOffset | ||
+ | | Integer (index) | ||
+ | | Integer | ||
+ | | Gets the offset at the given index. | ||
+ | |- | ||
+ | | setOffset | ||
+ | | Integer (index), Integer (value) | ||
+ | | None | ||
+ | | Sets the offset at the given index. | ||
+ | |- | ||
+ | | getCurrentAddress | ||
+ | | None | ||
+ | | Integer | ||
+ | | Returns the current address as an integer. | ||
+ | |- | ||
+ | | appendToEntry | ||
+ | | MemoryRecord | ||
+ | | None | ||
+ | | Appends the current memory record to the given memory record. | ||
+ | |- | ||
+ | | getHotkey | ||
+ | | Integer (index) | ||
+ | | MemoryRecordHotkey | ||
+ | | Returns the hotkey from the hotkey array. | ||
+ | |- | ||
+ | | getHotkeyByID | ||
+ | | Integer (id) | ||
+ | | MemoryRecordHotkey | ||
+ | | Returns the hotkey with the given id. | ||
+ | |- | ||
+ | | reinterpret | ||
+ | | None | ||
+ | | None | ||
+ | | Reinterprets the memory record. | ||
+ | |- | ||
+ | | createHotkey | ||
+ | | Table (keys), Integer (action), String (value, optional), String (description, optional) | ||
+ | | MemoryRecordHotkey | ||
+ | | Creates a hotkey object. | ||
+ | |- | ||
+ | | disableWithoutExecute | ||
+ | | None | ||
+ | | None | ||
+ | | Sets the entry to disabled without executing the disable section. | ||
+ | |- | ||
+ | | beginEdit | ||
+ | | None | ||
+ | | None | ||
+ | | Call when you wish to take a long time to edit a record. | ||
+ | |- | ||
+ | | endEdit | ||
+ | | None | ||
+ | | None | ||
+ | | Marks the end of your long edit sequence. | ||
+ | |} | ||
− | + | == Events / Callbacks == | |
− | + | {| class="wikitable" style="width:100%" | |
+ | ! Event | ||
+ | ! Parameters | ||
+ | ! Description | ||
+ | |- | ||
+ | | OnActivate | ||
+ | | function(memoryrecord, before, currentstate):boolean | ||
+ | | Called 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 | ||
+ | | Called when the memoryrecord will change (or changed) Active to false. If before is true, not returning true will cause the deactivation to stop. | ||
+ | |- | ||
+ | | OnActivationFailure | ||
+ | | function(memoryrecord, reason, reasonText) | ||
+ | | Called when activating a record fails. Return true to try again (be careful of infinite loops). | ||
+ | |- | ||
+ | | OnDestroy | ||
+ | | function() | ||
+ | | Called when the memoryrecord is destroyed. | ||
+ | |- | ||
+ | | OnGetDisplayValue | ||
+ | | function(memoryrecord, valuestring):boolean,string | ||
+ | | Called when rendering the value of a memory record. Return true and a new string to override the value shown. | ||
+ | |- | ||
+ | | 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 changed by the user. | ||
+ | |} | ||
+ | == Global Events == | ||
+ | <pre> | ||
+ | function onMemRecPreExecute(memoryrecord, newstate BOOLEAN) | ||
+ | -- Called before action is performed. Active property is about to change to newState. | ||
+ | end | ||
− | + | function onMemRecPostExecute(memoryrecord, newState BOOLEAN, succeeded BOOLEAN) | |
− | + | -- Called after action is performed. Active property was supposed to change to newState. | |
− | + | -- If 'succeeded' is true, Active state has changed and is newState. | |
− | + | end | |
− | + | </pre> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | == Examples == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<pre> | <pre> | ||
− | + | -- Get the first memory record in the address list | |
− | + | local mr = AddressList[0] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | -- Print some basic properties | |
+ | print("ID:", mr.ID) | ||
+ | print("Description:", mr.Description) | ||
+ | print("Address:", mr.Address) | ||
+ | print("Current Value:", mr.Value) | ||
+ | print("Active:", mr.Active) | ||
+ | -- Change the value and activate the record | ||
+ | mr.Value = "999" | ||
+ | mr.Active = true | ||
+ | </pre> | ||
− | + | {{LuaSeeAlso}} | |
− | |||
− | + | === Related Functions === | |
− | + | * [[Lua:getMainForm|getMainForm]] | |
+ | * [[Lua:getAddressList|getAddressList]] | ||
− | + | === Related Classes === | |
− | + | * [[Lua:Class:Addresslist|Addresslist]] | |
− | |||
− |
Latest revision as of 13:39, 11 July 2025
MemoryRecord class: (Inheritance: Object)
The MemoryRecord class represents an entry in the Cheat Engine address list. Each memory record can represent an address, pointer, script, or group header, and provides access to its properties, children, hotkeys, and events.
Contents
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 top, ReadOnly). |
Description | String | The description of the memory record. |
Address | String | Get/set the interpretable address string. |
AddressString | String | The address string shown in CE (ReadOnly). |
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 interpretable text style. |
CurrentAddress | Integer | The address the memory record points to. |
VarType | ValueType (string) | The variable type of this record. See vtByte to vtCustom. |
Type | ValueType (number) | The variable type of this record. See vtByte to vtCustom. |
CustomTypeName | String | If the type is vtCustom, this contains the name of the CustomType. |
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. |
Selected | Boolean | True if selected (ReadOnly). |
Active | Boolean | Set to true to activate/freeze, false to deactivate/unfreeze. |
Color | Integer | The color of the memory record. |
ShowAsHex | Boolean | Show value as hexadecimal. |
ShowAsSigned | Boolean | Show value as signed. |
AllowIncrease | Boolean | Allow value increasing; unfreeze resets to false. |
AllowDecrease | Boolean | Allow value decreasing; unfreeze resets to false. |
Collapsed | Boolean | Set to true to collapse this record, false to expand. |
IsGroupHeader | Boolean | True if the record is a group header with no address or value info. |
IsAddressGroupHeader | Boolean | True if the record is a group header with address. |
IsReadable | Boolean | False if record contains an unreadable address (ReadOnly, set after value is accessed). |
Options | String set | A string enclosed by square brackets with options separated by commas (e.g., [moHideChildren,moActivateChildrenAsWell]). |
DropDownLinked | Boolean | True if dropdown list refers to another memory record's list. |
DropDownLinkedMemrec | String | Description of linked memory record or empty string if not linked. |
DropDownList | StringList | List of "value:description" lines; 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[index] | String | Array to access values in DropDownList (ReadOnly). |
DropDownDescription[index] | String | Array to access descriptions in DropDownList (ReadOnly). |
Count | Integer | Number of child records. |
Child[index] | MemoryRecord | Array to access child records. |
Parent | MemoryRecord | The parent of the memory record. |
HotkeyCount | Integer | Number of hotkeys attached to this memory record. |
Hotkey[index] | GenericHotkey | Array to index the hotkeys. |
Async | Boolean | Set to true if activating this entry will be asynchronous (only for AA/Lua scripts). |
AsyncProcessing | Boolean | True when async is true and it's being processed. |
AsyncProcessingTime | Qword | The time that it has been processing in milliseconds. |
HasMouseOver | Boolean | True if the mouse is currently over it. |
DontSave | Boolean | Don't save this memoryrecord and its children. |
Special Properties by Type[edit]
- vtString:
String.Size
,String.Unicode
,String.Codepage
- vtBinary:
Binary.Startbit
,Binary.Size
- vtByteArray:
Aob.Size
Variable Types[edit]
Constant | Value | Description |
---|---|---|
vtByte | 0 | 1 byte (unsigned) |
vtWord | 1 | 2 bytes (unsigned) |
vtDword | 2 | 4 bytes (unsigned) |
vtQword | 3 | 8 bytes (unsigned) |
vtSingle | 4 | 4 bytes (float) |
vtDouble | 5 | 8 bytes (double/float) |
vtString | 6 | String (ASCII) |
vtUnicodeString vtWideString |
7 | Unicode string (Only used by autoguess) |
vtByteArray | 8 | Array of bytes |
vtBinary | 9 | Binary (bitfield) |
vtAll | 10 | All types (used for scans) |
vtAutoAssembler | 11 | Auto Assembler script |
vtPointer | 12 | Pointer (Only used by autoguess and structures) |
vtCustom | 13 | Custom type |
vtGrouped | 14 | Grouped type |
MemoryRecord Options[edit]
The following options can be set in the `Options` property of a MemoryRecord. The value is a string enclosed in square brackets, with options separated by commas (e.g., `[moHideChildren,moActivateChildrenAsWell]`).
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 will also set the value of all children recursively. |
moAllowManualCollapseAndExpand | Allows the user to manually collapse or expand this record in the address list. |
moManualExpandCollapse | Enables manual expand/collapse behavior for this record. |
moAlwaysHideChildren | Always hides the children, regardless of other settings. |
Methods[edit]
Method | Parameters | Returns | Description |
---|---|---|---|
getDescription | None | String | Gets the description. |
setDescription | String | None | Sets the description. |
getAddress | None | String, Table | Returns the interpretable address string. If pointer, returns a table of offsets as second result. |
setAddress | String | None | Sets the interpretable address string (and offsets if pointer). |
getOffsetCount | None | Integer | Returns the number of offsets. |
setOffsetCount | Integer | None | Sets the number of offsets. |
getOffset | Integer (index) | Integer | Gets the offset at the given index. |
setOffset | Integer (index), Integer (value) | None | Sets the offset at the given index. |
getCurrentAddress | None | Integer | Returns the current address as an integer. |
appendToEntry | MemoryRecord | None | Appends the current memory record to the given memory record. |
getHotkey | Integer (index) | MemoryRecordHotkey | Returns the hotkey from the hotkey array. |
getHotkeyByID | Integer (id) | MemoryRecordHotkey | Returns the hotkey with the given id. |
reinterpret | None | None | Reinterprets the memory record. |
createHotkey | Table (keys), Integer (action), String (value, optional), String (description, optional) | MemoryRecordHotkey | Creates a hotkey object. |
disableWithoutExecute | None | None | Sets the entry to disabled without executing the disable section. |
beginEdit | None | None | Call when you wish to take a long time to edit a record. |
endEdit | None | None | Marks the end of your long edit sequence. |
Events / Callbacks[edit]
Event | Parameters | Description |
---|---|---|
OnActivate | function(memoryrecord, before, currentstate):boolean | Called 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 | Called when the memoryrecord will change (or changed) Active to false. If before is true, not returning true will cause the deactivation to stop. |
OnActivationFailure | function(memoryrecord, reason, reasonText) | Called when activating a record fails. Return true to try again (be careful of infinite loops). |
OnDestroy | function() | Called when the memoryrecord is destroyed. |
OnGetDisplayValue | function(memoryrecord, valuestring):boolean,string | Called when rendering the value of a memory record. Return true and a new string to override the value shown. |
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 changed by the user. |
Global Events[edit]
function onMemRecPreExecute(memoryrecord, newstate BOOLEAN) -- Called before action is performed. Active property is about to change to newState. end function onMemRecPostExecute(memoryrecord, newState BOOLEAN, succeeded BOOLEAN) -- Called after action is performed. Active property was supposed to change to newState. -- If 'succeeded' is true, Active state has changed and is newState. end
Examples[edit]
-- Get the first memory record in the address list local mr = AddressList[0] -- Print some basic properties print("ID:", mr.ID) print("Description:", mr.Description) print("Address:", mr.Address) print("Current Value:", mr.Value) print("Active:", mr.Active) -- Change the value and activate the record mr.Value = "999" mr.Active = true