Lua References and Library Modules

  • Skill Level: Advanced and Intermediate
  • FH versions: V5, V6, and V7
  • In Topics: Writing plugins 

Lua Language References

ƒh versions 5 & 6 ƒh version 7 Notes
Lua version 5.1 5.3.5 5.4 was released on 29 Jun 2020
Lua reference and programming manuals Free online: Lua 5.1 Reference Manual

Free online: Programming in Lua (first edition) for Lua 5.0

Programming in Lua 2nd edition at Amazon

Free online: Lua 5.3 Reference Manual

Free online: Programming in Lua (first edition) for Lua 5.0

Programming in Lua 4th edition at Amazon

Lua version history has links to free online Reference Manuals for all versions

Programming in Lua paperbacks (editions 2 to 4) are all available via Amazon in the country of your choice

Lua Wiki
(programming language information & resources)
Lua Wiki ~ Main Page and Lua Wiki ~ Sample Code. Note: There will be elements of the advice and sample code that apply only to the later versions of Lua, not 5.1.

IUP GUI Builder

This is a pre-installed library used by ƒh plugins when they need to present a user interface more complex than the simple message box and propmpts provided by the ƒh API.  The version supported by ƒh is often not the latest available, and can be hard to determine; where we’re uncertain we haven’t specified a version but you would be wise to remember this when debugging. You should also be careful to check which version of a library the online Documentation refers to, and consult the associated History page to understand the changes between the version provided in ƒh and the current version.

ƒh versions 5 & 6 ƒh version 7 Make available by:
IUP version V5: 3.11.2

V6: 3.5

3.28 require ("iuplua")
IUP reference manual and programming guides Free online: IUP Portable User Interface Version 3.29

Read carefully to identify features that are not available in the version you are using.

A Basic Guide to using IupLua

IUP GUI Builder Hints and Tips

Additional IUP Libraries IupControls
IupGLCanvas
IupGLControls
IupMglPlot
IupOleControl
IupScintilla
IupWebBrowser
require( "iupluacontrols" )
require( "iupluagl" )
require( "iupluaglcontrols" )
require( "iuplua_mglplot" )
require( "iupluaole" )
require( "iuplua_scintilla" )
require( "iupluaweb" )

Other Lua Library Modules

Not all these libraries are pre-installed in ƒh Versions 5 or 6; you may need to use the Module Require With Load (code snippet) to use them within your plugin.  Most of them are pre-installed in [fh]7 and you do not need to use loadrequire.

The versions supported by ƒh are often not the latest available, and can be hard to determine; where we’re uncertain we haven’t specified a version but you would be wise to remember this when debugging. You should also be careful to check which version of a library the online Documentation refers to, and consult the associated History page to understand the changes between the version provided in ƒh and the current version.

[fh] Versions 5 & 6 ƒh Version 7 Notes
Lua File System v6: v1.5

Free online: Lua File System Library Manual

v7: 1.7

 

require( "lfs" )
Free online: Lua File System Library Manual
LuaCOM v6, v7: 1.3

Free online: LuaCOM User Manual Version 1.3

require ("luacom")
IM: Digital Imaging Toolkit v5: 3.4.2

v6: 3.8.2

v7: 3.13

 

require( "imlua" ,
"imlua_process" )
Free online: IM – Digital Imaging Tool Version
CD: 2-D Graphics library v5 and 6: Version tba v7: 5.1.2 require ("cdlua")
Free online: CD – A 2D Graphics Library
MD5: Cryptographic library Free online: MD5: Cryptographic Library for Lua Version 1.2

 

ƒh5 and 6: loadrequire ( "md5" )

ƒh7: require ("md5")
LuaSocket: Network support v5 and 6: Version tba Version tba (probably 2.0.2) ƒh5 and 6: loadrequire ( "socket" )

ƒh7: require ("socket")
Free online: LuaSocket: Network support for Lua
LuaZip: Reading files inside zip files Free online: LuaZip: Reading files inside zip files Not supported in ƒh7.0.0

On Windows 10 above build 17063, you can use Tar (to create compressed archives) and uncompress both gz and zip ones

require 'luacom'
-- Unzip
sCmd = 'tar -xf "L:\\fh_set_living.zip" -C D:\\temp\\ '
-- Zip
sCmd = 'tar -cvzf "d:\\temp\\doc.gz" "D:\\temp\\Doc"'

Shell = luacom.CreateObject("WScript.Shell")
Shell:Run (sCmd, 0, true)

ƒh5 and 6: loadrequire( "zip" )

ƒh7: N/A
LuaSQL: DMBS interface v5 and 6: Version tba Version 2.2.1

However, this is not believed to work in ƒh7.

ƒh6: loadrequire( "luasql", "luasql.sqlite3" )

ƒh7: require ("luasql", "luasql.sqlite3")
Free online: LuaSql: DBMS interface for Lua

The differences between 2.2.1 and the latest version are detailed at History

Penlight Lua Library Modules Free online: Penlight Lua Library Modules version 1.5.4 Version 1.8

Free documentation online: Penlight Lua Libraries 1.9.2

Changes from 1.8 to 1.9.2 are documented here (mostly bugfixes)

ƒh5 and 6: loadrequire( "pl", "pl.init" )

ƒh7: require ("pl.init")
utf8: UTF-8 aware string functions ƒh6: dated 2009-04-03

 

ƒh7: dated 2009-04-03

 

ƒh6:

loadrequire("utf8")
loadrequire("compat53")
utf8 = require(".utf8"):init()

Note: this order of requiring the modules is important.

ƒh7:

utf8 = require('.utf8'):init()

 

Online documentation

Note 1: in ƒh6 the library compat53 is a prerequisite for this library.

Note 2: you must loadrequire this library using the ‘multiple sub-directories’ version of loadrequire here

fhUtils: An ƒh specific library module that provides utility functions for building ƒh plugins. N/A Version 1.6

Online Documentation

require ("fhutils")
compat53 : A small module that aims to make it easier to write code in a Lua-5.3-style that is compatible with Lua 5.1, Lua 5.2, and Lua 5.3. This does not make Lua 5.2 (or even Lua 5.1) entirely compatible with Lua 5.3, but it brings the API closer to that of Lua 5.3. Version 0.9

Online documentation

N/A ƒh6: loadrequire (“compat53”)

compat53 makes changes to your global environment and does not return a meaningful return value, so the usual idiom of storing the return of require in a local variable makes no sense.

Last update: 28 Jan 2021