[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  random delay and many trigtexts

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: random delay and many trigtexts
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Mon 12 Oct 2009 07:52 AM (UTC)  quote  ]
Message
Template:regexp 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
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Mon 12 Oct 2009 07:44 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Doorie   Finland  (10 posts)  [Biography] bio
Date Mon 12 Oct 2009 07:41 AM (UTC)  quote  ]
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..
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sun 11 Oct 2009 09:44 AM (UTC)  quote  ]

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
[Go to top] top

Posted by Doorie   Finland  (10 posts)  [Biography] bio
Date Sun 11 Oct 2009 09:18 AM (UTC)  quote  ]
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?)
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Sat 10 Oct 2009 07:37 PM (UTC)  quote  ]

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
[Go to top] top

Posted by Doorie   Finland  (10 posts)  [Biography] bio
Date Sat 10 Oct 2009 07:04 PM (UTC)  quote  ]
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-

[Go to top] 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.


1,737 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]