string.dump

Converts a function into binary

Prototype

s = string.dump (f)

Description

Converts a function f into binary representation, which can be subsequently processed by loadstring to retrieve the function. The function must be a Lua function without upvalues.

function f () print "hello, world" end
s = string.dump (f)
assert (loadstring (s)) () --> hello, world
Note: this does not currently work if you are using the LuaJIT DLL instead of the one that ships with the normal MUSHclient download. One way of testing for the presence of LuaJIT is to run this:

print (jit.version) --> LuaJIT 2.0.0-beta7 
If LuaJIT is not installed you would see something like:

Error: attempt to index global 'jit' (a nil value)
Further note: Using string.dump is not recommended. Apart from the issues with LuaJIT it may not be portable across Lua releases or different operating system platforms.

Lua functions

Topics