Page 1 of 1

Tutorial on how to call/load external .dll/.so from lua

PostPosted: Tue May 21, 2013 05:48
by aldobr
Is there any tutorial or help about how to call external libraries from lua scripts ?

PostPosted: Tue May 21, 2013 06:26
by kaeza
aldobr wrote:Is there any tutorial or help about how to call external libraries from lua scripts ?

The process is not easy, and there are some portability problems to be aware of; at least, IRC it does not work on Windows. This is because Minetest uses a statically linked Lua library, while mods *must* use either a Lua DLL, or statically link lua into the DLL you want to call.

If you don't mind about this page may help you on your quest.

PostPosted: Tue May 21, 2013 18:22
by BrandonReese
Like kaeza said there are lots of portability problems. If you want to use an external library anybody who wants to run your mod on their computer or server will be required to install the external library. I was working on a mod that needed socket access.

On ubuntu I just had to install the socket library

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
sudo apt-get install luasocket


Then in my lua code it was just one line to include functionality from the socket library

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
http = require("socket.http")


Note: I have not worked on this since Minetest started using LuaJIT, but I assume it should work the same.