Difference between revisions of "Lua:Class:MemoryRecordHotkey"

From Cheat Engine
Jump to navigation Jump to search
(Initial page creation.)
 
m (Syntax Highlighting.)
 
Line 114: Line 114:
  
 
===Examples===
 
===Examples===
<pre>
+
<syntaxhighlight lang="lua" line>
 
-- List all hotkeys for a memory record
 
-- List all hotkeys for a memory record
 
local mr = AddressList[0]
 
local mr = AddressList[0]
Line 130: Line 130:
 
-- Execute a hotkey manually
 
-- Execute a hotkey manually
 
hk:doHotkey()
 
hk:doHotkey()
</pre>
+
</syntaxhighlight>
  
 
== See also ==
 
== See also ==
 
* [[Lua:Class:MemoryRecord|MemoryRecord]]
 
* [[Lua:Class:MemoryRecord|MemoryRecord]]
 
* [[Lua:AddressList|AddressList]]
 
* [[Lua:AddressList|AddressList]]

Latest revision as of 18:49, 25 June 2026

class MemoryRecordHotkey (Inheritance: Object)

The MemoryRecordHotkey class represents a hotkey attached to a memory record. It is mainly read-only, except for event properties used for trainer creation. For custom hotkeys not tied to memory records, use the generic hotkey class.

Properties[edit]

Property Type Description
Owner MemoryRecord The memory record this hotkey belongs to (ReadOnly).
Keys Table Table containing the key combination for this hotkey.
action Integer The action that should happen when this hotkey triggers. See action values below.
value String Value used depending on the hotkey type (see action).
ID Integer Unique ID of this hotkey (ReadOnly).
Active Boolean True if this hotkey will be handled, false if ignored.
Description String The description of this hotkey.
HotkeyString String The hotkey formatted as a string (ReadOnly).
ActivateSound String Tablefile name of a WAV file inside the table to play on activate events.
DeactivateSound String Tablefile name of a WAV file inside the table to play on deactivate events.
OnHotkey Function(sender) Function called when a hotkey has just been pressed.
OnPostHotkey Function(sender) Function called when a hotkey has been pressed and the action has been performed.

Action Values[edit]

Constant Value Description
mrhToggleActivation 0 Toggles between active/deactive.
mrhToggleActivationAllowIncrease 1 Toggles between active/deactive. Allows increase when active.
mrhToggleActivationAllowDecrease 2 Toggles between active/deactive. Allows decrease when active.
mrhActivate 3 Sets the state to active.
mrhDeactivate 4 Sets the state to deactive.
mrhSetValue 5 Sets a specific value to the value property.
mrhIncreaseValue 6 Increases the current value with the value property.
mrhDecreaseValue 7 Decreases the current value with the value property.

Methods[edit]

Method Parameters Returns Description
doHotkey None None Executes the hotkey as if it got triggered by the keyboard.

Examples[edit]

 1 -- List all hotkeys for a memory record
 2 local mr = AddressList[0]
 3 for i=0, mr.HotkeyCount-1 do
 4   local hk = mr.Hotkey[i]
 5   print("Hotkey:", hk.HotkeyString, "Action:", hk.action, "Active:", hk.Active)
 6 end
 7 
 8 -- Set a function to run when a hotkey is pressed
 9 local hk = mr.Hotkey[0]
10 hk.OnHotkey = function(sender)
11   print("Hotkey pressed for:", sender.Owner.Description)
12 end
13 
14 -- Execute a hotkey manually
15 hk:doHotkey()

See also[edit]