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

Executing files

The require function only loads a file one time. When dealing with modules, this feature is a great way to avoid loading duplicate code. But, when trying to load data, the require function will not re-load data. Loading the same Lua file multiple times can be done using the dofile function. Both dofile and require load a file and execute the code within, but with two major differences:

  • dofile: will re-load a given file every time it is called
  • dofile: does not search package.path; instead, it loads the file name given assuming the path provided is relative to the current file path

Let's modify the previous code sample to save some data, load it, save some new data, and then re-load the data. The code needs to change to this: ...

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