diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 4aa02989..c0f86634 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -8333,6 +8333,11 @@ function get_time() -- ... end +--- @return integer +function get_ttc_speed_setting() + -- ... +end + --- @param type HudDisplayValue --- @return integer function hud_get_value(type) @@ -8437,6 +8442,12 @@ function set_override_near(near) -- ... end +--- @param speed integer +--- @return nil +function set_ttc_speed_setting(speed) + -- ... +end + --- @param name string --- @return integer function smlua_model_util_get_id(name) diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index f3154297..30cb2603 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -8353,6 +8353,24 @@
+## [get_ttc_speed_setting](#get_ttc_speed_setting) + +### Lua Example +`local integerValue = get_ttc_speed_setting()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s16 get_ttc_speed_setting();` + +[:arrow_up_small:](#) + +
+ ## [hud_get_value](#hud_get_value) ### Lua Example @@ -8676,6 +8694,26 @@
+## [set_ttc_speed_setting](#set_ttc_speed_setting) + +### Lua Example +`set_ttc_speed_setting(speed)` + +### Parameters +| Field | Type | +| ----- | ---- | +| speed | `integer` | + +### Returns +- None + +### C Prototype +`void set_ttc_speed_setting(s16 speed);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_model_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 94ad7e7d..a77a11eb 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1547,6 +1547,7 @@ - [get_network_area_timer](functions-4.md#get_network_area_timer) - [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer) - [get_time](functions-4.md#get_time) + - [get_ttc_speed_setting](functions-4.md#get_ttc_speed_setting) - [hud_get_value](functions-4.md#hud_get_value) - [hud_hide](functions-4.md#hud_hide) - [hud_is_hidden](functions-4.md#hud_is_hidden) @@ -1563,6 +1564,7 @@ - [set_override_far](functions-4.md#set_override_far) - [set_override_fov](functions-4.md#set_override_fov) - [set_override_near](functions-4.md#set_override_near) + - [set_ttc_speed_setting](functions-4.md#set_ttc_speed_setting)
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 7a06992d..a2219ff4 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -27176,6 +27176,21 @@ int smlua_func_get_time(UNUSED lua_State* L) { return 1; } +int smlua_func_get_ttc_speed_setting(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_ttc_speed_setting", 0, top); + return 0; + } + + + lua_pushinteger(L, get_ttc_speed_setting()); + + return 1; +} + int smlua_func_hud_get_value(lua_State* L) { if (L == NULL) { return 0; } @@ -27464,6 +27479,23 @@ int smlua_func_set_override_near(lua_State* L) { return 1; } +int smlua_func_set_ttc_speed_setting(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", "set_ttc_speed_setting", 1, top); + return 0; + } + + s16 speed = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_ttc_speed_setting"); return 0; } + + set_ttc_speed_setting(speed); + + return 1; +} + ///////////////////////// // smlua_model_utils.h // ///////////////////////// @@ -30410,6 +30442,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer); 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_ttc_speed_setting", smlua_func_get_ttc_speed_setting); smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value); smlua_bind_function(L, "hud_hide", smlua_func_hud_hide); smlua_bind_function(L, "hud_is_hidden", smlua_func_hud_is_hidden); @@ -30426,6 +30459,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_override_far", smlua_func_set_override_far); smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov); smlua_bind_function(L, "set_override_near", smlua_func_set_override_near); + smlua_bind_function(L, "set_ttc_speed_setting", smlua_func_set_ttc_speed_setting); // smlua_model_utils.h smlua_bind_function(L, "smlua_model_util_get_id", smlua_func_smlua_model_util_get_id); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 8ac81bec..fdab7020 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -389,6 +389,16 @@ bool course_is_main_course(u16 levelNum) { /// +s16 get_ttc_speed_setting() { + return gTTCSpeedSetting; +} + +void set_ttc_speed_setting(s16 speed) { + gTTCSpeedSetting = speed; +} + +/// + u32 get_time(void) { return time(NULL); } diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 6e8efecb..0d5a5c16 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -96,6 +96,9 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); bool course_is_main_course(u16 levelNum); +s16 get_ttc_speed_setting(); +void set_ttc_speed_setting(s16 speed); + u32 get_time(void); #endif diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 49ed0b3b..45bb0408 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -20,6 +20,7 @@ #include "pc/crash_handler.h" #include "pc/debuglog.h" #include "game/camera.h" +#include "game/object_list_processor.h" #include "game/object_helpers.h" #include "menu/intro_geo.h" @@ -521,6 +522,8 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) { camera_set_use_course_specific_settings(true); free_vtx_scroll_targets(); gMarioStates[0].cap = 0; + extern s16 gTTCSpeedSetting; + gTTCSpeedSetting = 0; struct Controller* cnt = gMarioStates[0].controller; cnt->rawStickX = 0;