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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  percentage calculating

percentage calculating

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


Posted by Blackmamba   (4 posts)  [Biography] bio
Date Sun 29 Apr 2018 05:46 PM (UTC)
Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 29 Apr 2018 08:49 PM (UTC)
Message
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.

- Nick Gammon

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

Posted by Blackmamba   (4 posts)  [Biography] bio
Date Reply #2 on Sun 29 Apr 2018 09:22 PM (UTC)

Amended on Sun 29 Apr 2018 10:48 PM (UTC) by Nick Gammon

Message

<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.)
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sun 29 Apr 2018 10:52 PM (UTC)
Message
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.

- Nick Gammon

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

Posted by Blackmamba   (4 posts)  [Biography] bio
Date Reply #4 on Sun 29 Apr 2018 11:50 PM (UTC)

Amended on Mon 30 Apr 2018 01:15 AM (UTC) by Blackmamba

Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 30 Apr 2018 05:20 AM (UTC)
Message
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.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Mon 30 Apr 2018 05:36 AM (UTC)
Message

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.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Mon 30 Apr 2018 06:21 AM (UTC)
Message
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.

- 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.


14,972 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]