Main Content

Lua - using modules to add your own utilities

Archive - Originally posted on "The Horse's Mouth" - 2015-11-04 21:09:22 - Graham Ellis

Lua is a small language ... but that doesn't mean it lacks capabiities - it just means that you need to write some code yourself to implement simple utilities that you would cherry pick from huge libraries in other languages.

For example from this week's course, I've written functions to split a line and to read a file into a table of tables - it's [here]. Those functions can be loaded using a require and called up from multiple application programs - see [here] and [here].

Since Lua is a "default global" language, please note the declaration of internal variables to local within each function.

Although we're already in November, due to popular demand the current Lua course will be followed by yet another in the week of 14th December ...or if you're coming back to this article on the archive, see [here] for our current schedule.

N.B. original unsplit code is [here]