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
➜ Tips and tricks
➜ Creating one-shot *triggers* in scripts
Creating one-shot *triggers* in scripts
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Krenath
USA (76 posts) Bio
|
Date
| Tue 29 Jan 2002 10:00 PM (UTC) |
Message
| If you want a simple way of programmatically creating a one-shot trigger, here are two VBscript subroutines you can use which will generate a trigger with a random name that will delete itself upon firing.
Sub OneShotTrigger(sPattern,sResponseText)
Dim iFlags,iRand
Randomize timer
iRand=int(32767*rnd(1)+1)
iFlags = eEnabled+eKeepEvaluating+eIgnoreCase+eTriggerRegularExpression+eExpandVariables+eReplace
World.AddTrigger "OneShot_"&iRand,sPattern,sResponseText,iFlags,-1,0,"","OnDeleteTrigger"
End Sub
Sub OnDeleteTrigger(sName,sOutput,aParams)
world.deletetrigger sName
End Sub
You can then call OneShotTrigger with your pattern and the text you want to send as a response and not have to worry about the trigger waiting around to fire at inappropriate times.
OneShotTrigger "Bob has connected.","say Hi, Bob!"
THe above will greet bob the next time he connects, but not repeat if he disconnects and reconnects.
|
- Krenath from
bDv TrekMUSH
ATS TrekMUSH
TNG TrekMUSE
TOS TrekMUSE | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 30 Jan 2002 02:07 AM (UTC) |
Message
| Nice idea.
You can save a small amount of effort, and make the trigger names stay unique for longer, by using World.GetUniqueNumber.
This returns a unique number for the session, that is a "long" so it has a larger range of values than the 32,767 you used in conjunction with the rnd function.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #2 on Thu 21 Feb 2002 08:37 PM (UTC) |
Message
| However, I must admit that your way is better if you are likely to be adding triggers over multiple sessions, as the GetUniqueNumber function only supplies a unique number for a particular execution of MUSHclient. |
- 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.
14,455 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top