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

Posted by Eloni on Tue 06 Dec 2016 01:25 PM — 6 posts, 23,649 views.

#0
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.
Australia Forum Administrator #1
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.
Amended on Tue 06 Dec 2016 08:54 PM by Nick Gammon
#2


<*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 '?'

Amended on Tue 06 Dec 2016 09:16 PM by Eloni
Australia Forum Administrator #3
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.
#4
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 '?'

Amended on Wed 07 Dec 2016 07:48 AM by Eloni
Australia Forum Administrator #5

 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")