Page 1 of 1

Lua and DLL's

Posted: Wed Jun 30, 2010 5:10 am
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?

Re: Lua and DLL's

Posted: Wed Jun 30, 2010 6:03 am
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.

Re: Lua and DLL's

Posted: Wed Jun 30, 2010 11:06 am
by Vadi
Just keep in mind that dlls only work on a third of OS' that Mudlet runs on

Re: Lua and DLL's

Posted: Wed Jun 30, 2010 5:22 pm
by Miriel
Thank you, Vadi. Love the client, by the way.

Re: Lua and DLL's

Posted: Fri Jul 02, 2010 10:55 pm
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.