[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to get the reture value of luaL_dostring
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 11 Apr 2006 13:37:57 -0300
> 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))