Jump to content
  • Advertisement
Sign in to follow this  
JClayton

Stupid LUA problem

This topic is 5127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!