diy
Modules
The concept of
module in Lua took a while to settle down.
Modules can be written in Lua or in C, and both kinds can
be loaded by using the
require function. The syntax is
x = require "foo"
which returns a table
x containing what the module
foo
exports. The
require function first checks to see whether
foo is already loaded. If not it uses the system variables
LUA_PATH (for Lua modules) and
LUA_CPATH (for
C modules) to search for
foo. These variables contain a
list of wild-carded paths with a
? for where the
foo
should appear. For C modules the paths must be in Unix format.
RiscLua has in its Boot file
set LUA_PATH rlua:lib.?,?
set LUA_CPATH rlua:solib.?/so,?/so
The
riscos module gives Lua access to RISC OS itself.