lua: use the active EngineDelegate::onConsolePrint() in print() function

This is needed to output print() messages in the DevConsoleView when
it's open.
This commit is contained in:
David Capello 2018-09-14 20:38:27 -03:00
parent b4b232b10f
commit aed23f4751
2 changed files with 9 additions and 5 deletions

View File

@ -52,10 +52,8 @@ int print(lua_State* L)
lua_pop(L, 1); // pop result
}
if (!output.empty()) {
std::printf("%s\n", output.c_str());
std::fflush(stdout);
if (App::instance()->isGui())
Console().printf("%s\n", output.c_str());
App::instance()->scriptEngine()
->consolePrint(output.c_str());
}
return 0;
}
@ -291,8 +289,10 @@ void Engine::onConsolePrint(const char* text)
{
if (m_delegate)
m_delegate->onConsolePrint(text);
else
else {
std::printf("%s\n", text);
std::fflush(stdout);
}
}
} // namespace script

View File

@ -58,6 +58,10 @@ namespace app {
const std::string& filename = std::string());
bool evalFile(const std::string& filename);
void consolePrint(const char* text) {
onConsolePrint(text);
}
private:
void onConsolePrint(const char* text);