get_ttc_speed_setting and set_ttc_speed_setting (#307)

This commit is contained in:
Agent X 2023-03-20 20:20:11 -04:00 committed by GitHub
parent 90bc1732f1
commit 42b43a9b7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 101 additions and 0 deletions

View file

@ -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)

View file

@ -8353,6 +8353,24 @@
<br />
## [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:](#)
<br />
## [hud_get_value](#hud_get_value)
### Lua Example
@ -8676,6 +8694,26 @@
<br />
## [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:](#)
<br />
---
# functions from smlua_model_utils.h

View file

@ -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)
<br />

View file

@ -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);

View file

@ -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);
}

View file

@ -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

View file

@ -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;