Difference between revisions of "Lua:encodeFunctionEx"

From Cheat Engine
Jump to navigation Jump to search
(Initial page creation.)
 
m (Syntax Highlighting.)
 
Line 50: Line 50:
  
 
===Examples===
 
===Examples===
<pre>
+
<syntaxhighlight lang="lua" line>
 
local encoded = encodeFunctionEx([[
 
local encoded = encodeFunctionEx([[
 
   print("Hello from an encoded script")
 
   print("Hello from an encoded script")
Line 57: Line 57:
 
local decoded = decodeFunction(encoded)
 
local decoded = decodeFunction(encoded)
 
decoded()
 
decoded()
</pre>
+
</syntaxhighlight>
  
<pre>
+
<syntaxhighlight lang="lua" line>
 
local script = [[
 
local script = [[
 
   return function(value)
 
   return function(value)
Line 71: Line 71:
 
local fn = decoded()
 
local fn = decoded()
 
print(fn(21))
 
print(fn(21))
</pre>
+
</syntaxhighlight>
  
<pre>
+
<syntaxhighlight lang="lua" line>
 
local luaDllPath = "C:\\\\Cheat Engine\\\\lua53-64.dll"
 
local luaDllPath = "C:\\\\Cheat Engine\\\\lua53-64.dll"
  
Line 82: Line 82:
 
local decoded = decodeFunction(encoded)
 
local decoded = decodeFunction(encoded)
 
decoded()
 
decoded()
</pre>
+
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}

Latest revision as of 16:27, 25 June 2026

<> Reference

function encodeFunctionEx(string, pathtodll) : string

Converts a Lua script string into an encoded function string.

This is similar to encodeFunction, but it uses a script string instead of a function object and allows specifying which Lua DLL should be used.

Function Parameters[edit]

Parameter Type Description
string String The Lua script that should be encoded.
pathtodll String (optional) The path to the Lua DLL that should be used for encoding.

Returns[edit]

String — The encoded function string.

Architecture Compatibility[edit]

The Lua DLL must match the architecture of the current Cheat Engine process.

Current Process Allowed Lua DLL Result
32-bit Cheat Engine 32-bit Lua DLL Compatible.
64-bit Cheat Engine 64-bit Lua DLL Compatible.
32-bit Cheat Engine 64-bit Lua DLL Not compatible.
64-bit Cheat Engine 32-bit Lua DLL Not compatible.

Examples[edit]

1 local encoded = encodeFunctionEx([[
2   print("Hello from an encoded script")
3 ]])
4 
5 local decoded = decodeFunction(encoded)
6 decoded()
 1 local script = [[
 2   return function(value)
 3     return value * 2
 4   end
 5 ]]
 6 
 7 local encoded = encodeFunctionEx(script)
 8 local decoded = decodeFunction(encoded)
 9 
10 local fn = decoded()
11 print(fn(21))
1 local luaDllPath = "C:\\\\Cheat Engine\\\\lua53-64.dll"
2 
3 local encoded = encodeFunctionEx([[
4   print("Encoded with a specific Lua DLL")
5 ]], luaDllPath)
6 
7 local decoded = decodeFunction(encoded)
8 decoded()

See Also[edit]

Main Pages

Function Encoding Related Lua Functions