(name: string, ...args: any[])
| 155 | } |
| 156 | |
| 157 | public call(name: string, ...args: any[]): MultiReturn { |
| 158 | const type = this.lua.lua_getglobal(this.address, name) |
| 159 | if (type !== LuaType.Function) { |
| 160 | throw new Error(`A function of type '${type}' was pushed, expected is ${LuaType.Function}`) |
| 161 | } |
| 162 | |
| 163 | for (const arg of args) { |
| 164 | this.pushValue(arg) |
| 165 | } |
| 166 | |
| 167 | const base = this.getTop() - args.length - 1 // The 1 is for the function to run |
| 168 | this.lua.lua_callk(this.address, args.length, LUA_MULTRET, 0, null) |
| 169 | return this.getStackValues(base) |
| 170 | } |
| 171 | |
| 172 | public getStackValues(start = 0): MultiReturn { |
| 173 | const returns = this.getTop() - start |
no test coverage detected