-
Notifications
You must be signed in to change notification settings - Fork 18
/
SM_Super.lua
125 lines (111 loc) · 2.89 KB
/
SM_Super.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
-- hook API functions
local oldPickupMacro=PickupMacro;
local oldPickupContainerItem=PickupContainerItem;
local oldPickupInventoryItem=PickupInventoryItem;
local oldPickupSpell=PickupSpell;
local oldPickupAction=PickupAction;
local oldPlaceAction=PlaceAction;
local oldUseAction=UseAction;
local oldGetActionText=GetActionText;
local oldGetActionTexture=GetActionTexture;
function PickupMacro(macroid, supername)
if ( supername ) then
SM_CURSOR=supername;
local tempicon=SM_MACRO_ICON[GetSuperMacroInfo(supername,"texture")];
local macroname, macroicon=GetMacroInfo(1);
macroicon=SM_MACRO_ICON[macroicon];
EditMacro(1,macroname, tempicon);
oldPickupMacro(1);
EditMacro(1,macroname, macroicon);
else
SM_CURSOR=nil;
oldPickupMacro(macroid);
end
end
function PickupContainerItem(index, slot)
SM_CURSOR=nil;
oldPickupContainerItem(index, slot);
end
function PickupInventoryItem(index)
SM_CURSOR=nil;
oldPickupInventoryItem(index);
end
function PickupSpell(index, book)
SM_CURSOR=nil;
oldPickupSpell(index, book);
end
function PickupAction(id)
if ( SM_ACTION[id] ) then
SM_CURSOR=SM_ACTION[id];
local tempicon=SM_MACRO_ICON[GetSuperMacroInfo(SM_CURSOR,"texture")];
local macroname, macroicon=GetMacroInfo(1);
macroicon=SM_MACRO_ICON[macroicon];
EditMacro(1,macroname, tempicon);
SM_ACTION[id]=nil;
oldPickupAction(id);
EditMacro(1,macroname, macroicon);
else
SM_CURSOR=nil;
SM_ACTION[id]=nil;
oldPickupAction(id);
end
end
function PlaceAction(id)
-- place and pickup super
local cursor;
if ( SM_ACTION[id] ) then
cursor=SM_ACTION[id];
end
SM_ACTION[id]=SM_CURSOR;
SM_CURSOR=cursor;
oldPlaceAction(id);
end
function UseAction( id, click, selfcast)
lastActionUsed = id;
if ( SuperMacroFrame_SaveMacro and SuperMacroFrame:IsVisible() ) then
SuperMacroFrame_SaveMacro();
end
if ( SM_ACTION[id] ) then
RunSuperMacro(SM_ACTION[id]);
elseif ( GetActionText(id) ) then
RunMacro(GetActionText(id));
else
oldUseAction( id, click, selfcast );
end
end
function GetActionText(id)
if ( SM_ACTION[id] ) then
return SM_ACTION[id];
else
return oldGetActionText(id);
end
end
function GetActionTexture(id)
if ( SM_ACTION[id] ) then
local texture=GetSuperMacroInfo(SM_ACTION[id], "texture");
return texture;
else
return oldGetActionTexture(id);
end
end
function SuperMacro_UpdateAction(oldsuper, newsuper)
for k,v in SM_ACTION do
if v==oldsuper then
SM_ACTION[k]=newsuper;
end
end
end
function SetActionSuperMacro(actionid, supername)
if ( supername and actionid > 0 and actionid <= 120 ) then
PickupAction( actionid );
PickupMacro(1, supername );
PlaceAction ( actionid );
end
end
function SM_ActionButton_OnClick()
if ( SM_CURSOR ) then
PlaceAction(ActionButton_GetPagedID(this));
ActionButton_UpdateState();
return 1;
end
end