Ketho / vscode-wow-api

VS Code extension for World of Warcraft AddOns
https://marketplace.visualstudio.com/items?itemName=ketho.wow-api
MIT License
154 stars 33 forks source link

Combat log event enum #130

Open emmericp opened 9 months ago

emmericp commented 9 months ago

I would like to have an Enum for the combat log sub-events, the list of events is available in Blizzard_CombatLog.lua. I tried to add it myself but I couldn't quite figure out the intended way to pull in a dependency on additional default UI files. You seem to pull Blizzard files from your own repository, but how do I get in there in a future-proof way to keep it updated?

Anyhow, if the problem of acquiring the file is solved, then you can use this to extract COMBATLOG_EVENT_LIST from Blizzard_CombatLog.lua (or in fact probably global variables from most arbitrary scripts in general), it's a bit ugly but hopefully pretty future-proof.

An alternative to this mess would be to use lua-language-server with a custom script to extract the content of the variable statically. But given that the rest of the code relies on dynamic evaluation of Blizzard's code I guessed this is fine.

local maxSteps = 10000
local function avoidInfiniteLoop()
        maxSteps = maxSteps - 1
        if maxSteps <= 0 then
                error("loop counter exceeded")
        end
end
local mockEnv
mockEnv = setmetatable({}, {
        __index = function(self, k)
                avoidInfiniteLoop()
                return _G[k] or mockEnv
        end,
        __call = function()
                avoidInfiniteLoop()
                return mockEnv
        end
})
local f = loadfile("Blizzard_CombatLog.lua", nil, mockEnv)

local ok, err = pcall(f)
if not ok then
        print("Warning: unexpected error when loading Blizzard_CombatLog (but that may be fine)", err)
end

local combatLogEvents = rawget(mockEnv, "COMBATLOG_EVENT_LIST")

if not combatLogEvents then
        error("failed to get combatLogEvents")
end

for k in pairs(combatLogEvents) do print(k) end
Ketho commented 9 months ago

I uhh copy everything over manually, so no, not future-proof at all 😅

Thanks for your Lua script for getting the CLEU events. Are you maybe interested in communicating via Discord? (ketho) Otherwise here is fine too. I just have a very busy schedule at the moment so there has not been much progress.

emmericp commented 9 months ago

No urgency here; my discord username is tandanu