lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If a script defines some functions like so

-- myfuns.lua
function answer()
  return 42
end

then we can load it into another script:

dofile('myfuns.lua')
print(answer())

or (better) use require:

require('myfuns')
print(answer())

Then (a) it will not constantly reload the file each time it is required and (b) myfuns.lua can be put on your Lua module path

See the Unofficial FAQ:  http://www.luafaq.org/#T1.19