Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Logging amount of time something has been going for

Logging amount of time something has been going for

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Neverwhere   USA  (40 posts)  Bio
Date Sun 30 Dec 2001 06:20 AM (UTC)
Message
ok, i want to create a trigger that would read when a spell begins to be used on myself... i.e. "Neverwhere puts a protective aura on you."

Is there any way to log when this begins, then count the seconds until the client reads the down message... i.e "Your Iron Will wears off."

I dont know how to make triggers that would count the time the spell has been in effect for (in seconds) and I would very much like any help as to how to make this work.. (Easily mastered if possible, but I know C and C++ to I can figure out the harder crap.)

Thanks

Neverwhere

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #1 on Sun 30 Dec 2001 07:50 AM (UTC)
Message
Excellent idea. I think this is a project I would take on myself. ...But I'll have to put it on the list, I am working on other projects first.

I don't think MushClient has any functions built-in for recording time, but the various scripting languages probably do.

Since I do my scripting in Visual Basic, I will search the internet for documentation on how to access such functions in VBS. I'd recommend you do the same, if no one can come to your aid and you are impatient. :)

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #2 on Sun 30 Dec 2001 10:17 PM (UTC)
Message
It can certainly be done. VBscript supports the "variant" data type which includes the ability to remember dates/times.

You would make the trigger call a script, the script would get the current time (I don't remember the exact function name) and store it in a global variable (ie a variable outside a "sub").

Then you could make a timer that fired (say) every second, and got the current time. You can subtract times, giving the difference in seconds. Then that difference could be displayed somewhere useful, like on the status bar.

The second trigger (when the spell elapses) could then remove the timer.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Neverwhere   USA  (40 posts)  Bio
Date Reply #3 on Sun 30 Dec 2001 10:49 PM (UTC)
Message
cool, but how about giving me a demonstration... i dont really get howto call scripts and that stuff, i get a trig that fires every second, but i dont know howto activate it/shut it off...

MUSHClient is really cool btw, and user friendly. Thanks for making such a good one.

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #4 on Mon 31 Dec 2001 01:46 AM (UTC)

Amended on Mon 31 Dec 2001 01:48 AM (UTC) by Nick Gammon

Message
Well, it would look like this.

Add 2 triggers and 1 timer using the configuration screen ...





Trigger: * puts a protective aura on you
Label: NewAura
Script: OnNewAura


Trigger: Your Iron Will wears off.
Label: LostAura
Script: OnLostAura


Timer: (every 1 second)
Enabled: NOT checked
Label: CheckAura
Script: OnCheckAura




Then add the following script routines to the script file (language VBscript). You could use the exampscript.vbs file that came with MUSHclient, or start a new, empty one. Make sure that scripting is enabled and that the appropriate script file is selected.



Dim AuraTime

Sub OnNewAura(strTriggerName, strOutput, arrWildCards)
  AuraTime = Now () 
  world.EnableTimer "CheckAura", 1
End Sub

Sub OnCheckAura(strTimerName)
Dim CurrentTime, Elapsed
  CurrentTime = Now ()
  Elapsed = DateDiff ("s", AuraTime, CurrentTime)
  World.SetStatus "Aura for: " & Elapsed & " seconds."
End Sub

Sub OnLostAura(strTriggerName, strOutput, arrWildCards)
  world.EnableTimer "CheckAura", 0
  World.SetStatus "Ready."
End Sub


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Neverwhere   USA  (40 posts)  Bio
Date Reply #5 on Mon 31 Dec 2001 09:13 PM (UTC)
Message
ok, thanks man.

Hmm... does it matter what you title a vbscript? I think ill just try any old name, but maybe it wont work, hopefully it will.

Neverwhere

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
Top

Posted by Neverwhere   USA  (40 posts)  Bio
Date Reply #6 on Mon 31 Dec 2001 09:20 PM (UTC)
Message
darn... How would i be able to see how long the timer has been firing for? when the down msg gets shown, how would one go about reporting how long it lasted for.. kinda like "IW down! [XXX secs]"

i dont know much about vbscripting, hopefully this will help me out.. sorry about my idiocy

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #7 on Mon 31 Dec 2001 09:57 PM (UTC)
Message
You mean, when the aura wore off?

Something like this (new stuff in bold) ...


Sub OnLostAura (strTriggerName, strOutput, arrWildCards)
Dim CurrentTime, Elapsed
  world.EnableTimer "CheckAura", 0
  World.SetStatus "Ready."
  CurrentTime = Now ()
  Elapsed = DateDiff ("s", AuraTime, CurrentTime)
  World.Note "Aura was active for: " & Elapsed & " seconds."
End Sub


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #8 on Mon 06 May 2002 05:11 PM (UTC)

Amended on Mon 06 May 2002 05:24 PM (UTC) by Magnum

Message
Heh... I was looking for an old thread, and found this one. Thought I would post some of my script:

Const vbsTrue = 1
Const vbsFalse = 0
Dim SS_HB,      SD_HB,      SC_HB
Dim SS_MB,      SD_MB,      SC_MB
Dim SS_BC,      SD_BC,      SC_BC
Dim SS_GS,      SD_GS,      SC_GS
Dim SS_AOR,     SD_AOR,     SC_AOR
Dim SS_Berserk, SD_Berserk, SC_Berserk


Function TimeDiff (StartTime, EndTime)
	Dim Hours, Minutes, Seconds
	Seconds = DateDiff("s", StartTime, EndTime)
	If Seconds > 90000 Then Seconds = 90000
	If Seconds < 0 Then Seconds = 0
	Minutes = Seconds / 60
	Minutes = Fix(Minutes)
	Seconds = Seconds - (Minutes * 60)
	Hours = Minutes / 60
	Hours = Fix(Hours)
	Minutes = Minutes - (Hours * 60)
	Seconds = CStr(Seconds)
	Minutes = CStr(Minutes)
	Hours = CStr(Hours)
	If Len(Seconds) = 1 Then Seconds = "0" + Seconds
	If Len(Minutes) = 1 Then Minutes = "0" + Minutes
	If Len(Hours) = 1 Then Hours = "0" + Hours
	TimeDiff = Hours & ":" & Minutes & ":" & Seconds
End Function


Sub Grab_BodyClock (thename, theoutput, arrWildcards)
	SS_BC = Now()
	SC_BC = arrWildcards(2)
End Sub

Sub Display_End_BodyClock (thename, theoutput, arrWildcards)
	Dim TimeStamp
	If SS_BC <> Empty Then
		SD_BC = TimeDiff(SS_BC, Now())
		TimeStamp = " (" & SD_BC & " - " & SC_BC & ")."
	End If
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		World.Send "party emote no longer has a fastened body clock." & TimeStamp
	Else
		World.Note "END: Body Clock" & TimeStamp
	End If
	SS_BC = Empty
	World.EchoInput = vbsTrue
End Sub

Sub Grab_GodShield (thename, theoutput, arrWildcards)
	SS_GS = Now()
	SC_GS = arrWildcards(2)
End Sub

Sub Display_End_Godshield (thename, theoutput, arrWildcards)
	Dim TimeStamp
	If SS_GS <> Empty Then
		SD_GS = TimeDiff(SS_GS, Now())
		TimeStamp = " (" & SD_GS & " - " & SC_GS & ")."
	End If
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		World.Send "party emote no longer has a Godshield." & TimeStamp
	Else
		World.Note "END: GodShield" & TimeStamp
	End If
	SS_GS = Empty
	World.EchoInput = vbsTrue
End Sub

Sub Grab_HealthBlessing (thename, theoutput, arrWildcards)
	Dim Minutes
	SS_HB = Now()
	SC_HB = arrWildcards(2)
	If SD_HB <> Empty Then
		Minutes = Mid(SD_HB, 4, 2)
		Minutes = CInt(Minutes) - 3
		World.AddTimer "Warning_HB_Timer", 0, Minutes, 0, "", 5, "Display_HealthBlessing_Warning"
	End If
End Sub

Sub Display_End_HealthBlessing (thename, theoutput, arrWildcards)
	Dim TimeStamp
	FleeNow "Display_End_HealthBlessing", theoutput, arrWildcards
	If SS_HB <> Empty Then
		SD_HB = TimeDiff(SS_HB, Now())
		TimeStamp = " (" & SD_HB & " - " & SC_HB & ")."
	End If
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		World.Send "party emote no longer has blessed health." & TimeStamp
	Else
		World.Note "END: Health Blessing" & TimeStamp
	End If
	SS_HB = Empty
	World.EchoInput = vbsTrue
End Sub

Sub Display_HealthBlessing_Warning (TimerName)
	If World.GetVariable("InParty") Then
		World.EchoInput = vbsFalse
		World.Send "party emote expects Health Blessing will drop within 3 minutes."
	Else
		World.Note "WARNING: Health Blessing will drop within 3 minutes."
	End If
End Sub

I created the "TimeDiff" function, because I prefer to see an output of "hh:mm:ss", rather that just a count of seconds. Some spells last 30 minutes, and I don't want to be informed of it's length in seconds!

In my example, I use "SS_" for the Spell Start time, "SC_" for the Spell Caster name, and "SD_" for the Spell Done time.

The Health Blessing spell is special. It greatly increases your hit points. If it drops in battle, it can be lethal, so I call a "Fleenow" subroutine, which makes me leave the area if I was in combat. I also set up a timer, to fire 3 minutes before the spell will expire, as a warning World.Note. The script doesn't know how long the spell will last, it looks at "SD_HB", which is how long it lasted the last time the spell was cast. The variable gets reset everytime I load mushclient, so on the very first health blessing, I don't get a 3 minute warning, since "SD_HB" is empty that first time. Mostly, this is handy for killing a very large mob (that takes hours to kill), since the Health Blessing will usually come from the same healer, and thus the length of the cast is usually about the same.

My script sends the message to the party, IF I am in a party ("InParty"), otherwise, it just sends me a World.Note. "Inparty" in managed with other script, not posted here.

Hopefully, this example will give you some ideas on how to track time, and some of the fancier things you can do with that information. :)

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


26,080 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.