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
➜ random delay and many trigtexts
random delay and many trigtexts
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Doorie
Finland (10 posts) Bio
|
Date
| Sat 10 Oct 2009 07:04 PM (UTC) |
Message
| hello!
first time in here, so here i go:
1) i need to have a random delay between the trigger text and the action i want. delay time something like n+(1.000 - 10.000) seconds. i tried searching functions and also searched here in forums, but couldn't find a solution.
2) there are several death messages in mud what i use, and i have them all triggered for some action. instead of having 10 different ones, can i have some kind of: "trigtext1"|"trigtext2" solution, so taht i can have only one trigger?
thank you:)
-s-
| Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #1 on Sat 10 Oct 2009 07:37 PM (UTC) Amended on Sat 10 Oct 2009 07:43 PM (UTC) by Twisol
|
Message
| Hello! Welcome to the forums ;)
1) You can use the scripting function DoAfter. Example:
DoAfter(10, "text to send")
The first parameter is the delay, in seconds, before that text is sent. This creates a temporary MUSHclient timer, and does NOT pause the actual script - it just tells MUSHclient it wants to do something later, and continues doing whatever comes after the DoAfter call.
If you want to randomize the time it takes, you could do...
DoAfter(MtRand()*9+1, "text to send")
You'll want to put MtSrand(os.time()) in your scripting file too, so that the random-number generator always gives you a different sequence instead of starting with the same one every time.
2) Yep! With "Regular expression" enabled, you can do something like:
^(deathmessage1|deathmessage2|deathmessage3)$
If you don't know much about regular expressions, I'd learn up on them. Regex is very powerful when it comes to triggers (and aliases). A good website is here[1].
[1]: http://www.regular-expressions.info/ |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Doorie
Finland (10 posts) Bio
|
Date
| Reply #2 on Sun 11 Oct 2009 09:18 AM (UTC) |
Message
| this does not match:
^(* unanimated corpse falls to the ground.|* staggers to the ground ... dead.)$
do i need some leading char in front of * char? or . char?
(how do i put that stuff into code-box?) | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #3 on Sun 11 Oct 2009 09:44 AM (UTC) Amended on Sun 11 Oct 2009 09:48 AM (UTC) by Twisol
|
Message
| While "* unanimated corpse falls to the ground." will work in non-regex triggers, * means something entirely different in regex. This is what you'd want:
^(.+? unanimated corpse falls to the ground\.|.+? staggers to the ground \.\.\. dead\.)$
.+? breaks down like this:
'.' is any single character. Anything at all.
'+' is a modifier, meaning "one or more". Together with the dot, it matches one or more of anything.
'?', when used after the + in this case, is a secondary modifier. Advanced topic, but it changes the "greediness" of the match. With the ?, it'll try to match one of anything, two of anything, three of anything, etc. in that order. Without it, it'll try to match as much as possible, then as much as possible minus one, etc. Trust me, this works better with the ?.
It's basically the regex-ified version of the non-regex *. You'll also notice slashes before the other dots in the triggers - that's because we want it to match a literal dot, and not 'anything'. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Doorie
Finland (10 posts) Bio
|
Date
| Reply #4 on Mon 12 Oct 2009 07:41 AM (UTC) |
Message
| ok, works, kinda..
to clarify: i don't use this trigger in script file, but 'inside' alt-enter -> triggers.
previously, i was able to fish out %1 parameter, which would be the name of the mob. now it is impossible, the first parameter is the whole death message line, not the * -char, which was able to rely it before.
who can i fish out the mob name, (* == %1) when using regexps?
i tried with (.*?) and with (.+?) but the same result.. | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #5 on Mon 12 Oct 2009 07:44 AM (UTC) |
Message
|
^(?:(.+?) unanimated corpse falls to the ground\.|(.+?) staggers to the ground \.\.\. dead\.)$
I changed the outer () to a (?:), which means it doesn't capture it and store it in %1, and surrounded the targets inside with () so they ARE captured. Try this one. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #6 on Mon 12 Oct 2009 07:52 AM (UTC) |
Message
|
 |
Regular expressions
- Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
- Also see how Lua string matching patterns work, as documented on the Lua string.find page.
|
|
- 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.
21,180 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top