🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Stupid LUA problem

Started by
1 comment, last by Sneftel 20 years 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?
Advertisement
In Lua 5.x lua_open doesn't take any parameters.
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