vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local simpleSelfCastOriginalUseAction; |
2 | local splashString = "Simple Self Cast by Zugreg.\nUse |cffffff00/ssc help|r to display a command list."; |
||
3 | local helpString = "/ssc - Toggles self casting.\n/ssc help - Displays this message.\n/ssc enable - Enables self casting.\n/ssc disable - Disables self casting.\n/ssc nosplash - Prevents the splash message from being displayed.\n/ssc splash - Displays the splash message at each startup."; |
||
4 | |||
5 | function SimpleSelfCast_OnLoad() |
||
6 | this:RegisterEvent("VARIABLES_LOADED"); |
||
7 | end |
||
8 | |||
9 | function SimpleSelfCast_OnEvent(event) |
||
10 | if event == "VARIABLES_LOADED" then |
||
11 | SlashCmdList["SIMPLESELFCAST"] = SimpleSelfCast_Command; |
||
12 | SLASH_SIMPLESELFCAST1 = "/ssc"; |
||
13 | SLASH_SIMPLESELFCAST2 = "/simpleselfcast"; |
||
14 | if simpleSelfCastActive == nil then |
||
15 | simpleSelfCastActive = true; |
||
16 | end |
||
17 | if simpleSelfCastSplash == nil then |
||
18 | simpleSelfCastSplash = true; |
||
19 | end |
||
20 | if simpleSelfCastSplash then |
||
21 | SSCPrint(splashString); |
||
22 | end |
||
23 | if simpleSelfCastActive then |
||
24 | SimpleSelfCast_Enable(); |
||
25 | end |
||
26 | end |
||
27 | end |
||
28 | |||
29 | function SimpleSelfCast_Command(arg) |
||
30 | if arg == "enable" then |
||
31 | SimpleSelfCast_Enable(); |
||
32 | elseif arg == "disable" then |
||
33 | SimpleSelfCast_Disable(); |
||
34 | elseif arg == "help" then |
||
35 | SSCPrint(helpString); |
||
36 | elseif arg == "nosplash" then |
||
37 | SSCPrint("Splash message on starup will not be displayd."); |
||
38 | simpleSelfCastSplash = false; |
||
39 | elseif arg == "splash" then |
||
40 | SSCPrint("Splash message on starup will be displayd."); |
||
41 | simpleSelfCastSplash = true; |
||
42 | else |
||
43 | if simpleSelfCastActive then |
||
44 | SimpleSelfCast_Disable(); |
||
45 | else |
||
46 | SimpleSelfCast_Enable(); |
||
47 | end |
||
48 | end |
||
49 | end |
||
50 | |||
51 | function SimpleSelfCast_Enable() |
||
52 | SSCPrint("Simple Self Cast enabled."); |
||
53 | if simpleSelfCastOriginalUseAction == nil then |
||
54 | simpleSelfCastOriginalUseAction = UseAction; |
||
55 | UseAction = SimpleSelfCast_UseAction; |
||
56 | simpleSelfCastActive = true; |
||
57 | end |
||
58 | end |
||
59 | |||
60 | function SimpleSelfCast_Disable() |
||
61 | SSCPrint("Simple Self Cast disabled."); |
||
62 | if simpleSelfCastOriginalUseAction ~= nil then |
||
63 | UseAction = simpleSelfCastOriginalUseAction; |
||
64 | simpleSelfCastOriginalUseAction = nil; |
||
65 | simpleSelfCastActive = false; |
||
66 | end |
||
67 | |||
68 | end |
||
69 | |||
70 | function SimpleSelfCast_UseAction(id, type, self) |
||
71 | if simpleSelfCastOriginalUseAction then |
||
72 | simpleSelfCastOriginalUseAction(id, type, self); |
||
73 | if( SpellIsTargeting() ) then |
||
74 | if (UnitIsFriend("player","target")) then |
||
75 | SpellTargetUnit("target"); |
||
76 | else |
||
77 | SpellTargetUnit("player"); |
||
78 | end |
||
79 | end |
||
80 | end |
||
81 | end |
||
82 | |||
83 | function SSCPrint(string) |
||
84 | if Print ~= nil then |
||
85 | Print(string); |
||
86 | elseif DEFAULT_CHAT_FRAME then |
||
87 | DEFAULT_CHAT_FRAME:AddMessage(string); |
||
88 | end |
||
89 | end |