Add GetCombatLogPath/GetChatLogPath Lua functions, update log path globals

Register Lua functions to expose current log paths. At PLAYER_LOGIN,
overwrite COMBATLOGENABLED/CHATLOGENABLED globals with actual redirected
paths (English locale only). Update DLL_README with Lua API and logging
enable instructions.
This commit is contained in:
MarcelineVQ
2026-03-04 14:39:58 -08:00
parent 0c76c99734
commit 1bbf334958
4 changed files with 46 additions and 6 deletions
+25
View File
@@ -14,6 +14,7 @@
const std = @import("std");
const hook = @import("zhook");
const con = @import("../console.zig");
const lua = @import("../lua.zig");
const o = @import("offsets.zig");
const sc = std.builtin.CallingConvention{ .x86_stdcall = .{} };
@@ -475,6 +476,30 @@ pub fn onShutdown() void {
restorePathPointers();
}
// =============================================================================
// Lua API — log path accessors
// =============================================================================
/// GetCombatLogPath() → string or nil
pub fn luaGetCombatLogPath(L: lua.State) callconv(.c) u32 {
if (g_combat_path_len > 0) {
lua.pushstring(L, @ptrCast(g_combat_path[0..g_combat_path_len :0]));
} else {
lua.pushnil(L);
}
return 1;
}
/// GetChatLogPath() → string or nil
pub fn luaGetChatLogPath(L: lua.State) callconv(.c) u32 {
if (g_chat_path_len > 0) {
lua.pushstring(L, @ptrCast(g_chat_path[0..g_chat_path_len :0]));
} else {
lua.pushnil(L);
}
return 1;
}
// =============================================================================
// Install / remove hooks
// =============================================================================
+8
View File
@@ -10,6 +10,14 @@ frame:RegisterEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function()
if event == "PLAYER_LOGIN" then
DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00WeirdUtils|r v" .. WEIRDUTILS_VERSION .. " core loaded")
-- Update log path globals to show actual redirected paths (English locale only)
if GetCombatLogPath and COMBATLOGENABLED == "Combat being logged to Logs\\WoWCombatLog.txt" then
COMBATLOGENABLED = "Combat being logged to " .. GetCombatLogPath()
end
if GetChatLogPath and CHATLOGENABLED == "Chat being logged to Logs\\WoWChatLog.txt" then
CHATLOGENABLED = "Chat being logged to " .. GetChatLogPath()
end
end
end)
+4
View File
@@ -108,6 +108,10 @@ fn registerLuaFunctions() void {
if (build_opts.outline) {
registerFunction("OutlineCommand", @intFromPtr(&outline.outlineCommand));
}
if (build_opts.combatlog) {
registerFunction("GetCombatLogPath", @intFromPtr(&combatlog.luaGetCombatLogPath));
registerFunction("GetChatLogPath", @intFromPtr(&combatlog.luaGetChatLogPath));
}
if (build_opts.worldmarkers and markers.isActive()) {
// User-facing functions stay global
registerFunction("WorldMarker", @intFromPtr(&markers.luaWorldMarker));