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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Brackets and my trouble

Brackets and my trouble

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


Posted by Magellan   (15 posts)  [Biography] 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.
[Go to top] top

Posted by Fiendish   USA  (2,514 posts)  [Biography] 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
[Go to top] top

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


9,351 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]