Codea, require, and custom C libraries

I peeked around Codea’s .ipa file and found several libraries of interest that can be required and loaded but are undocumented, like “socket.lua”. This raises two questions for me:

  1. Are these hidden files (re.lua, LuaSandbox.lua) useful and is there documentation somewhere for them?
  2. Is it possible to modify these files or add some of your own, e.g. luarocks, etc?

You can do a forum search because some of them have been used already. What all did you find.

The files I found were

  • ClassTemplate.lua
  • dkjson.lua
  • ftp.lua
  • headers.lua
  • http.lua
  • ltn12.lua
  • LuaSandbox.lua
  • mbox.lua
  • mime.lua
  • re.lua
  • smtp.lua
  • socket.lua (already knew about this one)
  • tp.lua
  • tween.lua
  • url.lua
  • “lpeg” a library that can be included but isn’t in the files

I found them by downloading Codea’s IPA file from iTunes, then unzipping it.

On a jailbroken iPad, I tried installing a custom lua module, lfs, but requiring it failed with the error: error loading module 'lfs' from file /usr/local/lib/lua/5.3/lfs.so

Including libraries that aren’t written in pure Lua is another story… The Lua-File-System is such a thing! It must be compiled from source for the specific target platform that you will use it in (iOS in your case). That’s were things get complicated because afaik iOS doesn’t like ‘dynamic linking’ so sources must be compiled as ‘static libraries’. After compilation you must copy the resulting *.dylib file (I think it’s a dylib file extension) and the Lua interface files (additional *.lua files similar to what the socket library has) into your project. Then you can use it. – But I’m afraid that I’m not qualified to tell you how to do this. However Google might help.

@se24vad I already gave up on trying to compile libs for Lua :confused: maybe @Simeon or @John can elaborate their process…