vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | BCustomScript |
||
3 | Allows bar scripts to be executed at runtime. |
||
4 | --]] |
||
5 | |||
6 | local function AddScript(barID, event, action, runNow) |
||
7 | local funct = assert(loadstring("return function(bar,event)\n" .. action .. "\nend")); |
||
8 | BScript.AddBarEventAction(barID, event, funct(), runNow); |
||
9 | end |
||
10 | |||
11 | BCustomScript = { |
||
12 | Save = function(barID, event, action, runNow) |
||
13 | if not(barID and barID ~= "" and event and event ~= "") then return; end |
||
14 | |||
15 | if not BongosCustomScripts then |
||
16 | BongosCustomScripts = {}; |
||
17 | end |
||
18 | if not BongosCustomScripts[barID] then |
||
19 | BongosCustomScripts[barID] = {}; |
||
20 | end |
||
21 | assert(loadstring(action)); |
||
22 | |||
23 | BongosCustomScripts[barID][event] = {script = action}; |
||
24 | |||
25 | if runNow then |
||
26 | BongosCustomScripts[barID][event].runNow = 1; |
||
27 | AddScript(barID, event, action, runNow) |
||
28 | end |
||
29 | end, |
||
30 | |||
31 | Delete = function(barID, event) |
||
32 | if not(barID and barID ~= "" and event and event ~= "") then return; end |
||
33 | |||
34 | if BongosCustomScripts then |
||
35 | if BongosCustomScripts[barID] then |
||
36 | if BongosCustomScripts[barID][event] then |
||
37 | BScript.RemoveEventForBar(event, barID); |
||
38 | |||
39 | BongosCustomScripts[barID][event] = nil; |
||
40 | for i in BongosCustomScripts[barID] do return; end |
||
41 | BongosCustomScripts[barID] = nil; |
||
42 | for i in BongosCustomScripts do return; end |
||
43 | BongosCustomScripts = nil; |
||
44 | end |
||
45 | end |
||
46 | end |
||
47 | end, |
||
48 | |||
49 | Load = function(barID, event) |
||
50 | if not(barID and barID ~= "" and event and event ~= "") then return; end |
||
51 | |||
52 | if BongosCustomScripts then |
||
53 | if BongosCustomScripts[barID] then |
||
54 | local data = BongosCustomScripts[barID][event]; |
||
55 | if data then |
||
56 | AddScript(barID, event, data.script, data.runNow) |
||
57 | end |
||
58 | end |
||
59 | end |
||
60 | end, |
||
61 | |||
62 | LoadAll = function() |
||
63 | if BongosCustomScripts then |
||
64 | for barID in BongosCustomScripts do |
||
65 | for event, data in pairs(BongosCustomScripts[barID]) do |
||
66 | AddScript(barID, event, data.script, data.runNow) |
||
67 | end |
||
68 | end |
||
69 | end |
||
70 | end, |
||
71 | } |