Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ multi line number capturing, adding and displaying

multi line number capturing, adding and displaying

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


Posted by TheExile   (12 posts)  Bio
Date Fri 30 Sep 2011 01:46 PM (UTC)

Amended on Fri 30 Sep 2011 01:47 PM (UTC) by TheExile

Message
Alright this is completely beyond my limited abilities and I have no idea where to start with this.

I'm trying to make a trigger that will capture a number from a random amount of lines from 1 all the way upto a max of 10.

All after the initial line all of the lines look the same

You hold up both hands while screaming out in rage, a huge black ball of ki quickly appears above you. The ball continues to expand as red bolts of lightning crackle around 
it, with a sudden jolt you throw the massive Revenge Death Ball at Fire Spirit.
...your revenge death ball pushes Fire Spirit into the ground!
[========]=-=[49824]
...your revenge death ball pushes Fire Spirit into the ground!
[======--]=-=[50034]
...your revenge death ball pushes Fire Spirit into the ground!
[=====---]=-=[50187]
...your revenge death ball pushes Fire Spirit into the ground!
[=====---]=-=[50082]
...your revenge death ball pushes Fire Spirit into the ground!
[====----]=-=[50221]


The bar displayed before =-= is the muds 'health bar' for the mob your fighting. Anyway what I'd like to do is make a trigger that will read the damage done with each hit add them together and display them at the end of the attack as the total damage done.

Someone else on the mud did this with Cmud for his races multihit attack.

#TR {As the ball reaches its full potential, you snap you fingers as the Genocide rains down upon (*).} {genoDmg=0;target=%1}
    #TR {^...your genocide hits {@target}!$} {}
    #COND {=-=~[(%d)~]} {genoDmg=(@genoDmg+%1)}
    #STWIN { Target: @target %cr Genocide hit for a total of @genoDmg}


This is probably a lot to ask and probably more complicated then it already seems but I figured I'd try my luck and ask anyway.

Thanks in advance no matter the results.
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 02 Oct 2011 12:49 AM (UTC)
Message
Template:faq=37 Please read the MUSHclient FAQ - point 37.


That should get you started, if not please specify what went wrong (and post what you did so far).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by TheExile   (12 posts)  Bio
Date Reply #2 on Sun 02 Oct 2011 07:48 PM (UTC)
Message
Alright, here is what I've come up with so far.

<triggers>

<!-- trigger to match start of inventory -->

  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^\.\.\.your revenge death ball pushes."
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
multihit_table = {}
EnableTrigger ("multihit_line", true)
EnableTrigger ("multihit_stopper", true)
</send>
  </trigger>

<!-- trigger to match an inventory line -->

  <trigger
   keep_evaluating="y"
   match=".[(.*?)]$"
   name="multihit_line"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
  table.insert (multihit_table, "%1")
  </send>
  </trigger>

<!-- trigger to match end of inventory -->
  
  <trigger
   match="(^&lt;)|^$"
   name="multihit_stopper"
   regexp="y"
   send_to="12"
   sequence="40"
  >
  <send>
EnableTrigger ("multihit_line", false)
EnableTrigger ("multihit_stopper", false)

-- in case no table yet
multihit_table = multihit_table or {}

table.sort (multihit_table)

print ("Your Multihit Damage:")

for _, item in ipairs (multihit_table) do
  print (item)
end -- for

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

</muclient>


It works except what it does is it only picks up and displays the last hit of the attack instead of the whole thing. I thought that the stopper might be ending it to soon but changing what disabled the triggers didn't seem to matter. Is there anyway to fix this and get it to actually add the numbers together?

I tried using a variable setup I'm using in another set of triggers because it adds up numbers but I just cannot get multi-line triggers to work at all.

Thanks.
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 03 Oct 2011 02:17 AM (UTC)

Amended on Tue 04 Oct 2011 10:05 PM (UTC) by Nick Gammon

Message
I added line colouring to show what was happening. A few minor problems, fixed as so:


<triggers>

  <trigger
   group="battle"
   match="&lt;*"
   name="multihit_stopper"
   send_to="12"
   sequence="40"
  >
  <send>
EnableTrigger ("multihit_line", false)
EnableTrigger ("multihit_stopper", false)

if not multihit_table or next (multihit_table) == nil then
  print ("No damage.")
else
  table.sort (multihit_table)

  print ("Your Multihit Damage:")

  local total = 0

  for _, item in ipairs (multihit_table) do
    print (item)
    total = total + tonumber (item)
  end -- for 

  print ("Total damage =", total)

end -- if some damage


multihit_table = {}  -- for next time
  </send>
  </trigger>

  <trigger
   custom_colour="1"
   group="battle"
   keep_evaluating="y"
   match="\[(\d+)\]$"
   name="multihit_line"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
table.insert (multihit_table, "%1")
  </send>
  </trigger>

  <trigger
   custom_colour="3"
   enabled="y"
   group="battle"
   keep_evaluating="y"
   match="^\.\.\.your revenge death ball pushes."
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
multihit_table = multihit_table or {}
EnableTrigger ("multihit_line", true)
EnableTrigger ("multihit_stopper", true)
</send>
  </trigger>

</triggers>


Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


One problem was that you had "your revenge death ball pushes" resetting the table to empty, so naturally it only remembered the last one.

Now with this test data:



You hold up both hands while screaming out in rage, a huge black ball of ki quickly appears above you. The ball continues to expand as red bolts of lightning crackle around 
it, with a sudden jolt you throw the massive Revenge Death Ball at Fire Spirit.
...your revenge death ball pushes Fire Spirit into the ground!
[========]=-=[49824]
...your revenge death ball pushes Fire Spirit into the ground!
[======--]=-=[50034]
...your revenge death ball pushes Fire Spirit into the ground!
[=====---]=-=[50187]
...your revenge death ball pushes Fire Spirit into the ground!
[=====---]=-=[50082]
...your revenge death ball pushes Fire Spirit into the ground!
[====----]=-=[50221]
<15 hp>


I get:


Your Multihit Damage:
49824
50034
50082
50187
50221
Total damage = 250348


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by TheExile   (12 posts)  Bio
Date Reply #4 on Mon 03 Oct 2011 03:20 AM (UTC)

Amended on Mon 03 Oct 2011 05:53 AM (UTC) by Nick Gammon

Message
Thank you very much for the help, it works perfectly!

match="\[(\d+)\]$"


This somehow eluded me when I was reading through the various help files.

[EDIT] Escaped backslashes to show what there really was there before.
Top

Posted by 1313Jr1313   (1 post)  Bio
Date Reply #5 on Tue 04 Oct 2011 09:26 PM (UTC)
Message
wow, i recently had a similar problem but i guess many solutions are universal, lol.
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.


20,737 views.

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

Go to topic:           Search the forum


[Go to top] top

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