1. /*
  2.   I'm using visual studio, for this.
  3. */
  4.  
  5. /* Test.h: */
  6. #ifndef __LUA_INC_H__
  7. #define __LUA_INC_H__
  8.  
  9. extern "C"
  10. {
  11.    #include "lualib/lua.h"
  12.    #include "lualib/lauxlib.h"
  13.    #include "lualib/lualib.h"
  14. }
  15.  
  16. #endif // __LUA_INC_H__
  17.  
  18. ////////////////////////////////////////////////////////////
  19. // Site I was following:
  20. // (http://www.codeproject.com/Articles/11508/Integrating-Lua-into-C)          
  21. ////////////////////////////////////////////////////////////
  22.  
  23. /* QuickTests.cpp: */
  24.  
  25. #include "stdafx.h"
  26. #include "test.h"
  27.  
  28.  
  29. int main()
  30. {
  31.     int iErr = 0;
  32.     lua_State *lua = lua_open ();  // Open Lua
  33.     luaopen_io (lua);              // Load io library
  34.     if ((iErr = luaL_loadfile (lua, "test.lua")) == 0)
  35.     {
  36.         // Call main...
  37.         if ((iErr = lua_pcall (lua, 0, LUA_MULTRET, 0)) == 0)
  38.         {
  39.         // Push the function name onto the stack
  40.         lua_pushstring (lua, "helloWorld");
  41.         // Function is located in the Global Table
  42.         lua_gettable (lua, LUA_GLOBALSINDEX);  
  43.         lua_pcall (lua, 0, 0, 0);
  44.         }
  45.     }
  46.     lua_close (lua);
  47.     return 0;
  48. }