lovr.filesystem.load
EditLoad a file containing Lua code, returning a Lua chunk that can be run.
chunk = lovr.filesystem.load(filename, mode)
Arguments
Name | Type | Default | Description |
filename | string | The file to load. | |
mode | string | 'bt' |
The type of code that can be loaded. t allows text, b allows binary, and bt allows both.
|
Returns
Name | Type | Description |
chunk | function | The 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