diff options
author | Nipun Garg | 2019-06-27 07:39:50 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:02 +0200 |
commit | 00e6ce26809a7e37e0bb64b9614c1bc289be1631 (patch) | |
tree | ac952c27e239d1160c3e5bc440a1587c4f8b349b | |
parent | 459921b04612bf64c2b09e7eeb2d32e919833240 (diff) | |
download | scummvm-rg350-00e6ce26809a7e37e0bb64b9614c1bc289be1631.tar.gz scummvm-rg350-00e6ce26809a7e37e0bb64b9614c1bc289be1631.tar.bz2 scummvm-rg350-00e6ce26809a7e37e0bb64b9614c1bc289be1631.zip |
HDB: Add invokeLuaFunction()
-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); |