Loads and compiles Lua source code


See also Lua library functions.

Signature:

chunk, error = loadstring("s" [, "chunkname"])

Arguments:

  • s - A string containing Lua code (string)
  • chunkname - Name for the loaded chunk; used in error messages and debug information (string)

Returns:

  • chunk - A function which can be run to execute the provided code, or nil if the code could not be compiled (function)
  • error - Error message, if the code could not be compiled (string)
This function is defined in the Lua standard libraries