Syntax
local chunk, error_message = loadfile("plugin.lua")
if chunk then chunk() endExamples
Lua dofile and loadfile example
A focused example you can adapt while practising.
local chunk, error_message = loadfile("plugin.lua")
if chunk then chunk() endBest practices
- Start with the smallest working example, then adapt it to your project.
- Use the language’s standard library and idioms before introducing extra dependencies.
At a glance
- Purpose
- Lightweight scripting and embedding
- File extension
- .lua
- Runs in
- Lua interpreter or a host application
- Usually used with
- Host APIs and Lua modules
Specifications & further reading
Related Lua documentation
Lua Modules
Lua modules typically return a table of public functions and values. require loads a module and returns the value it exported, caching it for later requests.Lua require
Lua reference for lua require.Lua io library
Lua reference for lua io library.Lua os library
Lua reference for lua os library.
Lua modules typically return a table of public functions and values. require loads a module and returns the value it exported, caching it for later requests.Lua require
Lua reference for lua require.Lua io library
Lua reference for lua io library.Lua os library
Lua reference for lua os library.