percentage calculating

Posted by Blackmamba on Sun 29 Apr 2018 05:46 PM — 8 posts, 26,038 views.

#0
so i have
^(\w+)\'s mana stands at (\d+)\/(\d+)\.$

to send

if math.floor (%2/%3 * 100) < 50 then
Send("slap @target")
end

sending to the script with expand variables box checked and regular expression checked

However nothing is firing ...what is wrong with my code
Australia Forum Administrator #1
First, please post the whole trigger, as described here:

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.


Second, please copy and paste a line from the MUD that you think should fire the trigger.

Thanks.
#2

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="bodyscan"
   match="^(\w+)\'s mana stands at (\d+)\/(\d+)\.$"
   name="crown_contemplate"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if math.floor (%2/%3 * 100) &lt; 50 then
Send("slap @target")
end
</send>
  </trigger>
</triggers>



command: contemplate Jack

output:


Jack's mana stands at 9250/9300. 99.462365591398
Jack is operating in normal time.
Jack is not insane.


I would like the trigger to fire off the first line (Jack's mana stands at 9250/9300.)
Amended on Sun 29 Apr 2018 10:48 PM by Nick Gammon
Australia Forum Administrator #3
The line from the MUD is:


Jack's mana stands at 9250/9300. 99.462365591398


It ends in 99.462365591398 which you haven't allowed for in the trigger.

If you omit the final "$" it will match.
#4
Nick Gammon said:

The line from the MUD is:


Jack's mana stands at 9250/9300. 99.462365591398


It ends in 99.462365591398 which you haven't allowed for in the trigger.

If you omit the final "$" it will match.


The 99.462365591398 is an echo from the script, not from the game itself. Does that change anything?

And what boxes on the right should I be checking?

This might better explain the situation:https://pasteboard.co/HiW2j6n.png
Amended on Mon 30 Apr 2018 01:15 AM by Blackmamba
Australia Forum Administrator #5
Blackmamba said:

The 99.462365591398 is an echo from the script, not from the game itself. Does that change anything?


I need to see exactly what arrives from the MUD, to judge whether or not the trigger matches.
Australia Forum Administrator #6

Jack's mana stands at 9250/9300. 99.462365591398


In this particular case, of course, he doesn't have less than 50% mana. If you edit the trigger you can see how many times it has fired.
Australia Forum Administrator #7
Blackmamba said:

The 99.462365591398 is an echo from the script, not from the game itself. Does that change anything?


As a general rule, triggers don't match lines which are from a script. So your statement that it is an echo from a script (and your script doesn't echo anything) means there is more here than meets the eye.