Advertisement

Stupid LUA problem

Started by July 06, 2004 11:04 AM
1 comment, last by Sneftel 20 years, 2 months ago
I am attempting to embed LUA into a simple console application. I downloaded the compiled library and dlls from this website: http://tonyandpaige.com/tutorials/lua1.html I then used the code from the article here on gamedev:
#include <stdio.h>
extern "C"
{
 #include <lua.h>
 #include <lualib.h>
}
 
int main(int argc, char* argv[ ])
{
   lua_State* luaVM = lua_open(0);
 
   if (NULL == luaVM)
   {
      printf("Error Initializing lua\n");
      return -1;
   }
 
   // initialize lua standard library functions

   lua_baselibopen(luaVM);
   lua_iolibopen(luaVM);
   lua_strlibopen(luaVM);
   lua_mathlibopen(luaVM);

   // Do stuff with lua code.
    
   char* strLuaInput = "a = 1 + 1;\nprint( a);\n";
 
   lua_dostring(luaVM, strLuaInput);
 
   lua_close(luaVM);   
   
   while(1) {}
   return 0;
}
However the program crashes on the first line (the lua_open call)... any ideas?
In Lua 5.x lua_open doesn't take any parameters.
Advertisement
Also, before you run into the error on your own, lua_*libopen leave things on the stack. It's usually wise to call lua_settop(L, 0) after calling them.

This topic is closed to new replies.

Advertisement