lovr.filesystem.load

Load a file containing Lua code, returning a Lua chunk that can be run.

chunk = lovr.filesystem.load(filename)

Arguments

NameTypeDescription
filenamestringThe file to load.

Returns

NameTypeDescription
chunkfunctionThe runnable chunk.

Notes

An error is thrown if the file contains syntax errors.

Example

Safely loading code:

local success, chunk = pcall(lovr.filesystem.load, filename)
if not success then
  print('Oh no! There was an error: ' .. tostring(chunk))
else
  local success, result = pcall(chunk)
  print(success, result)
end

See also