diff options
-rw-r--r-- | engines/hdb/lua-script.cpp | 19 | ||||
-rw-r--r-- | engines/hdb/lua-script.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 3eb2fe5016..ac8d4cd3dd 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -988,6 +988,25 @@ bool LuaScript::callFunction(const char *name, int returns) { return true; } +void LuaScript::invokeLuaFunction(char *luaFunc, int x, int y, int value1, int value2) { + int type; + + if (!_systemInit) + return; + + lua_getglobal(_state, luaFunc); + type = lua_type(_state, 1); + if (type != LUA_TFUNCTION) { + warning("Function '%s' doesn't exist", luaFunc); + } else { + lua_pushnumber(_state, x); + lua_pushnumber(_state, y); + lua_pushnumber(_state, value1); + lua_pushnumber(_state, value2); + lua_call(_state, 4, 0); + } +} + bool LuaScript::executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length) { if (!_systemInit) { diff --git a/engines/hdb/lua-script.h b/engines/hdb/lua-script.h index a67695c576..5cab8cb17b 100644 --- a/engines/hdb/lua-script.h +++ b/engines/hdb/lua-script.h @@ -50,6 +50,7 @@ public: void pushFunction(char *func); void call(int args, int returns); bool callFunction(const char *name, int returns); + void invokeLuaFunction(char *luaFunc, int x, int y, int value1, int value2); bool executeMPC(Common::SeekableReadStream *stream, const char *name, const char *scriptName, int32 length); bool executeFile(const Common::String &filename); |