Lua:encodeFunction
Jump to navigation
Jump to search
Converts a given Lua function into an encoded string.
The encoded string can later be passed to decodeFunction to recreate the function.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| function | Function | The Lua function that should be encoded. |
Returns[edit]
String — The encoded function string.
Examples[edit]
1 local encoded = encodeFunction(function()
2 print("Hello from an encoded function")
3 end)
4
5 print(encoded)
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 function testFunction()
2 showMessage("This function was encoded and decoded")
3 end
4
5 local encoded = encodeFunction(testFunction)
6 local decoded = decodeFunction(encoded)
7
8 decoded()