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
➜ Timers, and Escape Characters
Timers, and Escape Characters
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Mike Kilian
(15 posts) Bio
|
Date
| Thu 11 Apr 2002 02:59 AM (UTC) |
Message
| Two topics here. First is I have a tick timer set up, and it triggers a script which sends a groupsay 'tick in 10 seconds' 10 seconds (more or less) before the tick. My problem is, sometimes I'd like to know exactly how long it is until the tick. Is there a VB script I can write to be called by an alias (call it "ttime") that will World.Note the time left before the timer (named "clock")fires?
Second, I use ; a lot to stack commands, but I also routinely change certain mud aliases on the fly to do multiple tasks. (ex. alias aa assist fred;assist john;cast 'blind') I know I can go into Game=>Configure=>Commands to check or uncheck command stacking, but it'd be easier if I could escape the ; while typing out my alias, ie. alias aa assist fred/;assist john/;cast 'blind'. I haven't been able to find an escape for this in the MushClient documentation, nor by trial and error.
Thanks for any assistance,
Mike | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 11 Apr 2002 03:52 AM (UTC) Amended on Thu 11 Apr 2002 03:55 AM (UTC) by Nick Gammon
|
Message
|
Quote:
Is there a VB script I can write to be called by an alias (call it "ttime") that will World.Note the time left before the timer (named "clock")fires?
Not directly. However, make the tick timer remember the current time, and when you want to know the time to go, subtract the current time (now) from the time the tick timer was set up. I seem to recall a post about this a while ago. Try searching for that.
Quote:
I know I can go into Game=>Configure=>Commands to check or uncheck command stacking, but it'd be easier if I could escape the ; while typing out my alias
Here are two possibilities for you ...
- Use double semicolons, like this:
alias aa assist fred;;assist john;;cast 'blind'
- Make an alias to turn off stacking. It would do this:
world.setoption "enable_command_stack", 0
Make another to turn it back on ...
world.setoption "enable_command_stack", 1
Then call those aliases when required.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mike Kilian
(15 posts) Bio
|
Date
| Reply #2 on Thu 11 Apr 2002 07:57 AM (UTC) Amended on Thu 11 Apr 2002 08:00 AM (UTC) by Mike Kilian
|
Message
| Double ;;. Why the hell didn't I think of that? Works perfect, thanks.
As for getting the timer countdown, yes, to have it do some math would be relatively easy, but I don't know how to get the time elapsed on the clock timer. There was a post awhile back ( http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=410 -"Timer triggers (help needed)" from July 30, 2001 in the Jscript Forum) where Nick wrote a script to get the time remaining on variable spells on variable people, but with my lack of experience using VBscript, I can't figure out which line makes the timer remember the current time (then set a variable to that and subtract it from 72 should work).
Heck, I think I can do it except I don't know how to call the time elapsed on the timer. Plus there's got to be a better way of storing variables than as world variables, isn't there?
My formal effort:
Sub TimeUntilTick (thename, theoutput, theWildcards)
World.SetVariable "elapsed", cint(World.GetTimer("clock"))
World.SetVariable "timeleft", (72-World.GetVariable(elapsed))
World.Note " " & World.GetVariable("timeleft") & " seconds until tick"
End Sub
Of course, I get an error that "World.GetTimer" is not a valid argument. Also, Object doesn't support this property or method: 'World.GetTimers' when I add the "s".
And I'm not sure the timeleft variable will be set by doing the math that way, but I haven't been able to get that far yet.
Mike | Top |
|
Posted by
| Mike Kilian
(15 posts) Bio
|
Date
| Reply #3 on Thu 11 Apr 2002 08:13 AM (UTC) |
Message
| Ok, did some testing on the math portion. Everything but the cint(World.GetTimer("clock")) should be correct.
Sub TimeUntilTick (thename, theoutput, theWildcards)
World.SetVariable "elapsed", cint(World.GetTimer("clock"))
World.SetVariable "timeleft", 72-World.GetVariable("elapsed")
World.Note " " & World.GetVariable("timeleft") & " seconds until tick"
End Sub
Mike | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #4 on Thu 11 Apr 2002 10:55 AM (UTC) |
Message
| You need to use "now" now. ;)
Try something like this:
world.setvariable "start_time", Now
... and then when you need the time to go ...
timeleft = 10 + DateDiff("s", Now, world.getvariable ("start_time"))
"Now" is the current time. DateDiff calculates the difference in seconds. Subtract (add?) that from the number of seconds you are interested in (in this case, 10) and you should get your time left. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mike Kilian
(15 posts) Bio
|
Date
| Reply #5 on Thu 11 Apr 2002 08:51 PM (UTC) |
Message
| Thanks Nick :)
Sub clocktick (strTriggerName, strTriggerLine, arrWildcards)
World.ResetTimer "clock"
world.setvariable "start_time", Now
End Sub
Sub TimeUntilTick (thename, theoutput, theWildcards)
timeleft = (72+DateDiff("s", Now, world.getvariable ("start_time")))
World.Note " " & timeleft & " seconds until tick"
End Sub
This works provided I reset my "clock" timer every tick. Unfortunately I don't have that luxury. Once I go a tick without reseting the timer, I get -20 seconds to tick, -180 seconds to tick, etc. Any way to reset the start_time variable without reseting the timer?
Mike | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #6 on Thu 11 Apr 2002 11:51 PM (UTC) |
Message
| When the "clock" timer fires just reset the time now. Wouldn't that work? Like this ...
sub myTimer (strTimerName)
' whatever you do in the timer ...
world.setvariable "start_time", Now
end sub
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
19,533 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top