lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> 	lua_State *L=lua_open();
> 	int error = luaL_dostring(L,"return 10");
> 	printf("%d\n",lua_tonumber(L,-1));
> 
> 	--output	
> 	0
> 
> 	not 10.  What can I do then?

In Lua 5.1, luaL_dostring is defined as
	luaL_loadstring(L, s) || lua_pcall(L, 0, 0, 0)

and so it ignores returns.

Try this:

#undef luaL_dostring
#define luaL_dostring(L,s)	\
	(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))