Difference between revisions of "Lua:decodeFunction"
Jump to navigation
Jump to search
(Tag: Undo) |
(Major overhaul of the post.) |
||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' decodeFunction('' | + | {{CodeBox|'''function''' decodeFunction(''string'') ''':''' function}} |
| − | Converts a | + | 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=== | ===Function Parameters=== | ||
| − | {|width="85%" cellpadding="10 | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
!style="width: 80%;background-color:white;" align="left"|Description | !style="width: 80%;background-color:white;" align="left"|Description | ||
|- | |- | ||
| − | |||
|string | |string | ||
| − | |The string | + | |String |
| + | |The encoded function string created by [[Lua:encodeFunction|encodeFunction]]. | ||
|} | |} | ||
| − | == Examples == | + | ===Returns=== |
| − | <pre | + | Function — The decoded Lua function. |
| − | local | + | |
| − | + | ===Examples=== | |
| − | + | <pre> | |
| + | local encoded = encodeFunction(function() | ||
| + | print("Hello from a decoded function") | ||
| + | end) | ||
| + | |||
| + | local decoded = decodeFunction(encoded) | ||
| + | |||
| + | decoded() | ||
| + | </pre> | ||
| + | |||
<pre> | <pre> | ||
| − | local function | + | local encoded = encodeFunction(function(value) |
| − | + | return value * 2 | |
| − | local | + | end) |
| − | + | ||
| + | local decoded = decodeFunction(encoded) | ||
| + | |||
| + | print(decoded(21)) | ||
</pre> | </pre> | ||
| + | |||
| + | <pre> | ||
| + | local encoded32 = "..." -- encoded on 32-bit Cheat Engine | ||
| + | local encoded64 = "..." -- encoded on 64-bit Cheat Engine | ||
| + | |||
| + | local encoded | ||
| + | |||
| + | if cheatEngineIs64Bit() then | ||
| + | encoded = encoded64 | ||
| + | else | ||
| + | encoded = encoded32 | ||
| + | end | ||
| + | |||
| + | local decoded = decodeFunction(encoded) | ||
| + | |||
| + | decoded() | ||
| + | </pre> | ||
| + | |||
| + | ===Architecture Compatibility=== | ||
| + | Encoded functions are architecture-dependent. | ||
| + | |||
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Encoded On | ||
| + | !align="left"|Can Be Decoded On | ||
| + | !style="width: 80%;background-color:white;" align="left"|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. | ||
| + | |} | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | === | + | {{LuaIndexBoxNoDescription |
| − | + | |title=Function Encoding Related Lua Functions | |
| + | |content= | ||
| + | {{LuaIndexItemNoDescription | ||
| + | |page=encodeFunction | ||
| + | |label=encodeFunction | ||
| + | }} | ||
| + | {{LuaIndexItemNoDescription | ||
| + | |page=decodeFunction | ||
| + | |label=decodeFunction | ||
| + | }} | ||
| + | {{LuaIndexItemNoDescription | ||
| + | |page=encodeFunctionEx | ||
| + | |label=encodeFunctionEx | ||
| + | }} | ||
| + | }} | ||
Revision as of 14:17, 25 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
| Parameter | Type | Description |
|---|---|---|
| string | String | The encoded function string created by encodeFunction. |
Returns
Function — The decoded Lua function.
Examples
local encoded = encodeFunction(function()
print("Hello from a decoded function")
end)
local decoded = decodeFunction(encoded)
decoded()
local encoded = encodeFunction(function(value) return value * 2 end) local decoded = decodeFunction(encoded) print(decoded(21))
local encoded32 = "..." -- encoded on 32-bit Cheat Engine local encoded64 = "..." -- encoded on 64-bit Cheat Engine local encoded if cheatEngineIs64Bit() then encoded = encoded64 else encoded = encoded32 end local decoded = decodeFunction(encoded) decoded()
Architecture Compatibility
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. |