-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
369 lines (332 loc) · 14.4 KB
/
init.lua
File metadata and controls
369 lines (332 loc) · 14.4 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
-- ClickyList by Algar
-- written in part using Sonnet/Opus 4.5
-- Version 1.1
-- A script to display extensive info about your current clicky items
-- /lua run clickylist
local mq = require('mq')
local ImGui = require('ImGui')
local openGUI = true
local showConsumables = false
local clickyItems = {}
local animItems = mq.FindTextureAnimation("A_DragItem")
local sortColumn = 0
local sortAscending = true
local targetColors = {
{ type = "find", values = { "self", "pet", }, color = { 1.0, 0.9, 0.5, 1, }, },
{ type = "exact", values = { "single", "single in group", }, color = { 1.0, 0.5, 0.5, 1, }, },
{ type = "find", values = { "tap", }, color = { 0.8, 0.3, 0.3, 1, }, },
{ type = "exact", values = { "corpse", }, color = { 0.5, 0.5, 0.5, 1, }, },
{ type = "find", values = { "target of target", }, color = { 1.0, 0.6, 0.85, 1, }, },
{ type = "find", values = { "group", "ae pc", "pb", }, color = { 0.8, 0.6, 1.0, 1, }, },
{ type = "exact", values = { "free target", "targeted ae", }, color = { 0.4, 1.0, 0.4, 1, }, },
}
local defaultTargetColor = { 1.0, 1.0, 1.0, 1, }
local locationColors = {
bag = ImVec4(0.7, 0.8, 1.0, 1),
inv = ImVec4(1.0, 0.9, 0.6, 1),
equipment = ImVec4(0.7, 1.0, 0.8, 1),
}
local equipSlotNames = {
[0] = "Charm",
[1] = "Left Ear",
[2] = "Head",
[3] = "Face",
[4] = "Right Ear",
[5] = "Neck",
[6] = "Shoulders",
[7] = "Arms",
[8] = "Back",
[9] = "Left Wrist",
[10] = "Right Wrist",
[11] = "Range",
[12] = "Hands",
[13] = "Primary",
[14] = "Secondary",
[15] = "Left Finger",
[16] = "Right Finger",
[17] = "Chest",
[18] = "Legs",
[19] = "Feet",
[20] = "Waist",
[21] = "Power Source",
[22] = "Ammo",
}
local function addClickies(item, location)
if item() and item.Clicky() and (showConsumables or (item.Clicky.MaxCharges() or 0) < 0) and (item.Clicky.RecastType() or 0) >= 0 then
table.insert(clickyItems, {
name = item.Name(),
item = item,
location = location,
spell = item.Clicky.Spell,
spellName = (item.Clicky.Spell() and item.Clicky.Spell.Name()) or "Unknown",
castTime = item.Clicky.CastTime() or 0,
recastDelay = item.Clicky.TimerID() or 0,
recastType = item.Clicky.RecastType() or 0,
requiredLevel = item.Clicky.RequiredLevel() or 0,
targetType = (item.Clicky.Spell() and item.Clicky.Spell.TargetType()) or "Unknown",
beneficial = item.Clicky.Spell() and item.Clicky.Spell.Beneficial(),
iconId = (item.Icon() or 500) - 500,
})
end
end
local function addAugClickies(item, location)
if not item() then return end
local augLocation = location .. " (Aug)"
for i = 1, 6 do
local aug = item.AugSlot(i).Item
if aug() then
addClickies(aug, augLocation)
end
end
end
local function getLocationSortValue(location)
local isAug = location:find(" %(Aug%)") and 0.5 or 0
local base = location:gsub(" %(Aug%)", "")
for slot, name in pairs(equipSlotNames) do
if base == name then return slot + isAug end
end
local invNum = base:match("^Inv (%d+)$")
if invNum then return 100 + tonumber(invNum) + isAug end
local bagNum, slotNum = base:match("^Bag (%d+), Slot (%d+)$")
if bagNum then return 200 + (tonumber(bagNum) * 100) + tonumber(slotNum) + isAug end
return 9999
end
local function applySorting()
if #clickyItems <= 1 then return end
table.sort(clickyItems, function(a, b)
local va, vb
if sortColumn == 0 then
va, vb = a.name:lower(), b.name:lower()
elseif sortColumn == 1 then
va, vb = a.spellName:lower(), b.spellName:lower()
elseif sortColumn == 2 then
va, vb = a.targetType:lower(), b.targetType:lower()
elseif sortColumn == 3 then
va, vb = a.castTime, b.castTime
elseif sortColumn == 4 then
va, vb = a.recastDelay, b.recastDelay
elseif sortColumn == 5 then
va, vb = a.recastType, b.recastType
elseif sortColumn == 6 then
va, vb = a.requiredLevel, b.requiredLevel
elseif sortColumn == 7 then
va, vb = getLocationSortValue(a.location), getLocationSortValue(b.location)
else
return false
end
if va == vb then
return a.name:lower() < b.name:lower()
end
if sortAscending then
return va < vb
else
return va > vb
end
end)
end
local function scanClickyItems()
clickyItems = {}
for slot = 0, 22 do
local item = mq.TLO.InvSlot(slot).Item
local location = equipSlotNames[slot]
addClickies(item, location)
addAugClickies(item, location)
end
for bag = 23, 32 do
local bagItem = mq.TLO.InvSlot(bag).Item
if bagItem() then
local bagLocation = string.format("Inv %d", bag - 22)
addClickies(bagItem, bagLocation)
addAugClickies(bagItem, bagLocation)
for slot = 1, bagItem.Container() or 0 do
local item = bagItem.Item(slot)
local itemLocation = string.format("Bag %d, Slot %d", bag - 22, slot)
addClickies(item, itemLocation)
addAugClickies(item, itemLocation)
end
end
end
applySorting()
end
local function renderGUI()
if mq.TLO.MacroQuest.GameState() ~= "INGAME" then return end
ImGui.SetNextWindowSize(ImVec2(1090, 500), ImGuiCond.FirstUseEver)
ImGui.SetNextWindowSizeConstraints(ImVec2(390, 200), ImVec2(2000, 2000))
local shouldDraw
openGUI, shouldDraw = ImGui.Begin('Clicky List###clickylist', openGUI)
if shouldDraw then
if ImGui.Button("Rescan") then
scanClickyItems()
end
ImGui.SameLine()
ImGui.Text("Found %d clicky items", #clickyItems)
ImGui.SameLine(ImGui.GetWindowWidth() - 160)
local newShowConsumables = ImGui.Checkbox("Show Consumables", showConsumables)
if newShowConsumables ~= showConsumables then
showConsumables = newShowConsumables
scanClickyItems()
end
ImGui.Separator()
local tableFlags = bit32.bor(ImGuiTableFlags.Resizable, ImGuiTableFlags.Borders, ImGuiTableFlags.RowBg, ImGuiTableFlags.ScrollY, ImGuiTableFlags.Sortable,
ImGuiTableFlags.Hideable, ImGuiTableFlags.Reorderable)
if ImGui.BeginTable("ClickyTable", 8, tableFlags) then
ImGui.TableSetupColumn('Item', bit32.bor(ImGuiTableColumnFlags.WidthStretch, ImGuiTableColumnFlags.DefaultSort), 300.0)
ImGui.TableSetupColumn('Spell', ImGuiTableColumnFlags.WidthStretch, 225.0)
ImGui.TableSetupColumn('Target', ImGuiTableColumnFlags.WidthFixed, 115.0)
ImGui.TableSetupColumn('Cast', ImGuiTableColumnFlags.WidthFixed, 55.0)
ImGui.TableSetupColumn('Recast', ImGuiTableColumnFlags.WidthFixed, 75.0)
ImGui.TableSetupColumn('Timer', ImGuiTableColumnFlags.WidthFixed, 45.0)
ImGui.TableSetupColumn('Min Lvl', ImGuiTableColumnFlags.WidthFixed, 60.0)
ImGui.TableSetupColumn('Location', ImGuiTableColumnFlags.WidthFixed, 130.0)
ImGui.TableSetupScrollFreeze(0, 1)
ImGui.TableHeadersRow()
local sortSpecs = ImGui.TableGetSortSpecs()
if sortSpecs and sortSpecs.SpecsDirty then
local spec = sortSpecs:Specs(1)
sortColumn = spec.ColumnIndex
sortAscending = spec.SortDirection == ImGuiSortDirection.Ascending
applySorting()
sortSpecs.SpecsDirty = false
end
for idx, clicky in ipairs(clickyItems) do
ImGui.TableNextRow()
ImGui.TableNextColumn()
local headerScreenPos = ImGui.GetCursorScreenPosVec()
animItems:SetTextureCell(clicky.iconId)
local drawList = ImGui.GetWindowDrawList()
drawList:AddTextureAnimation(animItems, ImVec2(headerScreenPos.x, headerScreenPos.y), ImVec2(16, 16))
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + 20)
if clicky.beneficial == true then
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.4, 1.0, 0.4, 1))
elseif clicky.beneficial == false then
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(1.0, 0.4, 0.4, 1))
else
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.6, 0.9, 1, 1))
end
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, ImGui.GetColorU32(0.12, 0.12, 0.12, 1))
ImGui.PushID("item_" .. idx)
local _, itemClicked = ImGui.Selectable(clicky.name)
ImGui.PopStyleColor(2)
if ImGui.IsItemHovered() then
ImGui.BeginTooltip()
ImGui.Text("Item ID: %s (click to inspect)", clicky.item.ID())
ImGui.EndTooltip()
end
if itemClicked and clicky.item then
clicky.item.Inspect()
end
ImGui.PopID()
ImGui.TableNextColumn()
if clicky.spell and clicky.spell() then
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(1, 0.65, 0, 1))
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, ImGui.GetColorU32(0.12, 0.12, 0.12, 1))
ImGui.PushID("spell_" .. idx)
local _, clicked = ImGui.Selectable(clicky.spellName)
ImGui.PopStyleColor(2)
if ImGui.IsItemHovered() then
ImGui.BeginTooltip()
ImGui.Text("Spell ID: %s (click to inspect)", clicky.spell.ID())
ImGui.EndTooltip()
end
if clicked then
clicky.spell.Inspect()
end
ImGui.PopID()
else
ImGui.TextDisabled(clicky.spellName)
end
ImGui.TableNextColumn()
local targetLower = clicky.targetType:lower()
local color = defaultTargetColor
for _, entry in ipairs(targetColors) do
for _, value in ipairs(entry.values) do
if entry.type == "exact" and targetLower == value then
color = entry.color
break
elseif entry.type == "find" and targetLower:find(value) then
color = entry.color
break
end
end
if color ~= defaultTargetColor then
break
end
end
---@diagnostic disable-next-line: deprecated
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(unpack(color)))
ImGui.Text(clicky.targetType)
ImGui.PopStyleColor()
ImGui.TableNextColumn()
if clicky.castTime <= 0 then
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.4, 0.4, 0.4, 1))
ImGui.Text("-")
ImGui.PopStyleColor()
else
local seconds = clicky.castTime / 1000
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.85, 0.9, 1.0, 1))
if seconds >= 60 then
local mins = math.floor(seconds / 60)
local secs = math.floor(seconds) % 60
if secs == 0 then
ImGui.Text("%dm", mins)
else
ImGui.Text("%dm %ds", mins, secs)
end
else
ImGui.Text("%.1fs", seconds)
end
ImGui.PopStyleColor()
end
ImGui.TableNextColumn()
if clicky.recastDelay <= 0 then
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.4, 0.4, 0.4, 1))
ImGui.Text("-")
ImGui.PopStyleColor()
else
local seconds = clicky.recastDelay
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(1.0, 0.9, 0.7, 1))
if seconds >= 60 then
local mins = math.floor(seconds / 60)
local secs = math.floor(seconds) % 60
if secs == 0 then
ImGui.Text("%dm", mins)
else
ImGui.Text("%dm %ds", mins, secs)
end
else
ImGui.Text("%ds", seconds)
end
ImGui.PopStyleColor()
end
ImGui.TableNextColumn()
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.7, 1.0, 0.8, 1))
ImGui.Text("%d", clicky.recastType)
ImGui.PopStyleColor()
ImGui.TableNextColumn()
if clicky.requiredLevel <= 0 then
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.4, 0.4, 0.4, 1))
ImGui.Text("-")
elseif mq.TLO.Me.Level() >= clicky.requiredLevel then
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(0.4, 1.0, 0.4, 1))
ImGui.Text("%d", clicky.requiredLevel)
else
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.GetColorU32(1.0, 0.4, 0.4, 1))
ImGui.Text("%d", clicky.requiredLevel)
end
ImGui.PopStyleColor()
ImGui.TableNextColumn()
local locColor = clicky.location:find("^Bag") and locationColors.bag
or clicky.location:find("^Inv") and locationColors.inv
or locationColors.equipment
ImGui.TextColored(locColor, clicky.location)
end
ImGui.EndTable()
end
end
ImGui.End()
end
scanClickyItems()
mq.imgui.init('ClickyList', renderGUI)
while openGUI do
mq.delay(100)
end