During some courses, I write few (if any) new examples in front of my delegates, rather relying on the standard ones in the training notes (which I wrote anyway!) and making small changes and adjustments to illustrate how things work. On other courses, though, I write a some new examples from scratch - and such was the case during last Thurday and Friday's two day
Lua training class.
Here - primarily for the delagates in that class - are links to the many of the new examples, which I have added to our on line resource. If you follow the links to any of these, you'll be offered links to other related examples too!
Lua Fundamentals
Comments in Lus
Simple sting.format example
for loop example in Lua
strip.rep to repeat a string
getting the minimum value from a table in Lua
Pattern Matching -getting names from amongst a stream of punctuation
Lua functions and modules
Variable number of arguments to a function
Lua functions to return larger of two values and largest of a table of values
How sorting works in Lua - looking under the counter
A Lua program that calls in a module and
the module itself
An function which could usefully be turned into a coroutine and
that example amended to run as a coroutine
Towards Object Orientation in Lua
A reminder of tables
Adding Lusa's metables to change functionallity
Creating and using a table of Lua 'objects'
Redefining operator behaviour on tables in Lua
Lua is a really excellent language with a small "footprint" - the more I use it, the more I like it (and I like it a lot!). You won't find the "bloat" of other open source languages, but you WILL find nifty and useful features which come together to make it a very valuable programming tool; it's this feature set that has led to its widespead adoption in the games industry where (for example) it's used in "The world or Warcraft" to customise the user interface.
(written 2008-07-06, updated 2008-08-05)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
U114 - Lua - Threading and Coroutines. [1691] Co-routines in Lua - co-operative processing - (2008-06-29)
[1870] What to do with a huge crop of apples - (2008-11-04)
[2314] Passing parameters to a coroutine in Lua - (2009-08-01)
[2455] Lua examples - coroutines, error handling, objects, etc - (2009-10-15)
[3395] Parallel but not really parallel. Moving game characters. Coroutines in Lua. - (2011-08-17)
[4270] Embedding Lua to perform tailored code at an interval - (2014-05-03)
U109 - Lua - Modules [2358] Encapsulating shared code in a Lua module - (2009-08-13)
[4571] Lua - using modules to add your own utilities - (2015-11-04)
U107 - Object Orientation - the Lua way [1692] Towards Object Oriented Programming in Lua - (2008-06-30)
[1743] First class functions in Lua lead to powerful OO facilities - (2008-08-07)
[1819] Calling base class constructors - (2008-10-03)
[2318] For Lua Programmers AND for Town Planners - (2009-08-02)
[2359] A fresh example - objects the Lua way - (2009-08-13)
[2701] Is Lua an Object Oriented language? - (2010-04-01)
[2703] Lua Metatables - (2010-04-02)
[2710] __index and __newindex in Lua - metatable methods - (2010-04-05)
[3142] Private and Public - and things between - (2011-01-22)
[3396] Tables as Objects in Lua - a gentle introduction to data driven programming - (2011-08-17)
[3524] Metaclasses (Python) and Metatables (Lua) - (2011-11-17)
[3683] Weak references in Lua - what are they, and why use them? - (2012-04-04)
[3694] Special __ methods you can use in Lua metatables - (2012-04-12)
[3727] Using Lua tables as objects - (2012-05-11)
[3730] What is a metatable? How do I set one up? How do I use them? Lua - (2012-05-12)
[4117] Is Lua an Object Oriented language? - (2013-06-15)
[4248] Metatables, Metamethods, classes and objects in Lua - (2014-03-18)
[4273] Dot or Colon separator between table name and member in Lua - what is the difference? - (2014-05-06)
[4572] Tables with values and code in Lua - looks like an object? - (2015-11-05)
[4573] Classic style OO code - in Lua - (2015-11-05)
[4753] Lua, Tcl, Python, C and C++ courses - at our Melksham HQ or on your site - forward from July 2017 - (2017-07-02)
U106 - Lua - Functions. [1685] Short circuit evaluation (lazy operator) in Lua - (2008-06-22)
[1697] Sorting in lua - specifying your own sort routine - (2008-07-05)
[1744] Lua examples, Lua Courses - (2008-08-08)
[1847] Lua - IAQ (Infrequently Answered Questions) - (2008-10-18)
[2312] What are closures in Lua? - (2009-07-31)
[2347] Dot, dot, dot in Lua - variable length parameter lists - (2009-08-11)
[2356] Passing multiple results back from a function - Lua, Python, etc - (2009-08-13)
[2723] Returning multiple values from a function - Lua - (2010-04-15)
[2949] Lua - variable function arguments and select - (2010-09-08)
[3695] Functions are first class variables in Lua and Python - (2012-04-13)
U102 - Lua - Numbers and the Math library. [2345] Automatically initialising Lua variables the first time - (2009-08-10)
[2509] A life lesson from the accuracy of numbers in Excel and Lua - (2009-11-21)
[3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
[4569] Lua - changes to how integers and floats are handled - 5.2 to 5.3 - (2015-11-02)
U101 - Introduction to Lua. [1111] Training in Lua - (2007-03-16)
[1695] Lua Course - here is the index - (2008-07-03)
[1737] Rules, suggestions, considerations for Lua variable names - (2008-08-05)
[1842] Lua Course, and the Wiltshire Countryside too - (2008-10-16)
[2310] Learning to write high quality code in Lua - (2009-07-30)
[3724] Learning to Program in Lua - public / open training course / class - (2012-05-09)
[4271] Line, block and nested comments - Lua compared to other languages - (2014-05-04)
[4324] Learning to program - variables and constants - (2014-11-22)
Some other Articles
Perl ... adding to a list - end, middle, startRunning operating system commands in PerlTraining Course and Business Conference TechnologyFTP server on Fedora LinuxIf you are learning Lua, here are some more examplesDealing with The PressSaying NOT in Perl, PHP, Python, Lua ...Defensive coding techniques in PHP?