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 ➜ VBscript ➜ Triggers, passing multiple variables

Triggers, passing multiple variables

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


Posted by Sleaker   (24 posts)  Bio
Date Sat 24 Aug 2002 06:21 AM (UTC)
Message
okay I have a alias.

conint *
Script: ContactTimerInterval

and the VBS script it calls.

Sub ContactTimerInterval(thename, theoutput, theparameters)

If World.GetVariable("ContactTimer") = "ON" And IsNumeric(Trim(theparameters(1))) = TRUE Then

world.SetVariable "ConTimerInterval", Trim(theparameters(1))

world.note "Contact Timer Interval Set to: " &

World.GetVariable("ConTimerInterval") & " seconds."

World.DeleteTimer "ContactTimer"

World.AddTimer "ContactTimer", 0, 0, Trim(theparameters(1)), "contacts", 1, ""

ElseIf (World.GetVariable("ContactTimer") = "OFF") Then

World.note "You must enable the Contact Timer before setting the interval."

Else

World.note "The current Contact Timer Interval is set to: " & World.GetVariable("ConTimerInterval") & " seconds."

End If
End Sub

I want it to take any Number over 59 and change it to Hours Minutes Seconds, then pass it to the AddTimer function.

So would I do as follows?



then run a While loop that While TRIM(theparameters(1)) is
greater than 60 it does
TRIM(theparameters(1)) - 60 and

World.SetVaraible "ContactIntervalMinutes", +1
or how do you add 1 to a variable?
then after seconds are finished it sets
World.SetVariabliable "ContactIntervalSeconds", TRIM(theparameters(1))

and then finally it checks for hours the same way with a while loop. then uses all that info and sets the Timer.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 24 Aug 2002 06:34 AM (UTC)
Message
First, if you use DoAfter instead of AddTimer it takes seconds instead of hours/minutes/seconds.

Second, to convert seconds to the other things you really need to divide by 60.

eg.

hours = CInt (seconds / 3600)

(The CInt converts to an integer, ie. a whole number).

Now get the remainder...

seconds = seconds - (hours * 3600)

Now for minutes ...

minutes = CInt (seconds / 60)

seconds = seconds - (minutes * 60)

- Nick Gammon

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

Posted by Sleaker   (24 posts)  Bio
Date Reply #2 on Sat 24 Aug 2002 06:38 AM (UTC)
Message
hrm, converting Seconds to Hours & Minutes & Seconds, why can't I run a While loop that subtracts 60 seconds and adds 1 minute, then stops when it can't subtract 60. How would that not work?
Top

Posted by Sleaker   (24 posts)  Bio
Date Reply #3 on Sat 24 Aug 2002 06:53 AM (UTC)
Message
mm okay I see whatcha mean :D yes your way is easiest hehe
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #4 on Sat 24 Aug 2002 04:23 PM (UTC)
Message
I just posted this in another thread:

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

Elsewhere in my script, I grab the current time with the VBS function: Now()

I wrote the function above to subtract two different "Now()" values, and present the results in the format "hh:mm:ss".

(I wanted to strip the date, which is included with the VBS function "DateDiff").

I check to make sure the seconds isn't too high (above 25 hours). This is because sometimes my triggers would inadvertantly call this script when the start time had not been initialized, and an error in the values would cause a runtime error.

Anyway, you can see how I do the conversion you are talking about...

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.


20,875 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.