Alright, so I have a rudimentary version working.
As above, I get a timestamp when the effect starts, then again when it stops. I am tracking 8 buffs this way, so I combined the math all into one alias:
<aliases>
<alias
match="LearnDuration"
enabled="y"
send_to="12"
sequence="100"
>
<send>SetVariable("D1", math.floor(tonumber(GetVariable("1End")) - GetVariable("1Start")))
SetVariable("D2", math.floor(tonumber(GetVariable("2End")) - GetVariable("2Start")))
SetVariable("D3", math.floor(tonumber(GetVariable("3End")) - GetVariable("3Start")))
...etc
Note ("Calculated durations!")</send>
</alias>
</aliases>
I have a trigger set up for a string of text received on login that creates the BuffBar miniwindow:
<triggers>
<trigger
enabled="y"
match="Welcome to some stuff*"
send_to="12"
sequence="100"
>
<send>require "InfoBox"
BB = InfoBox:New("Buffs")
</send>
</trigger>
</triggers>
And then a trigger for the buff activation that adds the bar:
<triggers>
<trigger
enabled="y"
match="*Your skin toughens*"
send_to="12"
sequence="110"
>
<send>Duration = (GetVariable("SSDuration") * GetVariable("Extend"))
DMax = Duration
BBHA = BB:AddBar("Stoneskin: ", 100)
require "wait"
wait.make (function ()
for i = Duration, 2, -2 do
Duration = (Duration - 2)
BBHA.value = (Duration/DMax*100)
BB:Update()
wait.time(2)
end
BB:RemoveBar(1)
end)</send>
</trigger>
</triggers>
("Extend" is another tracked buff that increases buff duration by 50%. The value of the variable is 1 when not present and 1.5 when it is.)
This mostly works fine. There is a bit of lag somewhere in this that sometimes results in the buff wearing off before the bar thinks it should -- It was very noticible with a 1s wait time, but 2s gets it right 95% of the time.
So now my question is how to scale this up to all 8 buffs? I assume the lag is going to get worse when multiple scripts are waiting and firing at once, and does the index of existing bars change when one is removed? If so, do I just need to create all 8 on login and have them stick around all the time?
(Again, sorry for the newbie-ness of this. I'm not a scripter at heart so I'm mostly stumbling around to find something that works.)