Add lovr.getOS;

This commit is contained in:
bjorn 2017-03-11 13:51:15 -08:00
parent ad1706f2ba
commit 3da4d4def9
1 changed files with 14 additions and 0 deletions

View File

@ -21,6 +21,18 @@ static int handleLuaError(lua_State* L) {
return 0;
}
static int lovrGetOS(lua_State* L) {
#ifdef _WIN32
lua_pushstring(L, "Windows");
return 1;
#elif __APPLE__
lua_pushstring(L, "macOS");
return 1;
#endif
lua_pushnil(L);
return 1;
}
static int lovrGetVersion(lua_State* L) {
lua_pushnumber(L, LOVR_VERSION_MAJOR);
lua_pushnumber(L, LOVR_VERSION_MINOR);
@ -54,6 +66,8 @@ void lovrInit(lua_State* L, int argc, char** argv) {
// lovr
lua_newtable(L);
lua_pushcfunction(L, lovrGetOS);
lua_setfield(L, -2, "getOS");
lua_pushcfunction(L, lovrGetVersion);
lua_setfield(L, -2, "getVersion");
lua_setglobal(L, "lovr");