Veovis_Muaddib's picture

Get started with Lua

How might I get started using Lua within my OpenTK applications? I've been looking into things like NLua and Eluant but I keep stumbling on how to get Monodevelop to be aware of the actual Lua dll. I can add the wrapper dlls just fine but attempts to add the lua5*.dll fail with the error "File /lua5*.dll is not a valid .Net assembly.".

I thought OpenTK included Lua support out of the box but I can't find the source anymore, so I'm likely confusing it with Tao. Since there's no native support, are there any links or resources on how to quickly get started?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

OpenTK has never included Lua support.

"File /lua5*.dll is not a valid .Net assembly." means that you are trying to add a native library as a managed reference. This is not possible - what you want to do instead, is to add it to your project as content and set the "copy to output directory" property to "only if newer". The wrapper library should work as long as the native dll is copied in the same folder.

That said, I've never tried to use Lua on a .Net project. I prefer to use a proper .Net language, such as F# or Boo, for scripting. Simple, fast and it works without any special setup (you can directly reference public classes from your engine.)

Veovis_Muaddib's picture

That works, and I can interact with the lua vm now. Thanks! I did have to change the wrapper's sources to use lua5.1.dll instead of lua5.1, as Windows doesn't automatically try to append .dll if there's already a period in the string.

I'm having some project configuration issues where the tests seem to be wanting to compile to x64, but I should be able to figure that out.

As to why I would use Lua instead of something like Boo, this is for mod support, and a significant portion of my target audience is familiar with Lua. That doesn't rule out something like Boo, but it's a pretty strong push in the direction of Lua. I'm also considering some amount of sandboxing.

If I were to use Boo for scripting, how difficult would an in-game interpreter be, where commands could be entered while the game is running?