Sign in to follow this  
sp00n

Lua Integration

Recommended Posts

sp00n    122
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

Share this post


Link to post
Share on other sites
_the_phantom_    11250
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.

Share this post


Link to post
Share on other sites
sp00n    122
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 );

Share this post


Link to post
Share on other sites
sp00n    122
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this