Hi,
Lua stand-alone interpreter can be given option -l to require a library into the workspace. The interpreter help says
-l name require library 'name' into global 'name'
I was trying to load a library lib from a folder named test, so
$ lua -l test.lib
I also tried,
$ lua -l test/lib
But then, how to access the loaded library in the interpreter?
I suppose both dot (.) and slash (/) are not valid characters in a variable name, e.g.
> test.lib.myfun()
stdin:1: attempt to index a nil value (global 'test')
stack traceback:
stdin:1: in main chunk
[C]: in ?
I figured I could use the global _G variable,
> _G['test.lib'].myfun()
42
But is there no more elegant way to do this? Would it not have been good if the directory name was not included in the variable name? Any idea?
I looked in PIL book chapter I.1 The stand-Alone Interpreter but could not find any answer. Using Lua 5.4.3.
Thanks,
Christian Govella