loadFile
Loadfile is a function in the standard Lua libraries that reads a Lua source file, compiles it as a chunk, and returns the compiled chunk as a function. It does not execute the chunk by itself; instead, it provides a callable representation of the code that can be invoked later, allowing for controlled execution and error handling.
When loadfile executes, it attempts to open the specified file, read its contents, and compile the code.
A common pattern is: local chunk, err = loadfile("script.lua"); if not chunk then error(err) end; chunk(). This
Environment and sandboxing considerations are important. In older Lua versions the environment of the loaded chunk