diff --git a/src/luaobject.cc b/src/luaobject.cc index c138fd6..f9e4182 100644 --- a/src/luaobject.cc +++ b/src/luaobject.cc @@ -97,6 +97,8 @@ Handle LuaObject::GetGlobal(const Arguments& args) { return scope.Close(Number::New((int)lua_tonumber(obj->lua_, -1))); }else if(lua_isstring(obj->lua_, -1)){ return scope.Close(String::New((char *)lua_tostring(obj->lua_, -1))); + }else if(lua_isboolean(obj->lua_, -1)){ + return scope.Close(Boolean::New((int)lua_toboolean(obj->lua_, -1))); } return scope.Close(Undefined()); @@ -130,6 +132,9 @@ Handle LuaObject::SetGlobal(const Arguments& args) { }else if(args[1]->IsNumber()){ int value = args[1]->ToNumber()->Value(); lua_pushinteger(obj->lua_, value); + }else if(args[1]->IsBoolean()){ + int value = (int)args[1]->ToBoolean()->Value(); + lua_pushboolean(obj->lua_, value); }else{ lua_pushnil(obj->lua_); } diff --git a/test/test.js b/test/test.js index 2b02e2c..5fc9934 100755 --- a/test/test.js +++ b/test/test.js @@ -9,7 +9,7 @@ lua.doFile(test_file); lua.setGlobal("test", "value"); lua.setGlobal("one", 1); -lua.setGlobal("two", "two"); +lua.setGlobal("two", true); lua.setGlobal("none", null); console.dir(lua.getGlobal("one")); diff --git a/test/test.lua b/test/test.lua index 21bbf5a..a23c229 100644 --- a/test/test.lua +++ b/test/test.lua @@ -1 +1 @@ -print "Hello, Lua" \ No newline at end of file +print "Hello, Lua"