add a way for Lua mods to detect what OS coop is running on (#338)

* patch for beta 32

* bump version

* fix lakitu cam duplication hopefully

* add a way for Lua mods to see what OS its running on
This commit is contained in:
Isaac0-dev 2023-04-09 09:52:16 +10:00 committed by GitHub
parent 2f4008f9c9
commit f7a3e5f0a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 0 deletions

View file

@ -8350,6 +8350,11 @@ function get_network_area_timer()
-- ... -- ...
end end
--- @return string
function get_os_name()
-- ...
end
--- @return integer --- @return integer
function get_skybox() function get_skybox()
-- ... -- ...

View file

@ -8353,6 +8353,24 @@
<br /> <br />
## [get_os_name](#get_os_name)
### Lua Example
`local stringValue = get_os_name()`
### Parameters
- None
### Returns
- `string`
### C Prototype
`char* get_os_name(void);`
[:arrow_up_small:](#)
<br />
## [get_skybox](#get_skybox) ## [get_skybox](#get_skybox)
### Lua Example ### Lua Example

View file

@ -1554,6 +1554,7 @@
- [get_last_star_or_key](functions-4.md#get_last_star_or_key) - [get_last_star_or_key](functions-4.md#get_last_star_or_key)
- [get_lighting_dir](functions-4.md#get_lighting_dir) - [get_lighting_dir](functions-4.md#get_lighting_dir)
- [get_network_area_timer](functions-4.md#get_network_area_timer) - [get_network_area_timer](functions-4.md#get_network_area_timer)
- [get_os_name](functions-4.md#get_os_name)
- [get_skybox](functions-4.md#get_skybox) - [get_skybox](functions-4.md#get_skybox)
- [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer) - [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer)
- [get_time](functions-4.md#get_time) - [get_time](functions-4.md#get_time)

View file

@ -27230,6 +27230,21 @@ int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
return 1; return 1;
} }
int smlua_func_get_os_name(UNUSED lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 0) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_os_name", 0, top);
return 0;
}
lua_pushstring(L, get_os_name());
return 1;
}
int smlua_func_get_skybox(UNUSED lua_State* L) { int smlua_func_get_skybox(UNUSED lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -30616,6 +30631,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_last_star_or_key", smlua_func_get_last_star_or_key); smlua_bind_function(L, "get_last_star_or_key", smlua_func_get_last_star_or_key);
smlua_bind_function(L, "get_lighting_dir", smlua_func_get_lighting_dir); smlua_bind_function(L, "get_lighting_dir", smlua_func_get_lighting_dir);
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer); smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
smlua_bind_function(L, "get_os_name", smlua_func_get_os_name);
smlua_bind_function(L, "get_skybox", smlua_func_get_skybox); smlua_bind_function(L, "get_skybox", smlua_func_get_skybox);
smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer); smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer);
smlua_bind_function(L, "get_time", smlua_func_get_time); smlua_bind_function(L, "get_time", smlua_func_get_time);

View file

@ -438,3 +438,19 @@ u16 get_envfx(void) {
void set_override_envfx(s32 envfx) { void set_override_envfx(s32 envfx) {
gOverrideEnvFx = envfx; gOverrideEnvFx = envfx;
} }
char* get_os_name(void) {
#if defined(_WIN32) || defined(_WIN64)
return "Windows";
#elif __APPLE__ || __MACH__
return "Mac OSX";
#elif __linux__
return "Linux";
#elif __FreeBSD__
return "FreeBSD";
#elif __unix || __unix__
return "Unix";
#else
return "Unknown";
#endif
}

View file

@ -110,4 +110,6 @@ u32 get_time(void);
u16 get_envfx(void); u16 get_envfx(void);
void set_override_envfx(s32 envfx); void set_override_envfx(s32 envfx);
char* get_os_name(void);
#endif #endif