vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
2 | <html> |
||
3 | <head> |
||
4 | <meta name="GENERATOR" content="PageBreeze Free HTML Editor (http://www.pagebreeze.com)"> |
||
5 | <title>FlexBar_Advanced_Topics_Extending FlexBar</title> |
||
6 | </head> |
||
7 | <body bgcolor="#ffffff"> |
||
8 | <p align="center"><strong><em><font size="5">Advanced Topics - |
||
9 | Extending FlexBar</font></em></strong></p> |
||
10 | <p align="center"><strong><em>PLEASE NOTE - THERE ARE CHANGES FROM |
||
11 | 1.36</em></strong></p> |
||
12 | <p align="left"><strong>Introduction:</strong> The creation of variants of |
||
13 | FlexBar (FlexBarEx, the original Matrix Flexbar and adding the detection of fear |
||
14 | to FlexBar) got me to thinking. The problem with these is that they fork |
||
15 | the FlexBar Code, making it hard for their creators to keep up with changes I |
||
16 | make in the original FlexBar. To help these folks out I've added in a few |
||
17 | arctitectural features to ensure that they can add code in that will survive new |
||
18 | versions (hopefully unchanged).</p> |
||
19 | <p align="left">The addition of the Scripts Editor and the ability to run scripts |
||
20 | on ProfileLoaded has paved the way to allowing these extension to be done within |
||
21 | the FlexBar environment instead of through outside code modules.</p> |
||
22 | <p align="left"><strong>Handling WoW Events:</strong> (NOTE - This is |
||
23 | changed since 1.36 PLEASE READ)</p> |
||
24 | <p align="left">In order to effectively code in the WoW environment, you must be |
||
25 | able to register for its events and respond to them. In 1.32-1.36 this was |
||
26 | done by making an entry in the FBEventHandlers table. This is problematic |
||
27 | in that, if I am already listening for that event you could overwrite my |
||
28 | code.</p> |
||
29 | <p align="left">In 1.37 I addressed this with 2 new functions:</p> |
||
30 | <p align="left">function FB_RegisterEvent(event, name, callback, |
||
31 | wowevent)<br>function FB_UnregisterEvent(event, name)<br></p> |
||
32 | <p align="left">The call to RegisterEvent requrest the event name (either a WoW |
||
33 | event like UNIT_HEALTH, or a FlexBar event like "mouseentergroup", a name for |
||
34 | your handler for this event, a callback function to handle the event, and a flag |
||
35 | to let FlexBar know if it is a WoW event or not.</p> |
||
36 | <p align="left">Unregister simply takes the event and name and deletes it from the |
||
37 | table.</p> |
||
38 | <p align="left">Note: For WoW events, FlexBar Code will execute first |
||
39 | followed by other functions for that event in the order they were |
||
40 | registered. For FB events, the event will be raised and acted on before |
||
41 | the registered code is run.</p> |
||
42 | <p align="left">Example:</p> |
||
43 | <p align="left">function SDK_TargetChanged()</p> |
||
44 | <p align="left"> FB_RaiseEvent("TargetChanged")</p> |
||
45 | <p align="left">end</p> |
||
46 | <p
|
||
47 | align="left">FB_RegisterEvent("PLAYER_TARGET_CHANGED","SDK_tgtchange",SDK_TargetChanged,true)</p> |
||
48 | <p align="left">Save this as "SDK Target Change Event Addition"</p> |
||
49 | <p align="left">then</p> |
||
50 | <p align="left">/flexbar runscript script='SDK Target Change Event Addition' |
||
51 | on='ProfileLoaded'</p> |
||
52 | <p align="left">and you will now get a Target Changed event in FlexBar.</p> |
||
53 | <p align="left"><strong>Conditionals:</strong></p> |
||
54 | <p align="left">Conditionals are also handled by a table (FBConditions). |
||
55 | They are indexed by a lower case condition name (EG: FBConditions["hasbuff"]) |
||
56 | and return either true or false - NOT NIL. Please see |
||
57 | FlexBar_Conditionals.lua for examples. </p> |
||
58 | <p align="left">Two conventions: If a condition has a target (argument) and |
||
59 | it is not provided, return false. If several targets are passed, and ANY |
||
60 | of them are true, return true.</p> |
||
61 | <p align="left"><strong>Slash Commands:</strong></p> |
||
62 | <p align="left">Slash commands are easy to add with WoW_UtilityClasses.lua |
||
63 | loaded:</p> |
||
64 | <p align="left">MyCmd = Command_Class:New("MyCmd","/mycmd")</p> |
||
65 | <p align="left">After this you can either add sub-commands with:</p> |
||
66 | <p align="left">MyCmd:AddCommand("command",callback,"group","usage")</p> |
||
67 | <p align="left">and parameters to that command with</p> |
||
68 | <p align="left">MyCmd:AddParam("command","param",Required,Strict,{ types },{ |
||
69 | bounds }, default)</p> |
||
70 | <p align="left">Or, if you just require a simple command, override |
||
71 | MyCmd:Dispatch(msg) to deal with it:</p> |
||
72 | <p align="left">function MyCmd:Dispatch(msg)</p> |
||
73 | <p align="left">local util = Utility_Class:New()</p> |
||
74 | <p align="left">util:Echo(msg)</p> |
||
75 | <p align="left">end</p> |
||
76 | <p align="left"> </p> |
||
77 | <p align="left">These abilities will make FlexBar extensible for other people, |
||
78 | without requiring that they remake all their changes each version.</p> |
||
79 | <p align="left"> </p> |
||
80 | </body> |
||
81 | </html> |