diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 0b0d8fb2..8647dac0 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -7847,12 +7847,6 @@ function djui_hud_set_render_behind_hud(enable) -- ... end ---- @param index integer ---- @return number -function get_environment_region(index) - -- ... -end - --- @param localIndex integer --- @return string function network_discord_id_from_local_index(localIndex) @@ -7873,12 +7867,6 @@ function network_player_palette_to_color(np, part, out) -- ... end ---- @param index integer ---- @param value integer -function set_environment_region(index, value) - -- ... -end - --- @param index integer --- @return integer function get_fog_color(index) @@ -8201,6 +8189,12 @@ function get_envfx() -- ... end +--- @param index integer +--- @return number +function get_environment_region(index) + -- ... +end + --- @return integer function get_global_timer() -- ... @@ -8407,6 +8401,12 @@ function save_file_set_using_backup_slot(usingBackupSlot) -- ... end +--- @param index integer +--- @param value integer +function set_environment_region(index, value) + -- ... +end + --- @param value boolean function set_got_file_coin_hi_score(value) -- ... diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 3d135b6e..9e36d7a8 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -2174,6 +2174,26 @@
+## [get_environment_region](#get_environment_region) + +### Lua Example +`local numberValue = get_environment_region(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 get_environment_region(u8 index);` + +[:arrow_up_small:](#) + +
+ ## [get_global_timer](#get_global_timer) ### Lua Example @@ -2871,6 +2891,27 @@
+## [set_environment_region](#set_environment_region) + +### Lua Example +`set_environment_region(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_environment_region(u8 index, s32 value);` + +[:arrow_up_small:](#) + +
+ ## [set_got_file_coin_hi_score](#set_got_file_coin_hi_score) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 332c87b6..90e295a4 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1720,6 +1720,7 @@ - [get_dialog_id](functions-5.md#get_dialog_id) - [get_dialog_response](functions-5.md#get_dialog_response) - [get_envfx](functions-5.md#get_envfx) + - [get_environment_region](functions-5.md#get_environment_region) - [get_global_timer](functions-5.md#get_global_timer) - [get_got_file_coin_hi_score](functions-5.md#get_got_file_coin_hi_score) - [get_hand_foot_pos_x](functions-5.md#get_hand_foot_pos_x) @@ -1756,6 +1757,7 @@ - [reset_window_title](functions-5.md#reset_window_title) - [save_file_get_using_backup_slot](functions-5.md#save_file_get_using_backup_slot) - [save_file_set_using_backup_slot](functions-5.md#save_file_set_using_backup_slot) + - [set_environment_region](functions-5.md#set_environment_region) - [set_got_file_coin_hi_score](functions-5.md#set_got_file_coin_hi_score) - [set_last_completed_course_num](functions-5.md#set_last_completed_course_num) - [set_last_completed_star_num](functions-5.md#set_last_completed_star_num) diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 6c8ad2f9..dfef8508 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -29146,23 +29146,6 @@ int smlua_func_djui_hud_set_render_behind_hud(lua_State* L) { return 1; } -int smlua_func_get_environment_region(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 1) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_environment_region", 1, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_environment_region"); return 0; } - - lua_pushnumber(L, get_environment_region(index)); - - return 1; -} - int smlua_func_network_discord_id_from_local_index(lua_State* L) { if (L == NULL) { return 0; } @@ -29238,25 +29221,6 @@ int smlua_func_network_player_palette_to_color(lua_State* L) { return 1; } -int smlua_func_set_environment_region(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_environment_region", 2, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_environment_region"); return 0; } - s32 value = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_environment_region"); return 0; } - - set_environment_region(index, value); - - return 1; -} - /////////////////////// // smlua_gfx_utils.h // /////////////////////// @@ -30217,6 +30181,23 @@ int smlua_func_get_envfx(UNUSED lua_State* L) { return 1; } +int smlua_func_get_environment_region(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_environment_region", 1, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_environment_region"); return 0; } + + lua_pushnumber(L, get_environment_region(index)); + + return 1; +} + int smlua_func_get_global_timer(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -30829,6 +30810,25 @@ int smlua_func_save_file_set_using_backup_slot(lua_State* L) { return 1; } +int smlua_func_set_environment_region(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_environment_region", 2, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_environment_region"); return 0; } + s32 value = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_environment_region"); return 0; } + + set_environment_region(index, value); + + return 1; +} + int smlua_func_set_got_file_coin_hi_score(lua_State* L) { if (L == NULL) { return 0; } @@ -34448,11 +34448,9 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "audio_stream_set_speed", smlua_func_audio_stream_set_speed); smlua_bind_function(L, "audio_stream_set_tempo", smlua_func_audio_stream_set_tempo); smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud); - smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region); smlua_bind_function(L, "network_discord_id_from_local_index", smlua_func_network_discord_id_from_local_index); smlua_bind_function(L, "network_player_color_to_palette", smlua_func_network_player_color_to_palette); smlua_bind_function(L, "network_player_palette_to_color", smlua_func_network_player_palette_to_color); - smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region); // smlua_gfx_utils.h smlua_bind_function(L, "get_fog_color", smlua_func_get_fog_color); @@ -34515,6 +34513,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "get_dialog_id", smlua_func_get_dialog_id); smlua_bind_function(L, "get_dialog_response", smlua_func_get_dialog_response); smlua_bind_function(L, "get_envfx", smlua_func_get_envfx); + smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region); smlua_bind_function(L, "get_global_timer", smlua_func_get_global_timer); smlua_bind_function(L, "get_got_file_coin_hi_score", smlua_func_get_got_file_coin_hi_score); smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x); @@ -34551,6 +34550,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "reset_window_title", smlua_func_reset_window_title); smlua_bind_function(L, "save_file_get_using_backup_slot", smlua_func_save_file_get_using_backup_slot); smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot); + smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region); smlua_bind_function(L, "set_got_file_coin_hi_score", smlua_func_set_got_file_coin_hi_score); smlua_bind_function(L, "set_last_completed_course_num", smlua_func_set_last_completed_course_num); smlua_bind_function(L, "set_last_completed_star_num", smlua_func_set_last_completed_star_num); diff --git a/src/pc/lua/utils/smlua_deprecated.c b/src/pc/lua/utils/smlua_deprecated.c index 252b1ff6..7e02df5b 100644 --- a/src/pc/lua/utils/smlua_deprecated.c +++ b/src/pc/lua/utils/smlua_deprecated.c @@ -43,23 +43,6 @@ void audio_stream_set_speed(UNUSED struct ModAudio* audio, UNUSED f32 initial_fr LOG_LUA_LINE_WARNING("[LUA] audio_stream_set_speed() is deprecated! There may be a replacement for this function in the future."); } -f32 get_environment_region(u8 index) { - LOG_LUA_LINE_WARNING("[LUA] get_environment_region() is deprecated! Use get_water_level() instead."); - s32 idx = 6 * index; - if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) { - return gEnvironmentRegions[idx]; - } - return gLevelValues.floorLowerLimit; -} - -void set_environment_region(u8 index, s32 value) { - LOG_LUA_LINE_WARNING("[LUA] get_environment_region() is deprecated! Use set_water_level() instead."); - s32 idx = 6 * index; - if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) { - gEnvironmentRegions[idx] = value; - } -} - void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerPart part, Color color) { LOG_LUA_LINE_WARNING("[LUA] network_player_color_to_palette() is deprecated! Use network_player_set_override_palette_color() instead."); if (np == NULL || !(part < PLAYER_PART_MAX && part >= 0)) { return; } diff --git a/src/pc/lua/utils/smlua_deprecated.h b/src/pc/lua/utils/smlua_deprecated.h index f65d0d09..143b9b3d 100644 --- a/src/pc/lua/utils/smlua_deprecated.h +++ b/src/pc/lua/utils/smlua_deprecated.h @@ -8,8 +8,5 @@ f32 audio_stream_get_tempo(struct ModAudio* audio); void audio_stream_set_tempo(struct ModAudio* audio, f32 tempo); void audio_stream_set_speed(struct ModAudio* audio, f32 initial_freq, f32 speed, bool pitch); -f32 get_environment_region(u8 index); -void set_environment_region(u8 index, s32 value); - void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerPart part, Color color); void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerPart part, Color out); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 473ef7b3..49377058 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -462,6 +462,23 @@ void set_volume_env(f32 volume) { /// +f32 get_environment_region(u8 index) { + s32 idx = 6 * index; + if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) { + return gEnvironmentRegions[idx]; + } + return gLevelValues.floorLowerLimit; +} + +void set_environment_region(u8 index, s32 value) { + s32 idx = 6 * index; + if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) { + gEnvironmentRegions[idx] = value; + } +} + +/// + void set_window_title(const char* title) { WAPI.set_window_title(title); } diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 5768ee2a..19f3669e 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -121,6 +121,9 @@ void set_volume_level(f32 volume); void set_volume_sfx(f32 volume); void set_volume_env(f32 volume); +f32 get_environment_region(u8 index); +void set_environment_region(u8 index, s32 value); + void set_window_title(const char* title); void reset_window_title(void);