Difference between revisions of "Lua:decodeFunction"
Jump to navigation
Jump to search
(Major overhaul of the post.) |
m (Added related function template.) |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 21: | Line 21: | ||
===Examples=== | ===Examples=== | ||
| − | < | + | <syntaxhighlight lang="lua" line> |
local encoded = encodeFunction(function() | local encoded = encodeFunction(function() | ||
print("Hello from a decoded function") | print("Hello from a decoded function") | ||
| Line 29: | Line 29: | ||
decoded() | decoded() | ||
| − | </ | + | </syntaxhighlight> |
| − | < | + | <syntaxhighlight lang="lua" line> |
local encoded = encodeFunction(function(value) | local encoded = encodeFunction(function(value) | ||
return value * 2 | return value * 2 | ||
| Line 39: | Line 39: | ||
print(decoded(21)) | print(decoded(21)) | ||
| − | </ | + | </syntaxhighlight> |
| − | < | + | <syntaxhighlight lang="lua" line> |
local encoded32 = "..." -- encoded on 32-bit Cheat Engine | local encoded32 = "..." -- encoded on 32-bit Cheat Engine | ||
local encoded64 = "..." -- encoded on 64-bit Cheat Engine | local encoded64 = "..." -- encoded on 64-bit Cheat Engine | ||
| Line 56: | Line 56: | ||
decoded() | decoded() | ||
| − | </ | + | </syntaxhighlight> |
===Architecture Compatibility=== | ===Architecture Compatibility=== | ||
| Line 85: | Line 85: | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | {{ | + | {{EncodeDecode}} |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | }} | ||
Latest revision as of 00:11, 27 June 2026
Converts an encoded function string back into a callable Lua function.
The encoded string must have been created for the same architecture as the current Cheat Engine process. A 32-bit encoded function can only be loaded by a 32-bit Lua state, and a 64-bit encoded function can only be loaded by a 64-bit Lua state.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| string | String | The encoded function string created by encodeFunction. |
Returns[edit]
Function — The decoded Lua function.
Examples[edit]
1 local encoded = encodeFunction(function()
2 print("Hello from a decoded function")
3 end)
4
5 local decoded = decodeFunction(encoded)
6
7 decoded()
1 local encoded = encodeFunction(function(value)
2 return value * 2
3 end)
4
5 local decoded = decodeFunction(encoded)
6
7 print(decoded(21))
1 local encoded32 = "..." -- encoded on 32-bit Cheat Engine
2 local encoded64 = "..." -- encoded on 64-bit Cheat Engine
3
4 local encoded
5
6 if cheatEngineIs64Bit() then
7 encoded = encoded64
8 else
9 encoded = encoded32
10 end
11
12 local decoded = decodeFunction(encoded)
13
14 decoded()
Architecture Compatibility[edit]
Encoded functions are architecture-dependent.
| Encoded On | Can Be Decoded On | Notes |
|---|---|---|
| 32-bit Cheat Engine | 32-bit Cheat Engine | A 32-bit encoded function can only be decoded in a 32-bit Lua state. |
| 64-bit Cheat Engine | 64-bit Cheat Engine | A 64-bit encoded function can only be decoded in a 64-bit Lua state. |
| 32-bit Cheat Engine | 64-bit Cheat Engine | Not compatible. |
| 64-bit Cheat Engine | 32-bit Cheat Engine | Not compatible. |