Difference between revisions of "Lua:decodeFunction"

From Cheat Engine
Jump to navigation Jump to search
(Examples)
m (Added related function template.)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' decodeFunction(''encodedString'') ''':''' function
+
{{CodeBox|'''function''' decodeFunction(''string'') ''':''' function}}
  
Converts a given string converted by [[Lua:encodeFunction|encodeFunction]] back into function.
+
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%" cellpadding="5%" cellspacing="0" border="0"
+
{|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
 
|-
 
|-
|encodedString
 
 
|string
 
|string
|The string to decode into a function
+
|String
 +
|The encoded function string created by [[Lua:encodeFunction|encodeFunction]].
 
|}
 
|}
  
[ENABLE]
+
===Returns===
{$lua}
+
Function — The decoded Lua function.
decodeFunction("c-n1NS/kA974]I/v=n*d]q2B+[K8n%!U,^c5d{d71P4$-R2.z)#1Z%$a^3$khx+X{b$im:q%U0$d#^z1=3cZgz5mAF:92F)_M:t2fBpIEx3Ay6xdY$-5O#/!zArz;PydlWefv;/=/0I9.qwK*]?WFheZIf^*8[,y-?gQZctPKH-]5{g;z]Ko@0=CLH+0y[9/5)}^nzh*o4AZyFsG7^IFT/RDOHiz2$(zy*Cgg6YHq9hJ/G7Gt-VQU)+*;GLDx6{ySOK9MReOuZvttvRRALtLQDMpF=4A7bD_TgE2Bov]?n(=DT?:kNuc4nd6q9U(ZRQ)K!B1OcxOP2kW7j;0u3cs-vdM.Wyn+T#8j;gWNOjEW[XKYHkj{2*E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#r.h=4l1(]!lq:]kYog5B7V{nF+9uqS2vx;XS!lx?U.1G-ZypV+TABs)m.:r3@JnSix(3m_Tw!3Rb%=EFAKk,}h(DAI]@fe}y,k(gSr$c]%*G%DHa,pubw()mN+#AgEza2=@8;]jYSx4_qTP9RhuXb/C?WLfcCGk/B3iX^+odXcv_G5q4Lhy5k?H#5O9D/!7]xcLEc?fwx-K21d[B=:;tbea4E;wjbCz_Wcdh2NLsEAqge+n3w)m_(PA/+1MlkZcQ$aGM[n5zr:4Q}ZYn$eetFS+.dKsebn$?z/+[9$2A:Ql24Ji/hKyv7WCX%1{j!cXg=[3=A,_GCk]gqW}Q1B/rSgkf@P{2t2Ix2Fd=p5ca,(G4:Z(}XF;vGghR.KUNIOPVxSkOd^!ezV2PfbTAflCZpW;l4hm-[oP#t)(kIhj02]*WL{O[2*b^TcZ08}Vlf_L__N5jXk")()
+
 
 +
===Examples===
 +
<syntaxhighlight lang="lua" line>
 +
local encoded = encodeFunction(function()
 +
  print("Hello from a decoded function")
 +
end)
 +
 
 +
local decoded = decodeFunction(encoded)
 +
 
 +
decoded()
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="lua" line>
 +
local encoded = encodeFunction(function(value)
 +
  return value * 2
 +
end)
 +
 
 +
local decoded = decodeFunction(encoded)
 +
 
 +
print(decoded(21))
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="lua" line>
 +
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()
 +
</syntaxhighlight>
 +
 
 +
===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}}
  
[DISABLE]
+
{{EncodeDecode}}
{$lua}
 
decodeFunction("c-n1LOOL7s7-f1V(EzIc7rmRdE2}UZL]4*7$]u3@9aI$LS;:vA6d#D:3!Lj?]WyO)y6FG9owQB5:}/jdPV%k3oF9ebqXc}a]#0{?cz:6$dv[Npz/*?e:@NnY(Aj[NzPo#*uK@lhXaGpP0yoSn0Q}j]0D!;j(HY//54-{mZ,iQ!/Jw!tZ5.#q.BSKuU.g},pNlpeAYFsWz%**(iiW1nD/E!itXbhP1M{Tv9C%?*zuK?/D-R{%(.hO;5fw{RsOk=)i(SaTuYno1!b!sESwC}gW#ZD#fj2TwtJIo4YO]Huk+{s)n/sV8QQaa6r(6rcrbLA^D]:75CfXX-S_#XO)NnFEA(u?Jfi_/Xg=]MEA(ARM/4P?5Wa2i]OIBJ}WPM)J+eDm};/w+0#S*^G6(S7D0udn{/eC?GlO[jDcl]w^G$)#D?RaO:,+%KG9dD1!k]QnQxsW=e6H:iwnv#WCnL^mBjK(3!QK$9Yv80nc]#^W2@J0yWU{4:/ijU)cSXgd3K#d_V]yHq.!ordh*WKReq?59Xw3EA.D.PaC7l/5^A5wZ^B6agiw%ToKUiQ%7](meSy!M=4V$M+#%M_7cPH/_P6ov3ogv#R*NC;il#j(pSRHTY:yllo+znh/Q-QHY][od3)sCYqKJb?Uejpl0GJeR^9*Y21(rk@)Lq$CUreK2J)da6?3k#S}RgW0+)jt14F%:bnvRDbB.lqfJuDHW!YFx)C*FVU,}yL18TNzSlk)ByFY6z2ye,SUAS#-1kZ4Y5rYW-:D-..4s)h(b%jD$uU8fu8upK8p6[W/@97TtoMW/}jq;8ce-sfg[HxH+k2:@_Ebf0H*Pk-XmsakI6BO;)#w12hE/^ttpXlJw0)omu[#oN0=S!//vWiv$3OWO6BuoL}f^zoF*$S/hiu:QaRg4sMV}*wLX05-Td;,%Y(%$qBHgz7t55Ei4K0*=RVMIyrZ8b;BUmRsG;IQQxB1K[N/q*x^KlW5]q_wF}Pn[xfZVviJ?YU9pto,Q3%*3fq0yQP_jA+V_gnh*6B0Q^il!1N{R7FF!Xcrn0#p_lTd7kf+@jP*=]o33o@_+Y/2aSR]1aiWHGh-yq3-^J_$(XI%)m^b}}_3rC,Mg;cHUg)en8kp84_J59a##+)CWwam-r8/4?RTbE#(alQ#m#:0m,-65#?Y/]j{zG{fQ54Y:r/9YW]1Tu%4^8k75_R%[T:b+=2?WkKwk.{Ovp-J!8;HFazNOQ}{ULXP*TfMXl^xL=61]iNrOT93QTKDMSNQm]VYm3a6r?$cr]0RM--02@sgrT")()
 

Latest revision as of 00:11, 27 June 2026

<> Lua API Reference

function decodeFunction(string) : function

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.

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Function Encoding Related Lua Functions