This was designed to work with the 'uptime' command on Ages of Despair. Changing it for another muds command would require changing the trigger and a few wildcards in the setting script, but shouldn't be too hard.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient >
<muclient>
<plugin name="Reboot_Timer"
author="Kagehi"
language="vbscript"
purpose="Displays time until reboot in the status line."
save_state="n"
requires="3.23"
version="1.0"
id="d8008e74585e7435a82d1b12"
>
<description trim="y">
<![CDATA[
Designed for the Ages of Despair mud.
This plugin reads the time until reboot from the 'uptime'
command and sets a counter in the clients status line,
indicating the time left once each minute.
Typing 'uptime' will set/reset it.
]]>
</description>
</plugin>
<!--
========================================
Startup Sub
========================================
-->
<script>
<![CDATA[
sub OnPluginConnect
world.send "uptime"
end sub
]]>
</script>
<!--
========================================
Trigger SetReb
========================================
-->
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="*The next reboot is * on * (in *)."
name="SetReb"
script="SetReb"
sequence="3"
>
</trigger>
</triggers>
<script>
<![CDATA[
sub SetReb (TrigName, Output, Wildcards)
dim sTest, sGrab, sOut
dim sMatch
sTest = wildcards(4) '"1d 1h 14m 33s"
int b
int tim
int count
tim = 0
sMatch = split(sTest," ",-1,1)
'world.note ubound(sMatch)
for count = 0 to ubound(sMatch)
sGrab = sMatch(count)
b = len(sGrab)
'world.note sGrab & ", " & count
select case right(sGrab,1)
case "d"
tim = tim + 1440
case "h"
tim = tim + CInt(left(sGrab, b-1)) * 60
case "m"
tim = tim + CInt(left(sGrab, b-1))
case "s"
b = CInt(left(sGrab, b-1))
if b > 30 then
tim = tim + 1
end if
end select
next
world.setvariable "TTRB", CStr(tim)
world.addtimer "RebootTimer", 0, 1, 0, "", 1, "RepReboot"
world.enabletimer "RebootTimer", 1
sOut = Rttt(tim)
world.note "Reboot timer set."
world.setstatus "Reboot is in " & sOut
end sub
]]>
</script>
<!--
========================================
Timer RebootTimer
========================================
-->
<timers>
<timer name="RebootTimer" script="RepReboot" enabled="y" minute="1" active_closed="y" >
</timer>
</timers>
<script>
<![CDATA[
sub RepReboot (TimerName)
dim sRet, sOut, sTest
int tim
sRet = world.getvariable ("TTRB")
tim = CInt(sRet)
tim = tim - 1
if tim < 1 then
world.enabletimer "RebootTimer", 0
world.setstatus "Reboot!"
else
sOut = Rttt(tim)
world.setstatus "Reboot is in " & sOut
world.setvariable "TTRB", CStr(tim)
end if
end sub
function Rttt(tim)
dim sRet, sOut
int temp
int temp2
temp = tim
if temp > 1440 then
sOut = " 1d "
temp = temp - 1440
end if
if temp >= 60 then
temp2 = Int(temp/60)
temp = temp - (temp2 * 60)
sOut = sOut & CStr(temp2) & "h "
end if
sOut = sOut & temp & "m."
Rttt = sOut
end function
]]>
</script>
NOTE: The above script should now be complete, the following questions and comments have been left in place for thread completeness.
Just one thing... It is generally a good idea if one of the first commands sent to the mud after all they login is the 'uptime' command. You can do this in the main world by adding it in the connection settings, however... How do you have a plugin automatically execute the command automatically the same way? |