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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Trigger that detects either a number or '???' ?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Trigger that detects either a number or '???' ?

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


Posted by Eloni   (28 posts)  [Biography] bio
Date Tue 06 Dec 2016 01:25 PM (UTC)
Message
My mud sometimes reports percentage health of mobs as "???". I can't seem to figure out how to make a single trigger that fires when it sees a percentage (number 0-100) OR '???'.

The trigger fires off of my prompt. The sixth asterisk is where either a percentage or the three question marks appear:

Quote:
<*hp *mana *move> * <*> <* percent>



I've tried several variations of regular expressions and normal triggers and nothing seems to work.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 06 Dec 2016 08:53 PM (UTC)

Amended on Tue 06 Dec 2016 08:54 PM (UTC) by Nick Gammon

Message
Please show what you have tried.

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.


Also copy and paste an example line of output from the MUD.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Eloni   (28 posts)  [Biography] bio
Date Reply #2 on Tue 06 Dec 2016 09:04 PM (UTC)

Amended on Tue 06 Dec 2016 09:16 PM (UTC) by Eloni

Message


<*hp *m *mv *ac> * <*> <* percent> 

<*hp *m *mv *ac> * <*> <??? percent> 




Both work individually.


^\<(.*?)hp (.*?)m (.*?)mv (.*?)ac\> (.*?) \<(.*?)\> \<((.*?)|\?\?\?) percent\> $


<*hp *m *mv *ac> * <*> <(*|???) percent> 




Neither of these worked.

edit: Forgot to include compile error



Compile error
World: world.com
Immediate execution
[string "Trigger: TrackInCombatStats"]:18: unexpected symbol near '?'

[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 07 Dec 2016 06:56 AM (UTC)
Message
If you would be kind enough to re-read reply #1, and do what it suggests in the link, that would be much appreciated.

You clearly have a problem in your code, code which you haven't posted.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Eloni   (28 posts)  [Biography] bio
Date Reply #4 on Wed 07 Dec 2016 07:45 AM (UTC)

Amended on Wed 07 Dec 2016 07:48 AM (UTC) by Eloni

Message
My apologies, Mr. Gammon. I think my brain didn't associate that part of your post with a response to my message. I guess it was processed like an automated forum signature, or like an ad and subconsciously ignored.

The first two triggers work fine by themselves. The third trigger is my best attempt to combine the two, and it returns the compile error seen just below it.

------

<triggers>
  <trigger
   enabled="y"
   match="^\&lt;(.*?)hp (.*?)m (.*?)mv (.*?)ac\&gt; (.*?) \&lt;(.*?)\&gt; \&lt;\?\? percent\&gt; $"
   name="TrackInCombatStats"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
  
 print "Detecting IN COMBAT, inCombat == true"
  
 inCombat = true
  
  
 MyHealth = %1
 MyMana = %2
 MyMove = %3
 
 print "%7"

 --print "%5"
 
 FightOrFlight(%7)
 
 
 
 
 

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



------

<triggers>
  <trigger
   enabled="y"
   match="^\&lt;(.*?)hp (.*?)m (.*?)mv (.*?)ac\&gt; (.*?) \&lt;(.*?)\&gt; \&lt;(.*?) percent\&gt; $"
   name="TrackInCombatStats"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
  
 print "Detecting IN COMBAT, inCombat == true"
  
 inCombat = true
  

  
 MyHealth = %1
 MyMana = %2
 MyMove = %3
 
 print "%7"

 --print "%5"
 
 FightOrFlight(%7)
 
 
 
 
 

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


------


<triggers>
  <trigger
   enabled="y"
   match="^\&lt;(.*?)hp (.*?)m (.*?)mv (.*?)ac\&gt; (.*?) \&lt;(.*?)\&gt; \&lt;((.*?)|\?\?) percent\&gt; $"
   name="TrackInCombatStats"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
  
 print "Detecting IN COMBAT, inCombat == true"
  
 inCombat = true
  


  
 MyHealth = %1
 MyMana = %2
 MyMove = %3
 
 print "%7"

 --print "%5"
 
 FightOrFlight(%7)
 
 
 
 
 

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


-----


Compile error
World: world.com
Immediate execution
[string "Trigger: TrackInCombatStats"]:18: unexpected symbol near '?'

[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Wed 07 Dec 2016 10:07 PM (UTC)
Message

 FightOrFlight(%7)


You probably need to quote that. If wildcard 7 is ??? then you now have:


 FightOrFlight(???)


Hence the error message. You should have:


 FightOrFlight("%7")

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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,859 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 FutureQuest]