Lua Bindings For Node.JS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
700 B

var nodelua = require('../../');
var lua = new nodelua.LuaObject();
var add_them = new nodelua.LuaFunction('add_them', function(a, b){
console.log('Adding ' + a + ' and ' + b + ' in js');
return a + b;
});
lua.registerFunction(add_them);
// Functionas are registered globally
// for all LuaObjects
var lua_two = new nodelua.LuaObject();
lua_two.doString("print('Result in Lua: ' .. nodelua('add_them', 10, 5))");
var subtract_them = new nodelua.LuaFunction('subtract_them', function(a, b){
console.log('Subtracting ' + a + ' and ' + b + ' in js');
return a - b;
});
lua_two.registerFunction(subtract_them);
lua.doString("print('Result in Lua: ' .. nodelua('subtract_them', 10, 5))");