(index: number, metatable: Record<any, any>)
| 237 | } |
| 238 | |
| 239 | public setMetatable(index: number, metatable: Record<any, any>): void { |
| 240 | index = this.lua.lua_absindex(this.address, index) |
| 241 | |
| 242 | if (this.lua.lua_getmetatable(this.address, index)) { |
| 243 | this.pop(1) |
| 244 | const name = this.getMetatableName(index) |
| 245 | throw new Error(`data already has associated metatable: ${name || 'unknown name'}`) |
| 246 | } |
| 247 | |
| 248 | this.pushValue(metatable) |
| 249 | this.lua.lua_setmetatable(this.address, index) |
| 250 | } |
| 251 | |
| 252 | public getMetatableName(index: number): string | undefined { |
| 253 | const metatableNameType = this.lua.luaL_getmetafield(this.address, index, '__name') |
no test coverage detected