Sign in to follow this  
FinalSmash

What's up with luaopen_io() not working?

Recommended Posts

FinalSmash    122
I am trying to get LUA working and i've used the debugger to find out that when i call the line luaopen_io(LuaVM); the program quits with a 0x1 code (instead of 0x0) just after the call. If i comment out the line, the program exits normally except luaL_loadstring() does nothing, even when i put in a string of LUA commands "a = 1 + 1;\nprint( \"1 + 1: \" .. a);\n" Can anyone tell me how to fix this luaopen_io() function. btw: i used this line beforehand to get a value into LuaVM. lua_State* luaVM = lua_open(); I am using LUA 5.1 and Microsoft Visual CPP 2008 Express Edition. I put the libraries and headers from LUA into MVCPPEE's library folder and include folder respectively and added them to the linker. But that's not really the problem (i think) because the other luaopen_XXX() functions work fine enough. THX for any useful help!

Share this post


Link to post
Share on other sites
Kambiz    758
Lua FAQ
Quote:

My application used to work, but I updated it to Lua 5.1 and it now crashes during initialization (OR: Why do I get a "no calling environment" error?)

The state initialization procedure changed between Lua 5.0 and Lua 5.1. It is now necessary to lua_call the various luaopen_* functions. Previously, these were simply called with a normal C call, but doing so now will cause a crash (or the above mentioned error) during the initialization of the io library.

The easiest way to initialize a lua_State is to use luaL_openlibs() which is defined in the file linit.c, or to copy the code from that file, modifying the list of libraries to initialize according to your needs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this