-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
20 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,18 @@ | ||
import { Lua } from '../dist/index.js'; | ||
// This file was created as a sandbox to test and debug on vscode | ||
|
||
// const lua = await Lua.create(); | ||
|
||
// function test() { | ||
// return 1234; | ||
// } | ||
|
||
// for (const index of Array.from({ length: 1 }, (_, i) => i + 1)) { | ||
// console.log(index); | ||
// lua.ctx.test = test; | ||
// for (const i of Array.from({ length: 50 }, (_, i) => i + 1)) { | ||
// await lua.doString('test()'); | ||
// await lua.doString(`print(test.x)`); | ||
// await lua.doString(`test.x = ${i}`); | ||
// } | ||
// } | ||
|
||
class TestClass { | ||
static hello() { | ||
return 'world'; | ||
} | ||
|
||
constructor(name) { | ||
this.name = name; | ||
} | ||
const lua = await Lua.create(); | ||
|
||
getName() { | ||
return this.name; | ||
} | ||
function test() { | ||
return 1234; | ||
} | ||
|
||
toString() { | ||
return `TestClass<${this.name}>`; | ||
for (const index of Array.from({ length: 1 }, (_, i) => i + 1)) { | ||
console.log(index); | ||
lua.ctx.test = test; | ||
for (const i of Array.from({ length: 50 }, (_, i) => i + 1)) { | ||
await lua.doString('test()'); | ||
await lua.doString(`print(test.x)`); | ||
await lua.doString(`test.x = ${i}`); | ||
} | ||
} | ||
|
||
const lua = await Lua.create(); | ||
|
||
lua.ctx.TestClass = { | ||
create: (name) => new TestClass(name), | ||
}; | ||
const res = await lua.doString(` | ||
local instance = TestClass.create("demo name 2") | ||
return instance.getName() | ||
`); | ||
console.log(res); |