[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Registering a new function that wraps write(format())
- From: "Chris Percival" <cpercival@...>
- Date: Thu, 21 Feb 2002 15:31:07 -0000
Yes that works for me also. It also fits in better with my model. So,
thanks again. You're the best! :)
Chris Percival
Software Engineer
Interaxis Computing Ltd.
DDI: +44 (0)1249 700072
http://www.interaxis.co.uk/
> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Luiz Henrique de
> Figueiredo
> Sent: 21 February 2002 15:16
> To: Multiple recipients of list
> Subject: RE: Registering a new function that wraps write(format())
>
>
> >Yes, but how would I do that from C?
>
> How about this (tested)?
>
> static int l_printf (lua_State *l) {
> lua_getglobal(L,"format");
> lua_insert(L,1);
> lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
> lua_getglobal(L,"write");
> lua_insert(L,1);
> lua_call(L,lua_gettop(L)-1,LUA_MULTRET);
> return lua_gettop(L);
> }
>
> lua_register(L,"printf",l_printf);
>
> --lhf