Added synchronous execution of lua commands via the main thread

This feature allows popping up modal dialogs or implementing qt
callbacks with return values in lua