-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuffmonitor_agent.lua
More file actions
108 lines (95 loc) · 3.32 KB
/
buffmonitor_agent.lua
File metadata and controls
108 lines (95 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
--==============================================================
-- buffmonitor_agent.lua
-- Project Lazarus EMU / MQNext
--
-- DUAL MODE: Buff Check + Buff Removal
-- Supports "Only report MISSING" and batched removals
--==============================================================
local mq = require('mq')
------------------------------------------------------------
-- Version / Identity
------------------------------------------------------------
local SCRIPT_VERSION = "1.3.0"
------------------------------------------------------------
-- Logging helper
------------------------------------------------------------
local function logMessage(msg)
print("\ao[BuffMonitor_agent] " .. msg)
end
------------------------------------------------------------
-- Startup messages
------------------------------------------------------------
print("\atOriginally created by Alektra <Lederhosen>")
print("\agBuffMonitor_agent v" .. SCRIPT_VERSION .. " Loaded")
logMessage("Script started")
------------------------------------------------------------
-- Args
------------------------------------------------------------
local arg = table.concat({...}, " ")
if not arg or arg == "" then
logMessage("ERROR: No arguments provided.")
return
end
------------------------------------------------------------
-- Mode detection
------------------------------------------------------------
local mode = "CHECK" -- default
if arg:sub(1, 9) == "__REMOVE|" then
mode = "REMOVE"
arg = arg:sub(10) -- strip prefix
end
------------------------------------------------------------
-- Parse args
------------------------------------------------------------
local buffs = {}
local onlyMissing = false
for token in string.gmatch(arg, "([^|]+)") do
if token == "__ONLY_MISSING__" then
onlyMissing = true
else
table.insert(buffs, token)
end
end
if #buffs == 0 then
logMessage("ERROR: No buffs parsed.")
return
end
------------------------------------------------------------
-- Mode: REMOVE
------------------------------------------------------------
if mode == "REMOVE" then
logMessage("REMOVE mode: " .. #buffs .. " buff(s)")
for _, buff in ipairs(buffs) do
mq.cmdf('/removebuff "%s"', buff)
logMessage("Removed: " .. buff)
end
return
end
------------------------------------------------------------
-- Mode: CHECK (original behavior)
------------------------------------------------------------
local MAX_BUFF_SLOTS = 42
local toonName = mq.TLO.Me.CleanName()
local function hasBuff(target)
local needle = target:lower()
for i = 1, MAX_BUFF_SLOTS do
local b = mq.TLO.Me.Buff(i)
if b() and b.Name() then
if b.Name():lower() == needle then
return true
end
end
end
return false
end
------------------------------------------------------------
-- Respond
------------------------------------------------------------
for _, buff in ipairs(buffs) do
local active = hasBuff(buff)
if (not active) or (not onlyMissing) then
local status = active and "ACTIVE" or "MISSING"
mq.cmdf('/g %s: %s = %s', toonName, buff, status)
end
end
logMessage("Reported buffs (onlyMissing=" .. tostring(onlyMissing) .. ")")