mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
feat: add /dump command for Lua expression evaluation and debugging
/dump <expression> evaluates a Lua expression and prints the result to
chat. For tables, iterates key-value pairs and displays them. Aliases:
/print. Useful for addon development and debugging game state queries
like "/dump GetSpellInfo(133)" or "/dump UnitHealth('player')".
This commit is contained in:
parent
b3f406c6d3
commit
e6fbdfcc02
1 changed files with 25 additions and 1 deletions
|
|
@ -2620,7 +2620,7 @@ void GameScreen::renderChatWindow(game::GameHandler& gameHandler) {
|
|||
"/cancelaura", "/cancelform", "/cancellogout", "/cancelshapeshift",
|
||||
"/cast", "/castsequence", "/chathelp", "/clear", "/clearfocus",
|
||||
"/clearmainassist", "/clearmaintank", "/cleartarget", "/cloak",
|
||||
"/combatlog", "/dance", "/dismount", "/dnd", "/do", "/duel",
|
||||
"/combatlog", "/dance", "/dismount", "/dnd", "/do", "/duel", "/dump",
|
||||
"/e", "/emote", "/equip", "/equipset",
|
||||
"/focus", "/follow", "/forfeit", "/friend",
|
||||
"/g", "/gdemote", "/ginvite", "/gkick", "/gleader", "/gmotd",
|
||||
|
|
@ -6016,6 +6016,30 @@ void GameScreen::sendChatMessage(game::GameHandler& gameHandler) {
|
|||
return;
|
||||
}
|
||||
|
||||
// /dump <expression> — evaluate Lua expression and print result
|
||||
if ((cmdLower == "dump" || cmdLower == "print") && spacePos != std::string::npos) {
|
||||
std::string expr = command.substr(spacePos + 1);
|
||||
auto* am = core::Application::getInstance().getAddonManager();
|
||||
if (am && am->isInitialized()) {
|
||||
// Wrap expression in print(tostring(...)) to display the value
|
||||
std::string wrapped = "local __v = " + expr +
|
||||
"; if type(__v) == 'table' then "
|
||||
" local parts = {} "
|
||||
" for k,v in pairs(__v) do parts[#parts+1] = tostring(k)..'='..tostring(v) end "
|
||||
" print('{' .. table.concat(parts, ', ') .. '}') "
|
||||
"else print(tostring(__v)) end";
|
||||
am->runScript(wrapped);
|
||||
} else {
|
||||
game::MessageChatData errMsg;
|
||||
errMsg.type = game::ChatType::SYSTEM;
|
||||
errMsg.language = game::ChatLanguage::UNIVERSAL;
|
||||
errMsg.message = "Addon system not initialized.";
|
||||
gameHandler.addLocalChatMessage(errMsg);
|
||||
}
|
||||
chatInputBuffer[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
// Check addon slash commands (SlashCmdList) before built-in commands
|
||||
{
|
||||
auto* am = core::Application::getInstance().getAddonManager();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue