3rd party Lua libraries

I’m probably missing something basic here, but I want to use a Lua library (vstruct - https://github.com/ToxicFrog/vstruct) that consists of multiple lua files in a folder hierarchy. I downloaded vstruct to /usr/local/lib/lua/5.1 and it works fine with plain old lua programs, but not with Corona, which complains it is unable to load.

I copied the vstruct folder to my build folder, same result.

How do I incorporate 3rd party lua libraries (i.e. no shared objects, just lua files) to my project?

[import]uid: 58455 topic_id: 22425 reply_id: 322425[/import]

libname = require(“vstruct.libname”) – no .lua

the vstruct folder needs to be in the same folder as your main.lua file.
[import]uid: 19626 topic_id: 22425 reply_id: 89461[/import]

Thanks. I tried that and it didn’t work, and then I noticed that there is no vstruct.lua. I had to load vstruct.init, instead.

However, there now seems to be a bigger problem. When trying to run a simple test of the API, the simulator complains of this:

ERROR: loadstring() is not available in Corona

EDIT: Found other threads that explain why this isn’t supported. [import]uid: 58455 topic_id: 22425 reply_id: 89478[/import]

Kia uses loadstrng instead of require that corona uses. You may need to edit your modules and change them to requires. I’m guessing because I’m using what I’ve read here [import]uid: 19626 topic_id: 22425 reply_id: 89490[/import]

loadstring() is used by vstruct, the lua module I want to use to unpack binary data from a socket stream. It’s part of the implementation of the solution, not used instead of require.

[import]uid: 58455 topic_id: 22425 reply_id: 89498[/import]

Oops. I was mixing up dofile and loadstring. “require” is Corona’s way of doing “dofile”. Loadstring isn’t supported because of Apple reasons. See:

http://developer.anscamobile.com/forum/2011/12/10/convert-signed-int-complex-number

http://developer.anscamobile.com/forum/2012/01/27/second-dofilefilename-its-lua-not-corona [import]uid: 19626 topic_id: 22425 reply_id: 89501[/import]