From c95c797da61b4b2829d542f6d7c164a88951cad4 Mon Sep 17 00:00:00 2001 From: jussi Date: Mon, 20 May 2024 17:56:28 +0300 Subject: GetPlatform. --- src/core.c | 25 +++++++++++++++++++++++++ src/lua_core.c | 1 + 2 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/core.c b/src/core.c index 2146510..d22ed60 100644 --- a/src/core.c +++ b/src/core.c @@ -1490,6 +1490,31 @@ int lcoreSetGCUnload( lua_State* L ) { return 0; } +/* +> platform = RL.GetPlatform() + +Get platform. Returns "Windows", "Linux", "FreeBSD", "OpenBSD", "Apple" or "Emscripten" + +- Success return string +*/ +int lcoreGetPlatform( lua_State* L ) { +#if defined( _WIN32 ) + lua_pushstring( L, "Windows" ); +#elif defined( __linux__ ) + lua_pushstring( L, "Linux" ); +#elif defined( __FreeBSD__ ) + lua_pushstring( L, "FreeBSD" ); +#elif defined( __OpenBSD__ ) + lua_pushstring( L, "OpenBSD" ); +#elif defined( __APPLE__ ) + lua_pushstring( L, "Apple" ); +#elif defined( __EMSCRIPTEN__ ) + lua_pushstring( L, "Emscripten" ); +#endif + + return 1; +} + /* ## Core - Files management functions */ diff --git a/src/lua_core.c b/src/lua_core.c index 6d89777..6330930 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1378,6 +1378,7 @@ void luaRegister() { assingGlobalFunction( "OpenURL", lcoreOpenURL ); assingGlobalFunction( "IsGCUnloadEnabled", lcoreIsGCUnloadEnabled ); assingGlobalFunction( "SetGCUnload", lcoreSetGCUnload ); + assingGlobalFunction( "GetPlatform", lcoreGetPlatform ); /* Files management functions. */ assingGlobalFunction( "LoadFileData", lcoreLoadFileData ); assingGlobalFunction( "SaveFileData", lcoreSaveFileData ); -- cgit v1.2.3