diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index af7a8f1d..50a2330f 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -8418,6 +8418,12 @@ function set_override_near(near) -- ... end +--- @param str string +--- @return nil +function smlua_exec_str(str) + -- ... +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 ffe2aaa1..3ff0ece0 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -8658,6 +8658,26 @@
+## [smlua_exec_str](#smlua_exec_str) + +### Lua Example +`smlua_exec_str(str)` + +### Parameters +| Field | Type | +| ----- | ---- | +| str | `string` | + +### Returns +- None + +### C Prototype +`void smlua_exec_str(const char* str);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_model_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 7e9ae5ca..200fe568 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1560,6 +1560,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) + - [smlua_exec_str](functions-4.md#smlua_exec_str)
diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index f8abc897..f13c1fb8 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -7,6 +7,7 @@ #include "pc/lua/utils/smlua_audio_utils.h" #include "pc/lua/utils/smlua_model_utils.h" #include "pc/lua/utils/smlua_level_utils.h" +#include "pc/lua/utils/smlua_misc_utils.h" #include "pc/djui/djui.h" lua_State* gLuaState = NULL; @@ -52,7 +53,7 @@ static void smlua_exec_file(char* path) { lua_pop(L, lua_gettop(L)); } -static void smlua_exec_str(char* str) { +void smlua_exec_str(const char* str) { lua_State* L = gLuaState; if (luaL_dostring(L, str) != LUA_OK) { LOG_LUA("Failed to load lua string."); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 9cb90305..2427181f 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -27411,6 +27411,23 @@ int smlua_func_set_override_near(lua_State* L) { return 1; } +int smlua_func_smlua_exec_str(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", "smlua_exec_str", 1, top); + return 0; + } + + const char* str = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_exec_str"); return 0; } + + smlua_exec_str(str); + + return 1; +} + ///////////////////////// // smlua_model_utils.h // ///////////////////////// @@ -30370,6 +30387,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, "smlua_exec_str", smlua_func_smlua_exec_str); // 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.h b/src/pc/lua/utils/smlua_misc_utils.h index 42537f40..b157f01d 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -96,4 +96,6 @@ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); bool course_is_main_course(u16 levelNum); +void smlua_exec_str(const char* str); + #endif