Add /lua to chat commands with dev flag

This commit is contained in:
Agent X 2023-03-08 19:26:03 -05:00
parent 36bda742cd
commit 0c7de174d2
3 changed files with 8 additions and 1 deletions

View file

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

View file

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

View file

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