From a9a2ee04796bc93b64acbf2a4db91d91fb6d6c51 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Thu, 20 Jun 2019 01:45:51 +0530 Subject: HDB: Add getStringOffStack() --- engines/hdb/lua-script.cpp | 10 ++++++++++ engines/hdb/lua-script.h | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 66aa6dca40..5259c10932 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -960,4 +960,14 @@ void LuaScript::checkParameters(const char *func, int params) { } } +const char *LuaScript::getStringOffStack() { + if (!_systemInit) { + return NULL; + } + + const char *string = lua_tostring(_state, 1); + lua_remove(_state, 1); + return string; +} + } diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h index 37b8df9d73..20cd94d331 100644 --- a/engines/hdb/lua-script.h +++ b/engines/hdb/lua-script.h @@ -44,6 +44,8 @@ public: bool executeFile(const Common::String &filename); void checkParameters(const char *func, int params); + const char *getStringOffStack(); + private: lua_State *_state; int _pcallErrorhandlerRegistryIndex; @@ -56,7 +58,6 @@ private: bool executeChunk(Common::String &chunk, uint chunkSize, const Common::String &chunkName) const; void stripComments(char *chunk); void addPatches(Common::String &chunk, const char *scriptName); - }; } -- cgit v1.2.3