Browse Source

Added love.getVersion (resolves issue #809).

Syntax is: major, minor, revision, codename = love.getVersion().
Alex Szpakowski 11 years ago
parent
commit
a2a8b14cfd
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/modules/love/love.cpp

+ 12 - 0
src/modules/love/love.cpp

@@ -170,6 +170,15 @@ const char *love_codename()
 	return love::VERSION_CODENAME;
 }
 
+static int w_love_getVersion(lua_State *L)
+{
+	lua_pushinteger(L, love::VERSION_MAJOR);
+	lua_pushinteger(L, love::VERSION_MINOR);
+	lua_pushinteger(L, love::VERSION_REV);
+	lua_pushstring(L, love::VERSION_CODENAME);
+	return 4;
+}
+
 int luaopen_love(lua_State * L)
 {
 	love::luax_insistglobal(L, "love");
@@ -203,6 +212,9 @@ int luaopen_love(lua_State * L)
 
 	lua_setfield(L, -2, "_version_compat");
 
+	lua_pushcfunction(L, w_love_getVersion);
+	lua_setfield(L, -2, "getVersion");
+
 #ifdef LOVE_WINDOWS
 	lua_pushstring(L, "Windows");
 #elif defined(LOVE_MACOSX)