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

User avatar
aldobr
Member
 
Posts: 316
Joined: Sun Nov 25, 2012 05:46

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

by aldobr » Tue May 21, 2013 05:48

Is there any tutorial or help about how to call external libraries from lua scripts ?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Tue May 21, 2013 06:26

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.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Tue May 21, 2013 18:22

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.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 6 guests

cron