From 36270e4301dc678d689d8f28157cec73afd68e35 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 26 Sep 2022 19:30:09 -0700 Subject: [PATCH] Reran autogen --- autogen/convert_functions.py | 2 +- autogen/lua_definitions/functions.lua | 10 ++--- docs/lua/functions-3.md | 62 +++++++++++++++++++++++++++ docs/lua/functions.md | 8 ++++ src/pc/lua/smlua_functions_autogen.c | 45 ++++++++++++++++++- 5 files changed, 120 insertions(+), 7 deletions(-) diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 6f52f535..af75cee4 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -52,7 +52,7 @@ in_files = [ "src/game/object_list_processor.h", "src/game/behavior_actions.h", "src/game/mario_misc.h", - "src/pc/mods/mod_storage.h" + "src/pc/mods/mod_storage.h", "src/pc/utils/misc.h", "src/game/level_update.h" ] diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index c671421e..75cec01a 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -5211,6 +5211,11 @@ function vec3f_set_dist_and_angle(from, to, dist, pitch, yaw) -- ... end +--- @return nil +function update_all_mario_stars() + -- ... +end + --- @param key string --- @return string function mod_storage_load(key) @@ -5224,11 +5229,6 @@ function mod_storage_save(key, value) -- ... end ---- @return nil -function update_all_mario_stars() - -- ... -end - --- @param courseNum integer --- @param actNum integer --- @param levelNum integer diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index ae9b6fae..5f76aa9a 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -7095,10 +7095,72 @@
+--- +# functions from misc.h
+## [update_all_mario_stars](#update_all_mario_stars) + +### Lua Example +`update_all_mario_stars()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void update_all_mario_stars(void);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from mod_storage.h + +
+ + +## [mod_storage_load](#mod_storage_load) + +### Lua Example +`local stringValue = mod_storage_load(key)` + +### Parameters +| Field | Type | +| ----- | ---- | +| key | `string` | + +### Returns +- `string` + +### C Prototype +`const char *mod_storage_load(const char *key);` + +[:arrow_up_small:](#) + +
+ +## [mod_storage_save](#mod_storage_save) + +### Lua Example +`local booleanValue = mod_storage_save(key, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| key | `string` | +| value | `string` | + +### Returns +- `boolean` + +### C Prototype +`bool mod_storage_save(const char *key, const char *value);` [:arrow_up_small:](#) diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 3a8ced33..8ab4e6b5 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1012,6 +1012,14 @@
+- misc.h + - [update_all_mario_stars](functions-3.md#update_all_mario_stars) + +
+ +- mod_storage.h + - [mod_storage_load](functions-3.md#mod_storage_load) + - [mod_storage_save](functions-3.md#mod_storage_save)
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 2fb7ea86..5f3c9113 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -31,9 +31,9 @@ #include "src/game/object_list_processor.h" #include "src/game/behavior_actions.h" #include "src/game/mario_misc.h" +#include "src/pc/mods/mod_storage.h" #include "src/pc/utils/misc.h" #include "src/game/level_update.h" -#include "src/pc/mods/mod_storage.h" //////////////////////// @@ -11719,6 +11719,43 @@ int smlua_func_vec3s_to_vec3f(lua_State* L) { } */ + //////////// + // misc.h // +//////////// + +int smlua_func_update_all_mario_stars(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + update_all_mario_stars(); + + return 1; +} + + /////////////////// + // mod_storage.h // +/////////////////// + +int smlua_func_mod_storage_load(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 1)) { return 0; } + + const char* key = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'mod_storage_load'"); return 0; } + + lua_pushstring(L, mod_storage_load(key)); + + return 1; +} + +int smlua_func_mod_storage_save(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + const char* key = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 1 for function 'mod_storage_save'"); return 0; } + const char* value = smlua_to_string(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter 2 for function 'mod_storage_save'"); return 0; } + + lua_pushboolean(L, mod_storage_save(key, value)); return 1; } @@ -19205,6 +19242,12 @@ void smlua_bind_functions_autogen(void) { //smlua_bind_function(L, "vec3s_sum", smlua_func_vec3s_sum); <--- UNIMPLEMENTED //smlua_bind_function(L, "vec3s_to_vec3f", smlua_func_vec3s_to_vec3f); <--- UNIMPLEMENTED + // misc.h + smlua_bind_function(L, "update_all_mario_stars", smlua_func_update_all_mario_stars); + + // mod_storage.h + smlua_bind_function(L, "mod_storage_load", smlua_func_mod_storage_load); + smlua_bind_function(L, "mod_storage_save", smlua_func_mod_storage_save); // network_player.h smlua_bind_function(L, "get_network_player_from_area", smlua_func_get_network_player_from_area);