Jump to content
  • Advertisement
Sign in to follow this  

lua_getfield behavior

This topic is 4001 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
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!