-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMoogleLib.lua
3298 lines (3082 loc) · 105 KB
/
MoogleLib.lua
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
MoogleLib = {
API = {},
Lua = {
Debug = {},
General = {},
IO = {},
Math = {},
OS = {},
String = {},
Table = {}
},
Gui = {},
RegisteredFunctions = {}
}
local self = MoogleLib
local selfs = "MoogleLib"
self.Info = {
Creator = "Kali",
Version = "1.4.0",
StartDate = "12/28/17",
ReleaseDate = "12/30/17",
LastUpdate = "01/04/18",
URL = "https://raw.githubusercontent.com/KaliMinion/Moogle-Stuff/master/MoogleLib.lua",
ChangeLog = {
["1.0.0"] = "Initial release",
["1.1.0"] = "Rework for self",
["1.1.1"] = "Teaks",
["1.1.2"] = "Download Overwrite Fix",
["1.1.7"] = "Download Overwrite Fix 6...",
["1.2.0"] = "File Delete Function",
["1.2.2"] = "New Functions",
["1.2.3"] = "Download Fixes...again",
["1.2.4"] = "Download Tweaks and new Functions",
["1.3.0"] = "Huge rework to fix locals and downloading",
["1.3.6"] = "Added Save Settings Function",
["1.4.0"] = "Complete rewrite."
}
}
local Info = self.Info
self.GUI = {}
self.Settings = {
enable = true,
MainMenuType = 2,
MainMenuEntryCreated = false,
}
local Settings = self.Settings
MoogleDebug, MoogleLog = {}, false
if not MoogleEvents then _G.MoogleEvents = {} end
-- Start Locals --
local API = MoogleLib.API
local Lua = MoogleLib.Lua
local Debug = Lua.Debug
local General = Lua.General
local IO = Lua.IO
local Math = Lua.Math
local OS = Lua.OS
local String = Lua.String
local Table = Lua.Table
local Gui = MoogleLib.Gui
API.MinionPath = GetStartupPath() local MinionPath = API.MinionPath
API.LuaPath = GetLuaModsPath() local LuaPath = API.LuaPath
API.MooglePath = LuaPath .. [[MoogleStuff Files\]] local MooglePath = API.MooglePath
API.MoogleSettings = MooglePath .. [[MoogleSettings.lua]] local MoogleSettings = API.MoogleSettings
API.ImageFolder = MooglePath .. [[Moogle Images\]] local ImageFolder = API.ImageFolder
API.ScriptsFolder = MooglePath .. [[Moogle Scripts\]] local ScriptsFolder = API.ScriptsFolder
API.TempFolder = MooglePath .. [[Temp\]] local TempFolder = API.TempFolder
API.ACRFolder = LuaPath .. [[ACR\CombatRoutines\]] local ACRFolder = API.ACRFolder
API.SenseProfiles = LuaPath .. [[Sense\profiles\]] local SenseProfiles = API.SenseProfiles
API.SenseTriggers = LuaPath .. [[Sense\triggers\]] local SenseTriggers = API.SenseTriggers
API.GitURL = function(ModuleFileName, Branch) Branch = Branch or "master" return [[https://github.com/KaliMinion/Moogle-Stuff/blob/]] .. Branch .. [[/]] .. ModuleFileName .. [[.lua]] end local GitURL = API.GitURL
local function sec(val,ms) val = val ms = ms or true if ms then return val*1000 else return val end end
local function min(val,ms) val = val*60 ms = ms or true if ms then return val*1000 else return val end end
local function hr(val,ms) val = val*3600 ms = ms or true if ms then return val*1000 else return val end end
local function day(val,ms) val = val*86400 ms = ms or true if ms then return val*1000 else return val end end
local function week(val,ms) val = val*604800 ms = ms or true if ms then return val*1000 else return val end end
local function month(val,days,ms)
if Type(days,"boolean") then ms = days; days = nil end
days = days or 30; ms = ms or true; local val2 = 0
if Type(days,"number") then val2 = day(days) else val2 = 2629744 end val = val * val2
if ms then return val*1000 else return val end
end
local function year(val,days,ms)
if Type(days,"boolean") then ms = days; days = nil end
days = days or 365.24219907408; ms = ms or true; local val2 = 0
if Type(days,"number") then val2 = day(days) else val2 = 31556926 end val = val * val2
if ms then return val*1000 else return val end
end
local Initialize, LoadModule, VersionCheck, LastPush, GitFileText, Vars, Distance2D, Distance3D, CurrentTarget, MovePlayer, SetTarget, ConvertCID, Entities, Entities2, EntitiesUpdateInterval, EntitiesLastUpdate, UpdateEntities, CMDKeyPress, SendKey, Keybinds, RecordKeybinds, ToasterTable, ToasterTime, Toaster, CSV2Table, Error, debug, IsNil, NotNil, Is, IsAll, Not, NotAll, Type, NotType, TimeSince, Size, Empty, NotEmpty, d2, DrawDebugInfo, DrawTree, AddTree, RemoveTree, Sign, Round, Convert4Bytes, PowerShell, CreateFolder, DeleteFile, WriteToFile, WipeFile, Queue, CMD, DownloadString, DownloadTable, DownloadFile, Ping, Split, starts, ends, ToTable, ProperCase, Proper, Case, Title, TitleCase, IsURL, Valid, NotValid, InsertIfNil, RemoveIfNil, UpdateIfChanged, RemoveExpired, Unpack, BannedKeys, Print, WindowStyle, WindowStyleClose, ColorConv, SameLine, Indent, Unindent, Space, Text, Checkbox, Image, Tooltip, GetRemaining, VirtualKeys, OrderedKeys, IndexToDecimal, HotKey, DrawTables, FinishedLoading
--local loaded = true
--local function VarInit(var,func)
-- if loaded then
-- if var == nil then
-- if func then
-- else
-- end
-- else
-- end
-- else
-- return nil, false
-- end
--end
local loaded = true
local function UpdateLocals4()
if loaded and VirtualKeys == nil then if Gui.VirtualKeys then VirtualKeys = Gui.VirtualKeys else loaded = false end end
if loaded and OrderedKeys == nil then if Gui.OrderedKeys then OrderedKeys = Gui.OrderedKeys else loaded = false end end
if loaded and IndexToDecimal == nil then if Gui.IndexToDecimal then IndexToDecimal = Gui.IndexToDecimal else loaded = false end end
if loaded and HotKey == nil then if Gui.HotKey then HotKey = Gui.HotKey else loaded = false end end
if loaded and DrawTables == nil then if Gui.DrawTables then DrawTables = Gui.DrawTables else loaded = false end end
if loaded and CSV2Table == nil then if API.CSV2Table then CSV2Table = API.CSV2Table else loaded = false end end
if loaded then FinishedLoading = true end
end
local function UpdateLocals3()
if loaded and ends == nil then if String.ends then ends = String.ends else loaded = false end end
if loaded and ToTable == nil then if String.ToTable then ToTable = String.ToTable else loaded = false end end
if loaded and ProperCase == nil then if String.ProperCase then ProperCase = String.ProperCase else loaded = false end end
if loaded and Proper == nil then if String.Proper then Proper = String.Proper else loaded = false end end
if loaded and Case == nil then if String.Case then Case = String.Case else loaded = false end end
if loaded and Title == nil then if String.Title then Title = String.Title else loaded = false end end
if loaded and TitleCase == nil then if String.TitleCase then TitleCase = String.TitleCase else loaded = false end end
if loaded and IsURL == nil then if String.IsURL then IsURL = String.IsURL else loaded = false end end
if loaded and Valid == nil then if Table.Valid then Valid = Table.Valid else loaded = false end end
if loaded and NotValid == nil then if Table.NotValid then NotValid = Table.NotValid else loaded = false end end
if loaded and InsertIfNil == nil then if Table.InsertIfNil then InsertIfNil = Table.InsertIfNil else loaded = false end end
if loaded and RemoveIfNil == nil then if Table.RemoveIfNil then RemoveIfNil = Table.RemoveIfNil else loaded = false end end
if loaded and UpdateIfChanged == nil then if Table.UpdateIfChanged then UpdateIfChanged = Table.UpdateIfChanged else loaded = false end end
if loaded and RemoveExpired == nil then if Table.RemoveExpired then RemoveExpired = Table.RemoveExpired else loaded = false end end
if loaded and Unpack == nil then if Table.Unpack then Unpack = Table.Unpack else loaded = false end end
if loaded and BannedKeys == nil then if Table.BannedKeys then BannedKeys = Table.BannedKeys else loaded = false end end
if loaded and Print == nil then if Table.Print then Print = Table.Print else loaded = false end end
if loaded and WindowStyle == nil then if Gui.WindowStyle then WindowStyle = Gui.WindowStyle else loaded = false end end
if loaded and WindowStyleClose == nil then if Gui.WindowStyleClose then WindowStyleClose = Gui.WindowStyleClose else loaded = false end end
if loaded and ColorConv == nil then if Gui.ColorConv then ColorConv = Gui.ColorConv else loaded = false end end
if loaded and SameLine == nil then if Gui.SameLine then SameLine = Gui.SameLine else loaded = false end end
if loaded and Indent == nil then if Gui.Indent then Indent = Gui.Indent else loaded = false end end
if loaded and Unindent == nil then if Gui.Unindent then Unindent = Gui.Unindent else loaded = false end end
if loaded and Space == nil then if Gui.Space then Space = Gui.Space else loaded = false end end
if loaded and Text == nil then if Gui.Text then Text = Gui.Text else loaded = false end end
if loaded and Checkbox == nil then if Gui.Checkbox then Checkbox = Gui.Checkbox else loaded = false end end
if loaded and Image == nil then if Gui.Image then Image = Gui.Image else loaded = false end end
if loaded and Tooltip == nil then if Gui.Tooltip then Tooltip = Gui.Tooltip else loaded = false end end
if loaded and GetRemaining == nil then if Gui.GetRemaining then GetRemaining = Gui.GetRemaining else loaded = false end end
if loaded then UpdateLocals4() end
end
local loaded = true
local function UpdateLocals2()
if loaded and IsAll == nil then if General.IsAll then IsAll = General.IsAll else loaded = false end end
if loaded and Not == nil then if General.Not then Not = General.Not else loaded = false end end
if loaded and NotAll == nil then if General.NotAll then NotAll = General.NotAll else loaded = false end end
if loaded and Type == nil then if General.Type then Type = General.Type else loaded = false end end
if loaded and NotType == nil then if General.NotType then NotType = General.NotType else loaded = false end end
if loaded and TimeSince == nil then if General.TimeSince then TimeSince = General.TimeSince else loaded = false end end
if loaded and Size == nil then if General.Size then Size = General.Size else loaded = false end end
if loaded and Empty == nil then if General.Empty then Empty = General.Empty else loaded = false end end
if loaded and NotEmpty == nil then if General.NotEmpty then NotEmpty = General.NotEmpty else loaded = false end end
if loaded and d2 == nil then if Debug.d2 then d2 = Debug.d2 else loaded = false end end
if loaded and DrawDebugInfo == nil then if Debug.DrawDebugInfo then DrawDebugInfo = Debug.DrawDebugInfo else loaded = false end end
if loaded and DrawTree == nil then if Debug.DrawTree then DrawTree = Debug.DrawTree else loaded = false end end
if loaded and AddTree == nil then if Debug.AddTree then AddTree = Debug.AddTree else loaded = false end end
if loaded and RemoveTree == nil then if Debug.RemoveTree then RemoveTree = Debug.RemoveTree else loaded = false end end
if loaded and Sign == nil then if Math.Sign then Sign = Math.Sign else loaded = false end end
if loaded and Round == nil then if Math.Round then Round = Math.Round else loaded = false end end
if loaded and Convert4Bytes == nil then if Math.Convert4Bytes then Convert4Bytes = Math.Convert4Bytes else loaded = false end end
if loaded and PowerShell == nil then if OS.PowerShell then PowerShell = OS.PowerShell else loaded = false end end
if loaded and CreateFolder == nil then if OS.CreateFolder then CreateFolder = OS.CreateFolder else loaded = false end end
if loaded and DeleteFile == nil then if OS.DeleteFile then DeleteFile = OS.DeleteFile else loaded = false end end
if loaded and WriteToFile == nil then if OS.WriteToFile then WriteToFile = OS.WriteToFile else loaded = false end end
if loaded and WipeFile == nil then if OS.WipeFile then WipeFile = OS.WipeFile else loaded = false end end
if loaded and Queue == nil then if OS.Queue then Queue = OS.Queue else loaded = false end end
if loaded and CMD == nil then if OS.CMD then CMD = OS.CMD else loaded = false end end
if loaded and DownloadString == nil then if OS.DownloadString then DownloadString = OS.DownloadString else loaded = false end end
if loaded and DownloadFile == nil then if OS.DownloadFile then DownloadFile = OS.DownloadFile else loaded = false end end
if loaded and Ping == nil then if OS.Ping then Ping = OS.Ping else loaded = false end end
if loaded and Split == nil then if String.Split then Split = String.Split else loaded = false end end
if loaded and starts == nil then if String.starts then starts = String.starts else loaded = false end end
if loaded then UpdateLocals3() end
end
local loaded = true
local function UpdateLocals()
if loaded and Initialize == nil then if API.Initialize then Initialize = API.Initialize else loaded = false end end
if loaded and LoadModule == nil then if API.LoadModule then LoadModule = API.LoadModule else loaded = false end end
if loaded and VersionCheck == nil then if API.VersionCheck then VersionCheck = API.VersionCheck else loaded = false end end
if loaded and LastPush == nil then if API.LastPush then LastPush = API.LastPush else loaded = false end end
if loaded and GitFileText == nil then if API.GitFileText then GitFileText = API.GitFileText else loaded = false end end
if loaded and Vars == nil then if API.Vars then Vars = API.Vars else loaded = false end end
if loaded and Distance2D == nil then if API.Distance2D then Distance2D = API.Distance2D else loaded = false end end
if loaded and Distance3D == nil then if API.Distance3D then Distance3D = API.Distance3D else loaded = false end end
if loaded and CurrentTarget == nil then if API.CurrentTarget then CurrentTarget = API.CurrentTarget else loaded = false end end
if loaded and MovePlayer == nil then if API.MovePlayer then MovePlayer = API.MovePlayer else loaded = false end end
if loaded and SetTarget == nil then if API.SetTarget then SetTarget = API.SetTarget else loaded = false end end
if loaded and ConvertCID == nil then if API.ConvertCID then ConvertCID = API.ConvertCID else loaded = false end end
if loaded and Entities == nil then if API.Entities then Entities = API.Entities else loaded = false end end
if loaded and Entities2 == nil then if API.Entities2 then Entities2 = API.Entities2 else loaded = false end end
if loaded and EntitiesUpdateInterval == nil then if API.EntitiesUpdateInterval then EntitiesUpdateInterval = API.EntitiesUpdateInterval else loaded = false end end
if loaded and EntitiesLastUpdate == nil then if API.EntitiesLastUpdate then EntitiesLastUpdate = API.EntitiesLastUpdate else loaded = false end end
if loaded and UpdateEntities == nil then if API.UpdateEntities then UpdateEntities = API.UpdateEntities else loaded = false end end
if loaded and CMDKeyPress == nil then if API.CMDKeyPress then CMDKeyPress = API.CMDKeyPress else loaded = false end end
if loaded and SendKey == nil then if API.SendKey then SendKey = API.SendKey else loaded = false end end
if loaded and Keybinds == nil then if API.Keybinds then Keybinds = API.Keybinds else loaded = false end end
if loaded and RecordKeybinds == nil then if API.RecordKeybinds then RecordKeybinds = API.RecordKeybinds else loaded = false end end
if loaded and ToasterTable == nil then if API.ToasterTable then ToasterTable = API.ToasterTable else loaded = false end end
if loaded and ToasterTime == nil then if API.ToasterTime then ToasterTime = API.ToasterTime else loaded = false end end
if loaded and Toaster == nil then if API.Toaster then Toaster = API.Toaster else loaded = false end end
if loaded and Error == nil then if General.Error then Error = General.Error else loaded = false end end
if loaded and debug == nil then if General.Debug then debug = General.Debug else loaded = false end end
if loaded and IsNil == nil then if General.IsNil then IsNil = General.IsNil else loaded = false end end
if loaded and NotNil == nil then if General.NotNil then NotNil = General.NotNil else loaded = false end end
if loaded and Is == nil then if General.Is then Is = General.Is else loaded = false end end
if loaded then UpdateLocals2() end
end
-- End Locals --
------------------------------------------------------------------------------------------------------------------------
function API.Initialize(ModuleTable)
if ModuleTable and ModuleTable.name then
local MenuType = Settings.MainMenuType
local MainIcon = ImageFolder .. [[MoogleStuff.png]]
local ModuleIcon = ImageFolder .. ModuleTable.name .. [[.png]]
-- Create the Main Menu entry if it hasn't been created yet --
if not Settings.MainMenuEntryCreated then
local ImGUIIcon = GetStartupPath() .. "\\GUI\\UI_Textures\\ImGUI.png"
local MetricsIcon = GetStartupPath() .. "\\GUI\\UI_Textures\\Metrics.png"
local ImGUIToolTip = "ImGUI Demo is an overview of what's possible with the UI."
local MetricsToolTip = "ImGUI Metrics shows every window's rendering information, visible or hidden."
if MenuType == 1 then
-- No Main Menu Entry --
-- Adding the ImGUI Test Window as a Minion Menu entry
ml_gui.ui_mgr:AddMember({ id = "ImGUIDemo", name = "ImGUI Demo", onClick = function() ml_gui.showtestwindow = true end, tooltip = ImGUIToolTip, texture = ImGUIIcon }, "FFXIVMINION##MENU_HEADER")
-- Adding the ImGUI Test Window as a Minion Menu entry
ml_gui.ui_mgr:AddMember({ id = "ImGUIMetrics", name = "ImGUIMetrics", onClick = function() ml_gui.showmetricswindow = true end, tooltip = MetricsToolTip, texture = MetricsIcon }, "FFXIVMINION##MENU_HEADER")
elseif MenuType == 2 then
-- Expansion Submenu inside of Main Menu --
ml_gui.ui_mgr:AddMember({ id = [[MOOGLESTUFF##MENU_HEADER]], name = "MoogleStuff", texture = MainIcon }, "FFXIVMINION##MENU_HEADER")
-- Adding the ImGUI Test Window as a Minion Menu entry
ml_gui.ui_mgr:AddSubMember({ id = "ImGUIDemo", name = "ImGUI Demo", onClick = function() ml_gui.showtestwindow = not ml_gui.showtestwindow end, tooltip = ImGUIToolTip, texture = ImGUIIcon }, "FFXIVMINION##MENU_HEADER", "MOOGLESTUFF##MENU_HEADER")
-- Adding the ImGUI Test Window as a Minion Menu entry
ml_gui.ui_mgr:AddSubMember({ id = "ImGUIMetrics", name = "ImGUIMetrics", onClick = function() ml_gui.showmetricswindow = not ml_gui.showmetricswindow end, tooltip = MetricsToolTip, texture = MetricsIcon }, "FFXIVMINION##MENU_HEADER", "MOOGLESTUFF##MENU_HEADER")
elseif MenuType == 3 then
-- New Component Header that branches off to the right --
ml_gui.ui_mgr:AddComponent({ header = { id = [[MOOGLESTUFF##MENU_HEADER]], expanded = false, name = "MoogleStuff", texture = MainIcon }, members = {} })
-- Adding the ImGUI Test Window as a Minion Menu entry
ml_gui.ui_mgr:AddMember({ id = "ImGUIDemo", name = "ImGUI Demo", onClick = function() ml_gui.showtestwindow = true end, tooltip = ImGUIToolTip, texture = ImGUIIcon }, "MOOGLESTUFF##MENU_HEADER")
-- Adding the ImGUI Test Window as a Minion Menu entry
ml_gui.ui_mgr:AddMember({ id = "ImGUIMetrics", name = "ImGUIMetrics", onClick = function() ml_gui.showmetricswindow = true end, tooltip = MetricsToolTip, texture = MetricsIcon }, "MOOGLESTUFF##MENU_HEADER")
end
Settings.MainMenuEntryCreated = true
end
-- Creating Module Entry --
if MenuType == 1 then
ml_gui.ui_mgr:AddMember({ id = ModuleTable.WindowName, name = ModuleTable.name, onClick = function() ModuleTable.OnClick() end, tooltip = ModuleTable.ToolTip, texture = ModuleIcon }, "FFXIVMINION##MENU_HEADER")
elseif MenuType == 2 then
ml_gui.ui_mgr:AddSubMember({ id = ModuleTable.WindowName, name = ModuleTable.name, onClick = function() ModuleTable.OnClick() end, tooltip = ModuleTable.ToolTip, texture = ModuleIcon }, "FFXIVMINION##MENU_HEADER", "MOOGLESTUFF##MENU_HEADER")
elseif MenuType == 3 then
ml_gui.ui_mgr:AddMember({ id = ModuleTable.WindowName, name = ModuleTable.name, onClick = function() ModuleTable.OnClick() end, tooltip = ModuleTable.ToolTip, texture = ModuleIcon }, "MOOGLESTUFF##MENU_HEADER")
end
-- Mini Button --
if ModuleTable.MiniButton then
local MiniNameStr = ModuleTable.MiniName or ModuleTable.name
table.insert(ml_global_information.menu.windows, { name = MiniNameStr, openWindow = function() ModuleTable.OnClick() end, isOpen = function() return ModuleTable.IsOpen() end })
end
return Settings.MainMenuEntryCreated
end
end
function API.Event(event,module,name,func)
if func then
if not MoogleEvents[module.." - "..event.." - "..name] then
local function run()
func()
end
RegisterEventHandler(event,run)
MoogleEvents[module.." - "..event.." - "..name] = true
end
end
end
local LocalsStr
function API.LoadModule(filepath)
AddTree("MoogleLib.API","Load Module",true)
AddTree("MoogleLib.API.Load Module",filepath:gsub("%.","_"),true)
if fileexist(filepath) then
AddTree("MoogleLib.API.Load Module."..filepath:gsub("%.","_"),"Valid Result",true)
local str,start,line = "",false,""
if IsNil(LocalsStr) then
local Lib = io.open(MooglePath..[[MoogleLib.lua]],"r")
repeat line = Lib:read("*l")
if line == "-- Start Locals --" then start = true end
if start then
str = str..line.."\r\n"
end
until line:match([[-- End Locals --]]) Lib:close()
if start then
LocalsStr = str
end
else
str = LocalsStr
end
local file = io.open(filepath,"r")
repeat line = file:read("*l") str = str..line.."\r\n" until line:match([[-- End of File --]]) file:close()
loadstring(str)()
local filename = filepath:match("[^\\]+$"):gsub("%..+$","") if filename then d("MoogleLib: Loading "..filename) end
end
end
function API.VersionCheck(name, url, version)
AddTree("MoogleLib.API","Version Check",true)
AddTree("MoogleLib.API.Version Check",name,true)
url = url or GitURL(name)
local result, localversion = GitFileText(url), nil
if Type(_G[name],"table") then localversion = _G[name].Info.Version end
if Type(result,"string") and #result > 3 then
AddTree("MoogleLib.API.Version Check."..name,"Valid Result",true)
local str
for s in result:gmatch("[^\r\n]+") do
if IsNil(str) and s:match([[.*Version = "([^"]+)]]) then
str = s:gsub("[^%d\.]", "")
end
end
if str then
if version and localversion then
local str2 = version:gsub("[^%d\.]", "")
local str3 = localversion:gsub("[^%d\.]", "")
local tbl = str:totable("%p")
local tbl2 = str2:totable("%p")
local tbl3 = str3:totable("%p")
local update = false
if (tbl[1] > tbl2[1]) then update = true
elseif tbl[1] == tbl2[1] and (tbl[2] > tbl2[2]) then update = true
elseif tbl[1] == tbl2[1] and tbl[2] == tbl2[2] and (tbl[3] > tbl2[3]) then update = true
elseif (tbl[1] > tbl3[1]) then update = true
elseif tbl[1] == tbl3[1] and (tbl[2] > tbl3[2]) then update = true
elseif tbl[1] == tbl3[1] and tbl[2] == tbl3[2] and (tbl[3] > tbl3[3]) then update = true
end
if update then
AddTree("MoogleLib.API.Version Check."..name..".Valid Result","Update Available",true)
else
AddTree("MoogleLib.API.Version Check."..name..".Valid Result","No Update Available",true)
end
return update, str, result
elseif localversion then
local str2 = localversion:gsub("[^%d\.]", "")
local tbl = str:totable("%p")
local tbl2 = str2:totable("%p")
local update = false
if (tbl[1] > tbl2[1]) then update = true
elseif tbl[1] == tbl2[1] and (tbl[2] > tbl2[2]) then update = true
elseif tbl[1] == tbl2[1] and tbl[2] == tbl2[2] and (tbl[3] > tbl2[3]) then update = true
end
if update then
AddTree("MoogleLib.API.Version Check."..name..".Valid Result","Update Available",true)
else
AddTree("MoogleLib.API.Version Check."..name..".Valid Result","No Update Available",true)
end
return update, str, result
else
return false, str, result
end
else
return false, str, result
end
end
end
function API.LastPush(GitFile, date)
AddTree("MoogleLib.API","LastPush",true)
AddTree("MoogleLib.API.LastPush",tostring(GitFile:gsub("%.lua",""):gsub("%/"," - ")),true)
local tbl = {}
local url = [[https://github.com/KaliMinion/Moogle-Stuff/commits/master/]]..GitFile
-- d("Last Push URL: "..url)
local result = OS.CMD([[PowerShell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $content = (New-Object System.Net.WebClient).DownloadString(']]..url..[['); $HTML = New-Object -Com 'HTMLFile'; $src = [System.Text.Encoding]::Unicode.GetBytes($content); $HTML.write($src); $result = (@($HTML.body.getElementsByTagName('relative-time'))[0].outerHTML).split('\"')[1]; $result >> "outputfile""]])
if result then
result = result:gsub("\n","")
AddTree("MoogleLib.API.LastPush."..tostring(GitFile:gsub("%.lua",""):gsub("%/"," - ")),"Valid Result",true)
for s in result:gmatch("[%d]+") do
tbl[#tbl+1] = s
end
if #tbl == 6 then
if date then
return os.date ("%x %X", os.time{ year = tbl[1], month = tbl[2], day = tbl[3], hour = tbl[4], min = tbl[5], sec = tbl[6]} - 21600)
else
return os.time{ year = tbl[1], month = tbl[2], day = tbl[3], hour = tbl[4], min = tbl[5], sec = tbl[6]} - 21600
end
end
end
end
function API.GitFileText(GitFile)
AddTree("MoogleLib.API","GitFile Text",true)
AddTree("MoogleLib.API.GitFile Text", GitFile,true)
local url; if IsURL(GitFile) then url = GitFile else url = [[https://github.com/KaliMinion/Moogle-Stuff/blob/master/]]..GitFile..[[.lua]] end
return OS.CMD([[PowerShell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $content = (New-Object System.Net.WebClient).DownloadString(']]..url..[['); $HTML = New-Object -Com 'HTMLFile'; $src = [System.Text.Encoding]::Unicode.GetBytes($content); $HTML.write($src); @($HTML.body.getElementsByTagName('table'))[0].innerText | Set-Content -Path 'outputfile'"]])
end
local init = true
MoogleInput = false
API.InputTable = {}
function API.Input(event, message, wParam, lParam)
if table.size(API.InputTable) ~= 0 then API.InputTable = {} end
if ml_input_mgr.InputHandler and init then
ml_input_mgr.InputHandler = function(event, message, wParam, lParam)
-- d(tostring(message).." "..tostring(wParam).." "..tostring(lParam)) -- all string values received.
if (string.valid(message) and string.valid(wParam) and string.valid(lParam)) then
API.InputTable.message = message
API.InputTable.wParam = wParam
API.InputTable.lParam = lParam
if MoogleInput then
table.print(API.InputTable)
end
-- Mouse Wheel --
-- if (message == "522") then
-- scrolling zoom for btree, keep this for minion function
-- BehaviorManager:ChangeZoom(tonumber(lParam))
-- Error(tonumber(lParam)/120)
-- end
end
end
init = false
-- Unable to use my event function due to issues --
if MoogleLib["MoogleLib - Gameloop.Input - Input"] == nil then
RegisterEventHandler("Gameloop.Input", ml_input_mgr.InputHandler)
MoogleLib["MoogleLib - Gameloop.Input - Input"] = true
end
end
end
function API.MouseWheel()
if API.InputTable.message == "522" then
local power = tonumber(API.InputTable.lParam) / 120
Error("Mouse Wheel Power: "..power)
return power
end
end
-- Example Usage --
--local wheel = API.MouseWheel()
--if wheel then
-- local state = ""; if wheel > 0 then state = "Up" else state = "Down" end
-- local add = string.rep("!", math.abs(wheel))
-- Error("Scrolling "..state..add)
--end
MoogleSettingsTable = FileLoad(MoogleSettings) or {}
function API.Vars(Tbl, load)
for k, v in pairs(Tbl) do
local SettingsTable = MoogleSettingsTable
local savevar = ""
local ModuleTable = _G
local t = {}
local t2 = {}
for w in tostring(k):gmatch("[%P/_/:]+") do
t[#t + 1] = w
end
for w in tostring(v):gmatch("[%P/_/:]+") do
t2[#t2 + 1] = w
end
for i, e in pairs(t) do
if i < #t then
if type(SettingsTable[e]) == "table" then
SettingsTable = SettingsTable[e]
else
SettingsTable[e] = {}
SettingsTable = SettingsTable[e]
end
else
savevar = e
end
end
for i, e in pairs(t2) do
if i < #t2 then
if ModuleTable[e] ~= nil then
ModuleTable = ModuleTable[e]
else
return
end
else
if load then
if type(SettingsTable[savevar]) ~= nil and SettingsTable[savevar] ~= ModuleTable[e] then
ModuleTable[e] = SettingsTable[savevar] or ModuleTable[e]
end
else
if type(SettingsTable[savevar]) == nil or SettingsTable[savevar] ~= ModuleTable[e] then
SettingsTable[savevar] = ModuleTable[e]
FileSave(MoogleSettings,MoogleSettingsTable)
end
end
end
end
end
end
MoogleSave = API.Vars
function MoogleLoad(tbl)
API.Vars(tbl, true)
end
API.ImageList, API.FinishedImages, API.ImageLastCheck = {},{},0
function API.DownloadImages(image,path)
if FinishedLoading then
if image == nil then
if TimeSince(API.ImageLastCheck,min(1)) then
AddTree("MoogleLib.API","Download Image",true)
AddTree("MoogleLib.API.Download Image","Automated Check",true)
path = path or ImageFolder
API.ImageCMD = io.popen([[PowerShell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $path = ']]..path..[['; mkdir -Force $path | Out-Null; (Invoke-WebRequest -Uri 'https://github.com/KaliMinion/Moogle-Stuff/tree/master/Moogle%20Images').Links | Where-Object -Property class -EQ -Value 'js-navigation-open' | Select-Object -Skip 1 | ForEach-Object{$url = 'https://github.com' + ($_.href -replace 'blob/', 'raw/'); if(![System.IO.File]::Exists($path+$_.title)){try{Invoke-WebRequest $url -OutFile ($path+$_.title)} catch { $_.Exception.Response }}}"]])
API.ImageLastCheck = Now()
end
else
AddTree("MoogleLib.API","Download Image",true)
AddTree("MoogleLib.API.Download Image",image,true)
path = path or ImageFolder
end
end
end
API.Event("Gameloop.Update",selfs,"DownloadImages",API.DownloadImages)
function API.Distance2D(table1, table2)
if table2 == nil then
table2 = table1
table1 = Player
end
if table.valid(table1) and table.valid(table2) then
return (math.sqrt(math.pow((table2.pos.x - table1.pos.x), 2) + math.pow((table2.pos.z - table1.pos.z), 2))) - (table1.hitradius + table2.hitradius)
end
end
function API.Distance3D(table1, table2)
if IsNil(table1.pos) then
table1 = { ["pos"] = table1 }
table1["hitradius"] = Player.hitradius
end
if IsNil(table2) then
table2 = Player
elseif IsNil(table2.pos) then
table2 = { ["pos"] = table2 }
table2["hitradius"] = Player.hitradius
end
if table.valid(table1) and table.valid(table2) then
return (math.sqrt(math.pow((table2.pos.x - table1.pos.x), 2) + math.pow((table2.pos.z - table1.pos.z), 2) + math.pow((table2.pos.y - table1.pos.y), 2))) - (table1.hitradius + table2.hitradius)
end
end
function API.CurrentTarget(check)
local target = Player:GetTarget()
if NotNil(target) then
if IsNil(check) then
return true
else
local t = {};
local changed = false
for w in check:gmatch("[%P/_/:]+") do
t[#t + 1] = w
end
if table.size(t) == 1 then
if t[1] == "table" then
return target
elseif In(t[1], "2D", "Distance2D") then
return Distance2D(Player, target)
elseif In(t[1], "3D", "Distance3D") then
return Distance3D(Player, target)
else
return target[t[1]]
end
else
local ctarget = target
for k, v in pairs(t) do
ctarget = ctarget[v]
end
return ctarget
end
end
else
return false
end
end
local CanTeleport, TeleportTime = true, 0
function API.MovePlayer(pos, map, stopdist)
local map = map or Player.localmapid
local ppos = Player.pos
local pmap = Player.localmapid
local stopdist = stopdist or 3
if pmap == map then
CanTeleport = true
if Distance3D(pos) <= stopdist then
if MIsMoving() then Player:Stop() end
return true
else
if not MIsLoading() and not MIsMoving() and NotValid(ml_navigation.path) then
Player:MoveTo(pos.x, pos.y, pos.z, stopdist, true, true)
end
if MIsMoving() then
local Sprint = ActionList:Get(1, 3)
if Sprint and Valid(ml_navigation.path) and Sprint.usable and Sprint:IsReady() then
Sprint:Cast()
end
end
end
elseif CanTeleport then
if MIsMoving() then Player:Stop() end
if not MIsLoading() and not MIsCasting() and NotAll(Player.action, 92, 93, 164) then
Player:Teleport(GetAetheryteByMapID(map, pos).id)
CanTeleport = false
TeleportTime = Now()
end
elseif TimeSince(TeleportTime,5000) then
CanTeleport = true
end
return false
end
local LastInteract = 0
function API.SetTarget(targetid, act)
local target = Player:GetTarget()
local entity = EntityList:Get(id)
if Type(targetid, "table") then
targetid = targetid.id
end
if not target or target.id ~= targetid then
Player:SetTarget(targetid)
if act and TimeSince(LastInteract,500) then
Player:Interact(targetid)
LastInteract = Now()
end
return true
elseif target and target.id == targetid then
return true
end
return false
end
function API.ConvertCID(CID, returntable)
local el = EntityList("contentid=" .. tostring(CID))
if table.valid(el) then
for k, v in pairs(el) do
if returntable then
return v
else
return v.id
end
end
end
end
API.Entities, API.Entities2, API.EntitiesUpdateInterval, API.EntitiesLastUpdate = {}, {}, 250, 0
function API.UpdateEntities()
if Text and TimeSince(API.EntitiesLastUpdate, API.EntitiesUpdateInterval) then
API.EntitiesLastUpdate = Now()
API.Entities = EntityList("")
if Valid(API.Entities) then
table.insert(API.Entities, Player)
for k, v in pairs(API.Entities) do
InsertIfNil(API.Entities2, "zone", Player.localmapid)
if API.Entities2.zone ~= Player.localmapid then
API.Entities2 = {}
API.Entities2.zone = Player.localmapid
end
InsertIfNil(API.Entities2, v.id, {})
InsertIfNil(API.Entities2[v.id], "name", v.name)
if v.incombat then
InsertIfNil(API.Entities2[v.id], "combatstart", Now())
InsertIfNil(API.Entities2[v.id], "starthp", v.hp.current)
if API.Entities2[v.id].percent then
if API.Entities2[v.id].percent < 75 and v.hp.percent > 75 then
API.Entities2[v.id].combatstart = Now()
API.Entities2[v.id].starthp = v.hp.current
API.Entities2[v.id].combattime = nil
API.Entities2[v.id].dps = nil
API.Entities2[v.id].ttd = nil
end
end
UpdateIfChanged(API.Entities2[v.id], "percent", (v.hp.current / v.hp.max) * 100)
if API.Entities2[v.id].combatstart then
API.Entities2[v.id].combattime = TimeSince(API.Entities2[v.id].combatstart) / 1000
API.Entities2[v.id].dps = (API.Entities2[v.id].starthp - v.hp.current) / API.Entities2[v.id].combattime
if API.Entities2[v.id].dps > 0 then
API.Entities2[v.id].ttd = v.hp.current / API.Entities2[v.id].dps
end
end
else
API.Entities2[v.id].combatstart = nil
API.Entities2[v.id].starthp = nil
API.Entities2[v.id].percent = nil
API.Entities2[v.id].combattime = nil
API.Entities2[v.id].dps = nil
API.Entities2[v.id].ttd = nil
end
if Valid(v.buffs) then
end
end
end
end
end
API.CMDKeyPress = ""
local CMDKeyPress = API.CMDKeyPress
function API.SendKey(key)
local SendKeyPress = ScriptsFolder .. [[SendKeyPress.exe]]
if not FileExists(SendKeyPress) then
FileWrite(SendKeyPress, [[ControlSend, , %1%, FINAL FANTASY XIV ]])
end
if Type(key, "string") then
CMDKeyPress = io.popen([["]] .. SendKeyPress .. [[" {]] .. key .. [[}]])
else
Error("API.SendKey `key` was not a valid string")
end
end
SendKey = API.SendKey
API.Keybinds = {
Movement = {},
Targeting = {},
Shortcuts = {},
Chat = {},
System = {},
Hotbar = {},
Gamepad = {}
}
local SendOpen = true
local Keybinds = API.Keybinds
function API.RecordKeybinds()
if IsControlOpen("ConfigKeybind") then
SendOpen = true
local data = GetControl("ConfigKeybind"):GetRawData()
if data then
local TabCount = {
Movement = 32,
Targeting = 50,
Shortcuts = 61,
Chat = 41,
System = 42,
Hotbar = 133,
Gamepad = 24
}
local page = 1
for k, v in table.pairsbykeys(TabCount) do
GetControl("ConfigKeybind"):PushButton(24, page)
for i = 10, v * 4, 4 do
if GetControl("ConfigKeybind"):GetRawData()[i] and GetControl("ConfigKeybind"):GetRawData()[i + 2] and GetControl("ConfigKeybind"):GetRawData()[i + 3] then
d(GetControl("ConfigKeybind"):GetRawData()[i].value)
API.Keybinds[k][tostring(GetControl("ConfigKeybind"):GetRawData()[i].value)] = GetControl("ConfigKeybind"):GetRawData()[i + 2].value
API.Keybinds[k][tostring(GetControl("ConfigKeybind"):GetRawData()[i].value) .. "2"] = GetControl("ConfigKeybind"):GetRawData()[i + 3].value
end
end
page = page + 1
end
FileSave(MooglePath .. "keybinds.lua", API.Keybinds)
end
elseif SendOpen then
ActionList:Get(10, 20):Cast()
SendOpen = false
end
end
function MoogleTime()
GUI:SetClipboardText(os.time())
end
API.ToasterTable = {}
API.ToasterTime = 5000
local lastsize, lasttime = 0, 0
function API.Toaster(Title, Text, Time)
local tbl = API.ToasterTable
Time = Time or API.ToasterTime
if NotNil(Title, Text, Time) then
tbl[#tbl + 1] = {
title = Title,
text = Text,
time = Time,
start = Now()
}
end
if table.valid(API.ToasterTime) then
GUI:Begin("ToasterWindow" .. tostring())
end
end
function API.CSV2Table(filepath)
AddTree("MoogleLib.API","CSV2Table",true)
AddTree("MoogleLib.API.CSV2Table",filepath:gsub("%.","_"),true)
if fileexist(filepath) then
AddTree("MoogleLib.API.CSV2Table."..filepath:gsub("%.","_"),"Valid Result",true)
local file = {}
for line in io.lines(filepath) do
local key = #file+1
file[key] = {}
local k = 1
for w in line:gmatch("[^,]+") do
file[key][k] = w
k = k + 1
end
end
return file
end
end
-- End API Functions --
-- General Functions --
function General.Error(string)
ml_error(string)
end
function General.Debug(string,level)
if MoogleLog then
level = level or 1
ml_debug("[MoogleLib]: "..string, "MoogleLog", level)
end
end
function General.IsNil(...)
local tbl = { ... }
if #tbl > 0 then
for i = 1, #tbl do
local x = tbl[i]
if x == nil or x == "" then
return true
end
end
else
return true
end
return false
-- -- First check if "check" is nil --
-- local x = check or "isnil"
-- if x == "isnil" then
-- -- "check" was nil, now return true or alternate value --
-- if check ~= "" then
-- return alt or true
-- else
-- return original or false
-- end
-- else
-- -- "check" was not nil, return false or return original if not nil --
-- return original or false
-- end
end
function General.NotNil(...)
local tbl = { ... }
if #tbl > 0 then
for i = 1, #tbl do
local x = tbl[i]
if x == nil or x == "" then
return false
end
end
else
return false
end
return true
-- -- First check that "check" is nil --
-- local x = check or "isnil"
-- if x == "isnil" then
-- return false
-- else
-- -- Isn't Nil, return alt if provided otherwise return true --
-- if check ~= "" then
-- return alt or true
-- else
-- return false
-- end
-- end
end
function General.Is(check, ...)
if check == nil then return false end
local compare = { ... }
if Valid(compare) then
for i = 1, #compare do
if (check == compare[i] or (tonumber(check) ~= nil and tonumber(check) == tonumber(compare[i]))) then
return true
end
end
return false
else
if Type(check, "boolean") then
if check == true then
return true
else
return false
end
else
return false
end
end
end
function General.IsAll(check, ...)
local compare = { ... }
if Valid(compare) then
local IsAllTrue = true
for i = 1, #compare do
if IsAllTrue then
if (check ~= compare[i] or (tonumber(check) ~= nil and tonumber(check) ~= tonumber(compare[i]))) then
return false
end
end
end
if IsAllTrue then
return true
else
return false
end
else
if Type(check, "boolean") then
if check == true then
return true
else
return false
end
else
return false
end
end
end
function General.Is2(check, compare, altyes, altno)
if Valid(compare) then
if (check == compare or (tonumber(check) ~= nil and tonumber(check) == tonumber(compare))) then
return altyes or true
else
return altno or false
end
else
if Type(check, "boolean") then
return check
else
return false
end
end
end
function General.Not(check, ...)
local compare = { ... }
if Valid(compare) then
for i = 1, #compare do
if (check ~= compare[i] or (tonumber(check) ~= nil and tonumber(check) ~= tonumber(compare[i]))) then
return true
end
end
return false
else
if Type(check, "boolean") then
return not check
else
return false
end