Register forum user name Search FAQ

Gammon Forum

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 ➜ Brackets and my trouble

Brackets and my trouble

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Magellan   (15 posts)  Bio
Date Mon 13 Nov 2017 03:10 AM (UTC)

Amended on Mon 13 Nov 2017 05:50 AM (UTC) by Fiendish

Message
without too much preamble here, i have a trigger set to collect some data off the prompt line. it works unless i enter a room that adds one or more set of brackets.



[695, 770]<552hp 496sp 499st> 



the trigger pulls everything you see there and sets it all as variables. it also throws out a second prompt line that shows some information i want. i didn't include it in these examples because they are in reaction to the line i did include.

so this is what happens if i go into another room with a visible flag:


[SAFE][695, 770]<5000hp 4968sp 4998st> 
Run-time error
World: [NDA]
Immediate execution
[string "Alias: "]:7: attempt to perform arithmetic on a string value
stack traceback:
        [string "Alias: "]:7: in main chunk
        [C]: in function 'Execute'
        [string "Trigger: "]:4: in main chunk



here is the trigger:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="affects"
   keep_evaluating="y"
   match="\[(.*?)\, (.*?)\]\&lt;[0-9]+hp [0-9]+sp [0-9]+st\&gt; $"
   omit_from_log="y"
   regexp="y"
   send_to="14"
   sequence="200"
  >
  <send>ColourNote ("blue", "black", "[", "gray", "black", "@Combat", "@mCa", "black", " Trgt","blue", "black","] ADIR @DIR waypoint @wpX,@wpY - return val @rX,@rY")
SetVariable ("X", "%1")
SetVariable ("Y", "%2")
Execute("return")
Execute("rcp")</send>
  </trigger>
</triggers>


i realize this is somewhat ugly. and i know that the error is that it is seeing the first set of brackets and then the line triggers and it's trying to do 'arithmetic' on a non-numerical line. i tried making it so it was only looking specifically for the lines i want, and removed the portion that would look for the start of a line hoping it would just ignore the [SAFE] bracket when it pops up. what do i need to do to make it ignore flags when they pop up. this is something that happens frequently and doesn't really affect the trigger but the annoying error is distracting. i appreciate the input.
Top

Posted by Fiendish   USA  (2,535 posts)  Bio   Global Moderator
Date Reply #1 on Mon 13 Nov 2017 05:48 AM (UTC)

Amended on Mon 13 Nov 2017 05:49 AM (UTC) by Fiendish

Message
When I have something that sometimes appears on a line, I make my regular expression expect it "maybe" by using the question mark symbol. Also escaping a comma isn't necessary.

So where you have

\[(.*?)\, (.*?)\]

I would put

(\[.*\])?\[(\d+), (\d+)\]

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Magellan   (15 posts)  Bio
Date Reply #2 on Mon 13 Nov 2017 06:41 AM (UTC)
Message
Thanks Fiendish. A Gentleman Scholar as always!
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.


10,603 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.