Lua and DLL's

Post Reply
Miriel
Posts: 2
Joined: Wed Jun 30, 2010 4:59 am
Contact:

Lua and DLL's

Post by Miriel »

I just began learning C++ and only a few minutes ago discovered the fun of creating DLL's in VC++. I'm sure this is a noobish question, but is it possible to use C++ functions defined in DLL's through a Lua script defined in Mudlet?
If so, how? If not, is there another way?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Lua and DLL's

Post by Heiko »

Yes, of course, but you'll need to supply special glue functions to interface C++ and Lua calling conventions.
For how to do this checkout the source code of TLuaInterpreter.cpp which holds these glue functions for Mudlet's Lua API. Just add your own to access your dll and then register this glue function with Lua -> TLuaInterpreter::initLuaGlobals().
Note that the glue functions need to be static functions.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Lua and DLL's

Post by Vadi »

Just keep in mind that dlls only work on a third of OS' that Mudlet runs on

Miriel
Posts: 2
Joined: Wed Jun 30, 2010 4:59 am
Contact:

Re: Lua and DLL's

Post by Miriel »

Thank you, Vadi. Love the client, by the way.

WillFa
Posts: 19
Joined: Mon May 10, 2010 4:16 pm

Re: Lua and DLL's

Post by WillFa »

If you're just referring to standard cdeclspec functions, you might consider a package called Alien. If you're new to Lua, I'd recommend getting the Lua for Windows installation. It installs what you may think of as a VM, an IDE, and lots of libs and provides documentation and a walkthru of the language, and samples for the libs.

Post Reply