Jump to content

Lua Programming/dofile

From Wikibooks, open books for an open world

The dofile builtin function can be used to execute a chunk of code stored in a file. In the following example, we have two files main.lua and sayit.lua. The main program (main.lua) calls the sayit program, which outputs a message to the screen:

-- sayit.lua
print("I am saying hello!")
-- main.lua
dofile("sayit.lua")
dofile("sayit.lua")