Sign in to follow this  

lua_getfield behavior

This topic is 3789 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

Hi everyone. I'm currently adding lua to my c++ project, and it works fine : I'm amazed by the flexibility it is going to bring ! However, I'm a bit anoyed by the lack of documentation available (or at least, that I could find). Every function is documented at http://www.lua.org, but too briefly... As a result, I don't know what is the behavior of lua_getfield() if the searched key doesn't appear anywhere in any file. Does anybody knows ? Or at least, if you know a good documentation place for the lua api... (though I suspect the value to be "nil", I'm not sure...) I want my lua files to be modifiable by everyone, and everyone is more likely to make mistake and forget to set an important value. So I'd like to check in my programm if "name" has been set, and if not, throw an error in the log so that the user can see why (and where) his code doesn't work. Edit : Okay, nevermind...
luaL_dofile(luaVM, "test.lua");

lua_getglobal(luaVM, "a");
if (lua_isnil(luaVM, -1))
	printf("a is nil.");
test.lua :
b = 12
c = 96
returns : "a is nil"... Nothing worth experiment :P [Edited by - Kaloux on August 3, 2007 6:41:54 PM]

Share this post


Link to post
Share on other sites

This topic is 3789 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.

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