From 93bdbf81c3d7f80da026d31b0aff2dc2d4076ab1 Mon Sep 17 00:00:00 2001 From: Emerald Lockdown <86802223+EmeraldLoc@users.noreply.github.com> Date: Sun, 7 Aug 2022 22:53:42 -0500 Subject: [PATCH] Expose save star flag (#139) * added save_file_set_star_flags and save_reload --- autogen/convert_functions.py | 2 +- autogen/lua_definitions/functions.lua | 8 ++++++++ docs/lua/functions-4.md | 22 ++++++++++++++++++++++ docs/lua/functions.md | 1 + src/pc/lua/smlua_functions_autogen.c | 16 ++++++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 00f7e2e7..5d484740 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -58,7 +58,7 @@ override_allowed_functions = { "src/audio/external.h": [ " play_", "fade", "current_background" ], "src/game/rumble_init.c": [ "queue_rumble_", "reset_rumble_timers" ], "src/pc/djui/djui_popup.h" : [ "create" ], - "src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags", "save_file_erase", "save_file_reload" ], + "src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags", "save_file_erase", "save_file_reload", "save_file_set_star_flags" ], "src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ], "src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ], "src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*" ], diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 40a6b340..5f264a9a 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -7271,6 +7271,14 @@ function save_file_set_flags(flags) -- ... end +--- @param fileIndex integer +--- @param courseIndex integer +--- @param starFlags integer +--- @return nil +function save_file_set_star_flags(fileIndex, courseIndex, starFlags) + -- ... +end + --- @param audio BassAudio --- @return nil function audio_sample_destroy(audio) diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 7692f56a..db18a1cf 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -5583,6 +5583,28 @@
+## [save_file_set_star_flags](#save_file_set_star_flags) + +### Lua Example +`save_file_set_star_flags(fileIndex, courseIndex, starFlags)` + +### Parameters +| Field | Type | +| ----- | ---- | +| fileIndex | `integer` | +| courseIndex | `integer` | +| starFlags | `integer` | + +### Returns +- None + +### C Prototype +`void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_audio_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 38833551..8b9b1ebb 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1350,6 +1350,7 @@ - [save_file_get_total_star_count](functions-4.md#save_file_get_total_star_count) - [save_file_reload](functions-4.md#save_file_reload) - [save_file_set_flags](functions-4.md#save_file_set_flags) + - [save_file_set_star_flags](functions-4.md#save_file_set_star_flags)
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 95d04e79..1feb857a 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -16125,6 +16125,21 @@ int smlua_func_save_file_set_flags(lua_State* L) { return 1; } +int smlua_func_save_file_set_star_flags(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + s32 fileIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1"); return 0; } + s32 courseIndex = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2"); return 0; } + u32 starFlags = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 3"); return 0; } + + save_file_set_star_flags(fileIndex, courseIndex, starFlags); + + return 1; +} + ///////////////////////// // smlua_audio_utils.h // ///////////////////////// @@ -19287,6 +19302,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "save_file_get_total_star_count", smlua_func_save_file_get_total_star_count); smlua_bind_function(L, "save_file_reload", smlua_func_save_file_reload); smlua_bind_function(L, "save_file_set_flags", smlua_func_save_file_set_flags); + smlua_bind_function(L, "save_file_set_star_flags", smlua_func_save_file_set_star_flags); // smlua_audio_utils.h smlua_bind_function(L, "audio_sample_destroy", smlua_func_audio_sample_destroy);