From 9e58dc8bfc31f27ddd655fd3414992abb7e7366f Mon Sep 17 00:00:00 2001 From: Brett Langdon Date: Sun, 25 Nov 2012 11:06:13 -0500 Subject: [PATCH] moved 'test' script to example, updated package.json to remove test script --- example/example.js | 22 ++++++++++++++++++++++ example/test.lua | 6 ++++++ package.json | 2 +- test/test.js | 20 -------------------- test/test.lua | 1 - 5 files changed, 29 insertions(+), 22 deletions(-) create mode 100755 example/example.js create mode 100644 example/test.lua delete mode 100755 test/test.js delete mode 100644 test/test.lua diff --git a/example/example.js b/example/example.js new file mode 100755 index 0000000..ba89d53 --- /dev/null +++ b/example/example.js @@ -0,0 +1,22 @@ +var path = require('path'); +var nodelua = require('../'); + +var lua = new nodelua.LuaObject(); + +lua.registerFunction('test_func', function(a,b){ + console.dir(a+b); + }); + +lua.setGlobal("test", 5); + +var test_file = path.resolve(__dirname, 'test.lua'); +lua.doFile(test_file); + +console.log("Global Var 'global_var' From Lua:"); +console.dir(lua.getGlobal('global_var')); + +var code = "print('Hello, Lua')"; +lua.doString(code); + + +lua.close(); \ No newline at end of file diff --git a/example/test.lua b/example/test.lua new file mode 100644 index 0000000..61ce524 --- /dev/null +++ b/example/test.lua @@ -0,0 +1,6 @@ +print("Calling JS Function 'test_func' From Lua"); +print(nodelua("test_func", 3, 5)) + +global_var = 'this is a global variable from lua' + +print("Global Var 'test' From JS: " .. test) \ No newline at end of file diff --git a/package.json b/package.json index fe6c90a..f3e15f4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ ], "main": "lib/index.js", "scripts": { - "test": "test/test.js", + "test": "", "install": "node-gyp rebuild" }, "homepage": "http://github.com/brettlangdon/nodelua.git", diff --git a/test/test.js b/test/test.js deleted file mode 100755 index 5fc9934..0000000 --- a/test/test.js +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env node - var path = require('path'); -var nodelua = require('../'); - -var lua = new nodelua.LuaObject(); - -var test_file = path.resolve(__dirname, 'test.lua'); -lua.doFile(test_file); - -lua.setGlobal("test", "value"); -lua.setGlobal("one", 1); -lua.setGlobal("two", true); -lua.setGlobal("none", null); - -console.dir(lua.getGlobal("one")); -console.dir(lua.getGlobal("test")); -console.dir(lua.getGlobal("none")); -console.dir(lua.getGlobal("two")); - -lua.close(); \ No newline at end of file diff --git a/test/test.lua b/test/test.lua deleted file mode 100644 index a23c229..0000000 --- a/test/test.lua +++ /dev/null @@ -1 +0,0 @@ -print "Hello, Lua"