Skip to Content
Lua Quick Start Guide
book

Lua Quick Start Guide

by Gabor Szauer
July 2018
Beginner
202 pages
5h 42m
English
Packt Publishing
Content preview from Lua Quick Start Guide

Loading and using modules

You can load Lua modules with the require function. The require function takes one argument, which is the name of the file being loaded (without the .lua extension). The require function should return a table that can then be used as any other table.

The require function searches for the given file in several specific folder paths. These paths are stored as a string in the global variable, package.path. The default path on windows looks like this:

?;?.lua;c:\windows\?;/usr/local/lua/?/?.lua

This string contains multiple search paths, each separated by a semicolon (;). The ? charter gets replaced by the filename provided to the require function. So, for example, if you called require("character"), Lua would look for ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Lua Programming

Beginning Lua Programming

Kurt Jung, Aaron Brown
Vim Masterclass

Vim Masterclass

Jason Cannon

Publisher Resources

ISBN: 9781789343229Supplemental Content