[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Redirecting output to non-files?
- From: PA <petite.abeille@...>
- Date: Fri, 2 Dec 2005 00:31:50 +0100
On Dec 02, 2005, at 00:03, Jens Alfke wrote:
What I want to do is redirect Lua output to my own function, so that
calls to print(), io.write(), io.output():write(), etc. all call my
function so it can collect the output and do something with it.
Not sure if this really what you want, but you can always redefine any
local _print = print
local _write = io.write
function print( ... )
_print( "@", ... )
function io.write( ... )
_write( "@", ... )
print( "hello" )
> @ hello
io.write( "hello" )
Packages (e.g. io) are tables. The global environment (_G) is a table.
You can redefine any table entry if you are so inclined :)
PA, Onnay Equitursay