Lua Integration
I'm working on an engine, and i'm integrating lua with it. I have an in game console, which i want to interact with the scripting engine. I know how to bind a function , eg console_print(), to allow lua to display output to the console. but how can i redirect _all_ of lua's textual output to my console, instead of to stdout? Or is this a sensible thing to do?
thanks. sp00n
Well, it depends on how the textual output is being produced, the simplest way I can think of would be to replace the print function in global function table with your own function which prints the output to where ever you want it to go.
I think I understand. would this work?
void l_print( lua_State* luaVM ) // glue function to call console's print method{ pConsole->Print( lua_toString(luaVM, -1) );}lua_register( luaVM, "print", l_print );
update:
thanks for the help, I've got it working now.
I'ts a great feeling to see my console working, and integrated with the Lua engine! Even if the only commands i have registered so far simply toggle between full screen and windowed :)
Now to really get cracking on my GUI system.
But first i need to carry on revising, big exam on Tuesday!
thanks for the help, I've got it working now.
I'ts a great feeling to see my console working, and integrated with the Lua engine! Even if the only commands i have registered so far simply toggle between full screen and windowed :)
Now to really get cracking on my GUI system.
But first i need to carry on revising, big exam on Tuesday!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement