Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

lua error

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

#include <conio.h>
#include <iostream>
extern "C"
{
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
 
main() 
{
	lua_State *L = lua_open();
        luaopen_base(L);
	lua_dofile(L,"test.lua");

/* the function name */
	lua_getglobal(L, "contact");
	lua_getglobal(L,"A");

	lua_call(L, 1, 1);// --------problem the line---------

	/* get the result */
	lua_pushstring(L,"name");
	lua_gettable(L,-2);
	const char * c = lua_tostring(L,-1);

	lua_close(L);
	getch();
}



\\ test.lua

function contact(t)     
for k,v in t do  --this   
print(k..v )     --this   
end              --this   
return t
end 



A = {     
name = "Game Developer",     
email = "hack@ogdev.net",     
url = "http://www.ogdev.net",     
quote = [[         
There are 
10 types of people        
who can understand binary.]] 
}
 




something is wrong. the program stop at lua_call and return. tip: deleting the line marked with --this ,the program work.

Share this post


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