feat(console): add "script" command to debug LUA code

This commit is contained in:
VDm 2025-08-05 23:33:45 +04:00
parent d63ebf7696
commit 0950f7dae3
7 changed files with 52 additions and 3 deletions

View File

@ -17,6 +17,7 @@ target_link_libraries(console
PUBLIC
common
gx
ui
storm
PRIVATE
client

View File

@ -231,7 +231,7 @@ void ConsoleInitializeCommonCommand() {
}
void ConsoleInitializeDebugCommand() {
// TODO
ConsoleCommandRegister("script", ConsoleCommand_Script, DEFAULT, nullptr);
}
int32_t ConsoleCommandComplete(const char* partial, const char** previous, int32_t direction) {

View File

@ -12,6 +12,7 @@ int32_t CCGxRestart(const char* command, const char* argument);
DECLARE_COMMAND(Quit);
DECLARE_COMMAND(Ver);
DECLARE_COMMAND(SetMap);
DECLARE_COMMAND(Script);
DECLARE_COMMAND(Help);
DECLARE_COMMAND(FontColor);

View File

@ -0,0 +1,8 @@
#include "console/Command.hpp"
#include "console/command/Commands.hpp"
#include "ui/FrameScript.hpp"
DECLARE_COMMAND(Script) {
FrameScript_Execute(arguments, "CONSOLE", nullptr);
return 1;
}

View File

@ -9,6 +9,7 @@
#include "world/CWorldScene.hpp"
#include "gameui/camera/CGCamera.hpp"
#include "event/EvtKeyDown.hpp"
#include "console/Console.hpp"
#include "model/Model2.hpp"

View File

@ -7,6 +7,7 @@
#include "gameui/CGDressUpModelFrame.hpp"
#include "gameui/CGTabardModelFrame.hpp"
#include "gameui/CGQuestPOIFrame.hpp"
#include "console/Console.hpp"
#include "ui/FrameXML.hpp"
#include "ui/FrameScript.hpp"
#include "util/Lua.hpp"
@ -1262,7 +1263,14 @@ static int32_t Script_IsThreatWarningEnabled(lua_State* L) {
}
static int32_t Script_ConsoleAddMessage(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
if (!lua_isstring(L, 1)) {
return luaL_error(L, "Usage: ConsoleAddMessage(string)");
}
auto text = lua_tolstring(L, 1, 0);
if (text && *text) {
ConsolePrintf("%s", text);
}
return 0;
}
static int32_t Script_GetItemUniqueness(lua_State* L) {

View File

@ -60,7 +60,37 @@ int32_t strsplit(lua_State* L) {
}
int32_t strjoin(lua_State* L) {
WHOA_UNIMPLEMENTED(0);
size_t length = 0;
auto v9 = luaL_checklstring(L, 1, &length);
int32_t v1 = lua_gettop(L);
int32_t v2 = v1 - 1;
if (length) {
if (v1 == 1) {
lua_pushstring(L, "");
return 1;
} else {
int32_t v4 = 2 * v2;
int32_t v8 = 2 * v2;
if (!lua_checkstack(L, 2 * v2))
return luaL_error(L, "strjoin(): Stack overflow");
if (v2 > 1) {
int32_t v5 = 3;
int32_t v6 = v2 - 1;
do {
lua_pushlstring(L, v9, length);
lua_insert(L, v5);
v5 += 2;
--v6;
} while (v6);
v4 = v8;
}
lua_concat(L, v4 - 1);
return 1;
}
} else {
lua_concat(L, v1);
return 1;
}
}
int32_t sub_816C40(lua_State* L) {