Skip to content

The Lua binding for JavaScript.

License

approvers/do-lua

Repository files navigation

do-lua

The Lua runtime for Node.js.

Usage

import { doFile, doString } from 'do-lua';

const program = `
print("Hello, World!")
`;

await doString(program);
await doFile('examples/test1.lua');

You cannot use this in functions of the passing table on loadProgram. Use arrow function instead of that.

import { loadProgram } from 'do-lua';

const state = loadProgram(`
obj.ox = 50;
obj.mes("Hello, World!")
`);
let message = '';
const table = {
  ox: 0,
  mes: (text) => {
    message += text; // `this` cannot be used but can capture variables.
  }
};
state.setTable('obj', table);

// G is global table exclusive "package" and "_G"
const G = await state.run()
console.log("ox: ", G.obj.ox); // 50
console.log("Message: ", message); // Hello, World!

About

The Lua binding for JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 2

  •  
  •