MCPcopy Create free account
hub / github.com/ceifa/wasmoon / setMetatable

Method setMetatable

src/thread.ts:239–250  ·  view source on GitHub ↗
(index: number, metatable: Record<any, any>)

Source from the content-addressed store, hash-verified

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')

Callers 1

pushValueMethod · 0.95

Calls 3

popMethod · 0.95
getMetatableNameMethod · 0.95
pushValueMethod · 0.95

Tested by

no test coverage detected