diff --git a/package-lock.json b/package-lock.json index 96413f1..6ebd237 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wasmoon-lua5.1", - "version": "1.18.2", + "version": "1.18.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "wasmoon-lua5.1", - "version": "1.18.2", + "version": "1.18.3", "license": "MIT", "dependencies": { "@types/emscripten": "^1.39.10", diff --git a/package.json b/package.json index 7772482..d5590a9 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wasmoon-lua5.1", - "version": "1.18.2", + "version": "1.18.3", "description": "A real lua 5.1 VM with JS bindings made with webassembly", "main": "dist/index.js", "scripts": { diff --git a/src/table.ts b/src/table.ts index d9825f8..d487625 100644 --- a/src/table.ts +++ b/src/table.ts @@ -1,5 +1,6 @@ import { DictType, mapTransform } from './utils/map-transform'; import { LUA_REGISTRYINDEX, LuaType } from './definitions'; +import { inspect } from 'util'; import LuaThread from './thread'; export class LuaTable { @@ -16,6 +17,10 @@ export class LuaTable { this.pointer = pointer; } + [inspect.custom](): string { + return this.toString(); + } + public $get(key: any): any { return this.getTableValue(key); } @@ -41,7 +46,7 @@ export class LuaTable { } public toString(): string { - return `[LuaTable *${this.ref} 0x${this.pointer.toString(16)}]`; + return `[LuaTable 0x${this.pointer.toString(16)} *${this.ref}]`; } private getTableValue(key: any): any { diff --git a/test/debug.mjs b/test/debug.mjs index f24b2a4..eec96dd 100644 --- a/test/debug.mjs +++ b/test/debug.mjs @@ -1,22 +1,19 @@ -import { JsType, Lua } from '../dist/index.js'; +import { Lua } from '../dist/index.js'; // This file was created as a sandbox to test and debug on vscode const lua = await Lua.create(); -class S { - pp() { - console.log('pp'); - } -} -const s = new S(); +lua.ctx.s = { + name: 123, +}; -lua.ctx.s = JsType.decorate(s) - .tostring(() => '2333') - .index((target, key) => target[key]) - .newindex((target, key, value) => { - target[key] = value; - }); +lua.ctx.s.a = {}; +lua.ctx.s.a.b = {}; +lua.ctx.s.a.b.c = {}; +lua.ctx.s.a.b.c.name = '233'; +console.log(lua.ctx.s.a.b.c); await lua.doString(` - print(s) + print(s.a.b.c) + print(s.a.b.c.name) `);