diff --git a/src/pc/chat_commands.c b/src/pc/chat_commands.c index df498d7d..becb4b2d 100644 --- a/src/pc/chat_commands.c +++ b/src/pc/chat_commands.c @@ -312,6 +312,11 @@ bool exec_chat_command(char* command) { djui_chat_message_create(message); return true; } + + if (str_starts_with("/lua ", command)) { + smlua_exec_str(&command[5]); + return true; + } #endif return smlua_call_chat_command_hook(command); @@ -327,6 +332,7 @@ void display_chat_commands(void) { } #if defined(DEVELOPMENT) djui_chat_message_create("/warp [LEVEL] [AREA] [ACT] - Level can be either a numeric value or a shorthand name"); + djui_chat_message_create("/lua [LUA] - Execute Lua code from a string"); #endif if (sConfirming != CCC_NONE) { djui_chat_message_create("/confirm"); } smlua_display_chat_commands(); diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index f8abc897..57c9cf4e 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -52,7 +52,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(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.h b/src/pc/lua/smlua.h index d757f207..49a4517e 100644 --- a/src/pc/lua/smlua.h +++ b/src/pc/lua/smlua.h @@ -40,6 +40,7 @@ extern struct Mod* gLuaLastHookMod; void smlua_mod_error(void); int smlua_error_handler(UNUSED lua_State* L); int smlua_pcall(lua_State* L, int nargs, int nresults, int errfunc); +void smlua_exec_str(char* str); void smlua_init(void); void smlua_update(void);