Total noob needs help

Posted by Treant on Wed 26 Aug 2009 04:55 AM — 21 posts, 86,652 views.

USA #0
Hello, New to the forum, new to scripting and what have you.

Needing major help ( practically need someone who's feeling nice to build it for me )

Theres a spell in the mud that I play that will tell you where the enemies are if they're in the same zone as you and it appears like this


You can momentarily see in all directions..
*Duke Treant*                       Inside Kael's North Walls
  Duke Zebulon                       General's Annex Room
<6395/6395Hp 2964/3072Mp 1290/1290Mv>NESW 2401 


I need the script to report to group via GT ( group tell ) the enemy's name and the enemy's location the enemy has the * * around his name, friendlies show up with the spell but do not have the asteriks

I have no idea where to begin on this.
Amended on Wed 26 Aug 2009 05:14 AM by Treant
#1
Template:post=9626
Please see the forum thread: http://gammon.com.au/forum/?id=9626.

Until one of the experts replies here you might want try creating triggers for the spell. The link above is a great movie that step-by-steps through the process.
Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

If you have trouble with getting the triggers to work you can paste them here for help using the info from the above link.
USA #2
I Kind of have it working..

You can momentarily see in all directions..
Reyven South-East Training Field
gt Reyven is at South-East Training Field

I got this to work by replacing Reyven with * and South-East Training field with another *

^(.*?)                       (.*?)$

there is not always the same amount of spaces between name and location, is there a variable to assume the role of spaces untill the first letter of another appears? and Reyven is a friendly, enemies start with a * so what would i have to do to allow a * to appear as a regular charachter for the trigger to extract?
Amended on Wed 26 Aug 2009 07:29 AM by Treant
USA #3

^\*(.*?)(.s)(.*?)$


So the (.s) would replace all of the spaces and with \* it will only catch lines that start with a *

then i have


gt *%1 is at %3


as the send to output BUT lines starting with * arent only found on the spell, decoy's sitting around appear with the * before and after their name as well as enemies you would just run into while walking around..

so I need the trigger to only fire on lines starting with * but after the line

You can momentarily see in all directions..





<6395/6395Hp 2806/3072Mp 1290/1290Mv>NESW 2401 You can momentarily see in all directions..
Reyven                       South-East Training Field
*Duke Treant*                       Training Grounds


another issue i see is that sometimes the command prompt will appear on the same line as "you can momentarily see in all directions.." and sometimes it wont..
Amended on Wed 26 Aug 2009 07:50 AM by Treant
USA #4

<6395/6395Hp 2878/3072Mp 1290/1290Mv>NESW 2401 ee
You can momentarily see in all directions..
Reyven                       South-East Training Fieldgt Eagle Eye Complete Enemy Locations are as Follows.
gt Reyven                       South-East Training Field
gt 
Treant                       Cobblestone Street leading into Kaelgt Eagle Eye Complete Enemy Locations are as Follows.
gt Reyven                       South-East Training Field
gt Treant                       Cobblestone Street leading into Kael

<6395/6395Hp 2842/3072Mp 1290/1290Mv>NESW 2401 You tell the group '[Wood]  Eagle Eye Complete Enemy Locations are as Follows.'

<6395/6395Hp 2842/3072Mp 1290/1290Mv>NESW 2401 You tell the group '[Wood]  Reyven                       South-East Training Field'

<6395/6395Hp 2842/3072Mp 1290/1290Mv>NESW 2401 You tell the group '[Wood]  '

<6395/6395Hp 2842/3072Mp 1290/1290Mv>NESW 2401 You tell the group '[Wood]  Eagle Eye Complete Enemy Locations are as Follows.'

<6395/6395Hp 2842/3072Mp 1290/1290Mv>NESW 2401 You tell the group '[Wood]  Reyven                       South-East Training Field'

<6395/6395Hp 2842/3072Mp 1290/1290Mv>NESW 2401 You tell the group '[Wood]  Treant                       Cobblestone Street leading into Kael'



^You can momentarily see in all directions\.\.\n(.*?)\n(.*?)\Z$


Ok I'm getting the double feed issue, and what do I do if there are more than just 2 people in the report?
#5
Full regular expression help can be found here.
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.

#6
treant said:

So the (.s) would replace all of the spaces and with \* it will only catch lines that start with a *

\s+ will match one or more spaces.
\s* will match zero or more spaces.
Amended on Wed 26 Aug 2009 08:22 AM by Blainer
#7
You can paste the triggers you are working to the forum.
Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.
Amended on Wed 26 Aug 2009 11:40 AM by Nick Gammon
Australia Forum Administrator #8
Treant said:

Ok I'm getting the double feed issue, and what do I do if there are more than just 2 people in the report?


I wouldn't use a multi-line trigger myself, that will be fiddly for an unknown number of people. Can't you just have a single-line trigger, and do one GT per enemy? If not, you would need to "batch them up" as they arrive, and then when something else (eg. a prompt) arrives, send the names via the GT.

If you are having trouble, please copy and paste what you have so far, as Blainer suggested.
USA #9
Nick Gammon said:

Treant said:

Ok I'm getting the double feed issue, and what do I do if there are more than just 2 people in the report?


I wouldn't use a multi-line trigger myself, that will be fiddly for an unknown number of people. Can't you just have a single-line trigger, and do one GT per enemy? If not, you would need to "batch them up" as they arrive, and then when something else (eg. a prompt) arrives, send the names via the GT.

If you are having trouble, please copy and paste what you have so far, as Blainer suggested.


I could and would definately love to have the trigger GT for each enemy that appears, the enemy appears with *Count Duke* (bunch of spaces) Location then goes to a new line. I dont know how to make the trigger catch the name in this certain format, because what If i am walking around and just see them in a room, *count duke* is here., i don't need it to report in that case, only when the spell is used to see the name.
USA #10
In essence, what I'm asking, how to make it ONLY catch a line that looks like


*Countess Klara*                        Annexed Planning Room


there will always be multiple spaces, where as if you walk into a room and see them it looks like this.


*Duke Treant* is here.

USA #11
Assuming the first asterisk starts the line, and the location ends it, this would match and put the name in %1, the location in %2.


^\*(.+?)\*\s+(.+)$

Keep it off by default. Turn it on when you see the 'You can momentarily see in all directions..' line, have it temporarily save all information you want to send. Send it however you need it, and turn it off, on the next prompt.

explanation:
^ means start of line
\* matches an asterisk
(.+?) matches anything, but is non-greedy (it'll stop as soon as possible) and the () sends it to %1
\* matches another asterisk, and stops the previous
\s+ matches any number of spaces, and will keep going until it finds something that isn't a space
(.+) matches anything, and starts at the end of the spaces
$ means end of line
Amended on Thu 27 Aug 2009 03:41 AM by Fadedparadox
USA #12

<triggers>
  <trigger
   enabled="y"
   group="Eagle Eye/Farsight"
   keep_evaluating="y"
   match="^\*(.*)\*\s+(.*)$"
   regexp="y"
   sequence="100"
  >
  <send>gt *%1* is at %2</send>
  </trigger>
</triggers>


If i added [^is here\.] to the match so that it would look like


match="^\*(.*)\*\s+([^is here\.].*)$"


Would that make it match Anything starting a line with a *Name* (spaces) Anything except [is here.]
I dont need it to single out the letters i s h e and r. I need it to single out the phrase [is here.] such as

*Duke Treant* is here. <---
Amended on Thu 27 Aug 2009 05:12 AM by Treant
Australia Forum Administrator #13
No, the square brackets look for a set. However you are on the right general track.

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.


Look for "lookahead assertions" (negative).


<triggers>
  <trigger
   enabled="y"
   group="Eagle Eye/Farsight"
   keep_evaluating="y"
   match="^\*(.*)\*\s+(?!is here\.)(.*)$"
   regexp="y"
   sequence="100"
  >
  <send>gt *%1* is at %2</send>
  </trigger>
</triggers>


The above seemed to work when I tested it. It looks for the thing in asterisks, followed by anything, *except* "is here.".
USA #14
finally got it working properly ( as far as i can test it so far )


<triggers>
  <trigger
   enabled="y"
   group="Eagle Eye/Farsight"
   keep_evaluating="y"
   match="^\*(.*)\*([^yells]\s+)([^is here\.].*)$"
   regexp="y"
   sequence="100"
  >
  <send>gt {C*%1*{G is at {C%3{x</send>
  </trigger>
</triggers>


Thanks for the help everyone.

In case you are wondering why Yells is in there where it is, its because i found enemies, eagle eye'd to see them, it reported, but they saw me and started yelling back.. it thought it was also reporting since they didnt yell "is here." so I added yells in there and modified it to skip wildcard 2 and use 3 in the return line.

Oh, the {C and {G whatever, are color strings for the mud i play, so ignore those in the return line too.
Amended on Thu 27 Aug 2009 06:45 AM by Treant
Australia Forum Administrator #15
Quote:

[^yells]


I don't think that will work properly. That matches a single letter, which is *not* one of: y, e, l, s.

If you are trying to exclude multiple things, the simplest way to go about it is probably to match anything, and then test for the exclusions in a small script, like this:


<triggers>
  <trigger
   enabled="y"
   group="Eagle Eye/Farsight"
   keep_evaluating="y"
   match="^\*(.*)\*\s+(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

-- exclusions
if string.match ([===[%2]===], "^yells") or
   [===[%2]===] == "is here." then
  return
end

-- not excluded? send it
Send ("gt *%1* is at %2")

</send>
  </trigger>
</triggers>


That doesn't try to exclude things like "is here" in the regular expression, but it then tests in the script for a match on "yells <something" or "is here.".

I used the slightly unusual form of Lua quotes because someone might cause your script to fail by putting quotes in what they say. eg.


*Nick* yells "hello".

Amended on Thu 27 Aug 2009 07:01 AM by Nick Gammon
USA #16
I did some experimentation way back about the %1 placeholder strings, and it turns out that MUSHclient escapes the quotes for you before inserting into the script code. You really can just use "%1" and not worry about it.
Australia Forum Administrator #17
Yes, I keep forgetting it does that. :)

So this will work:


<triggers>
  <trigger
   enabled="y"
   group="Eagle Eye/Farsight"
   keep_evaluating="y"
   match="^\*(.*)\*\s+(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

-- exclusions
if string.match ("%2", "^yells") or
   "%2" == "is here." then
  return
end

-- not excluded? send it
Send ("gt *%1* is at %2")

</send>
  </trigger>
</triggers>

USA #18
So send to 12, thats script, i need to put exclusions and all that stuff after the trigger in a script, or if i copy paste that as a plugin, it'll work as is?
Australia Forum Administrator #19
It's not a plugin, it is a single trigger. Just copy that into the client:

Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Yes, 12 is send-to-script. Don't try to copy and paste individual lines, follow the instructions on the link there.

It should work as-is, the exclusions are in the small bit of script that is there.
USA #20
Nick Gammon said:

It's not a plugin, it is a single trigger. Just copy that into the client:

(pasting)

Yes, 12 is send-to-script. Don't try to copy and paste individual lines, follow the instructions on the link there.

It should work as-is, the exclusions are in the small bit of script that is there.


Works like a charm, thanks for the help guys.