lua-users home
lua-l archive

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


Probably the easiest way to do that is to register your own print function
that works like the original but calls your own code to add things to the
console. You can take a look for the source of print in lua and duplicate
that logic.

But  don't forget that the write function can theoretically write to _STDOUT
or _STDERR, and that the read function can read from _STDIN, so you need to
handle those situations as well. That's not as easy, though.

my own solution to this problem in similar circumstances was to implement a
function and expose it as console.print or something like that, and then
expressly mention everywhere that that's the function you use for output to
the console.

> to show all the global variables?  How do I go about capturing the output
> from print to show in my in-game console?  Do I need to reroute the cout
or
> cerr streams?
>
> -Kevin Watters
>