Integrating Lua
From C4 Engine Wiki
Setup
This setup is geared towards setup in Visual Studio on Windows.
Download a distribution of Lua which has the header and libraries. For Windows, Lua For Windows is an easy route.
In the Configuration Properties > C/C++ > Additional Include Directories, add the include path to the Lua headers. If you installed Lua For Windows, this will be something like "C:\Program Files\Lua\5.1\include".
In the Configuration Properties > Linker > Input > Additional Dependencies, add the path to Lua5.1.lib. For Lua For Windows, this is would be something like "C:\Program Files\Lua\5.1\lib\Lua5.1.lib". If the path has spaces in it, be sure to contain it in quotes.
In the header file for your application, add the following:
extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" }
You should be able to compile your project now without any errors.
To verify that everything is working, try putting the following code at the end of the Game constructor:
lua_State *L = lua_open(); char foo[] = "bar"; lua_pushstring(L,foo); TheEngine->Report(lua_tostring(L,1)); lua_close(L);
When you start the engine, you should see "bar" in the console. You may have to include C4Engine.h to get the call to TheEngine to work.
Creating the Lua Console Window
Lua keeps a stack for variables, and they can be pushed and popped off the stack.
