Yep, that makes a bit more sense. Oookay... the 'timer' alias looks like some twisted way of getting a timediff, lets see...
Here's a plugin that does all the same things as your script, has the same 'check' and 'clear' aliases to control it, plus 2 triggers to add/remove the Heavy Weight prot. Both triggers should send to scripting, adding trigger should call the AddProt sub and send the report directly to the world, this is the contents of its Send box:
call AddProt("prot_name")
world.send "party report say prot_name active!"
removing trigger calls the RemoveProt sub and do an opposite announce:
call RemoveProt("prot_name")
world.send "party report say prot_name expires!"
You can copy the bellow code, paste it into an empty text file, save as "ProtsReport.xml" in your plugins folder, and install the resulting file as Mushclient's plugin. Note that only the script was tested - triggers and aliases might be off.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE muclient >
<muclient>
<plugin name="ProtsReport" author="Keldar" language="vbscript" purpose="Reporting the status of prots"
save_state="y" date_written="2004-04-05" requires="3.42" version="1.0" id="783968f7b4c746ec0f6d2bdf">
</plugin>
<aliases>
<alias
name="check_prots"
match="check"
enabled="y"
send_to="12"
sequence="100"
><send>call ReportProts</send></alias>
<alias
name="clear_prots"
match="clear"
enabled="y"
send_to="12"
sequence="100"
><send>call ClearProts</send></alias>
</aliases>
<triggers>
<trigger
match="You suddenly feel magically heavier\."
regexp="y"
enabled="y"
send_to="12"
sequence="100"
><send>call AddProt("HW")
world.send "party report say Heavy Weight Active."</send></trigger>
<trigger
match="You feel lighter, but it doesn't seem to affect your weight\!"
regexp="y"
enabled="y"
send_to="12"
sequence="100"
><send>call RemoveProt("HW")
world.send "party report say Heavy Weight Expires."</send></trigger>
</triggers>
<script>
<![CDATA[
dim start_times
set start_times = CreateObject("Scripting.Dictionary")
function GetTimeDiff(prot)
time_now = Timer
if start_times.Exists(prot) then
GetTimeDiff = time_now - start_times.Item(prot)
end if
end function
function FormatTime(diff)
tmp_time = cint(diff)
if (tmp_time) < 60 then
mins = "0"
secs = tmp_time
else
mins = cint((tmp_time)/60)
secs = tmp_time Mod 60
end if
if secs < 10 then
secs = "0" & secs
end if
FormatTime = cstr(mins) & ":" & cstr(secs)
end function
sub ReportProts
dim tmp_time, prot, output
output = ""
for each prot in start_times.Keys
tmp_time = FormatTime(GetTimeDiff(prot))
output = output & prot & " (" & tmp_time & ") "
next
world.send "party report say " & output
end sub
sub AddProt(prot)
if (not start_times.Exists(prot)) then
start_times.Add prot, Timer
end if
end sub
sub RemoveProt(prot)
if start_times.Exists(prot) then
start_times.Remove(prot)
end if
end sub
sub ClearProts
start_times.RemoveAll
end sub
]]>
</script>
</muclient>
|