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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Resetting counter.

Resetting counter.

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


Posted by Chyort   USA  (58 posts)  Bio
Date Wed 02 Jan 2013 10:59 PM (UTC)

Amended on Wed 02 Jan 2013 11:00 PM (UTC) by Chyort

Message
I once again have some free time, and so I am currently in the process of upgrading my Ugly autoquaff/autosip triggers.
They are currently based, entirely, around regular expressions. But I am upgrading them to very limited scripting, and learning a bit of scripting along the way.

(2 match lines randomly selected out of the 150 odd triggers I have currently…)
You report\: (3\d\d)\/(15\d\d) hp (.*?)\/(.*?) mv (.*?) xp\.$
You report\: (1\d\d)\/(19\d\d) hp (.*?)\/(.*?) mv (.*?) xp\.$


Effectively I needed 20 or so triggers per 100 base health.
And each trigger is manually set to quaff the right number of heals.

Brutal… But it required no scripting and after lots of copy/pasting, and hand editing, it did indeed work.

After mucking around in old topics/googling, I managed to get this to work.


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="You report\: (\d+)\/(\d+) hp (.*?)\/(.*?) mv (.*?) xp\.$"
   regexp="y"
   send_to="12"
  >
  <send>xyz = math.floor ((%2-%1)/100)
  Execute ("Auto_Heal " .. xyz)</send>
  </trigger>
</triggers>

What it does is simple enough, it subtracts current health from max health, divides by 100, and then uses math.floor to drop the decimal. Telling me how many heals need to be quaffed.
And with the Execute it should trip the corresponding aliases, and heal up the proper amount. Still somewhat of a brute force approach but by far better than the 150 triggers I have currently.
Effectively turning 150+ triggers into 1 trigger and 20+ aliases.


Now here is the current problem/upgrade, and what I need help with.

Each alias currently quaffs the required potion(s) and then drinks.
Which can be inefficient, sometimes drinking after only 1 potion, instead of the 8 allowed.


2 More examples.
<aliases>
  <alias
   match="Auto_Heal 1"
   enabled="y"
   send_to="10"
   sequence="101"
  >
  <send>quaff heal basket
drink spring</send>
  </alias>
  <alias
   match="Auto_Heal 9"
   enabled="y"
   send_to="10"
   sequence="101"
  >
  <send>quaff heal basket
quaff heal basket
quaff heal basket
quaff heal basket
quaff heal basket
quaff heal basket
quaff heal basket
quaff heal basket
quaff heal basket
drink spring
quaff heal basket
drink spring</send>
  </alias>
</aliases>


What I would like to do is remove the drinks from the Auto_heal aliases entirely (Which will also allow me to simplify them, sometime in the future from 20 aliases into 1), and have the auto_heal aliases execute the “quaff heal basket”
Which in turn would trip another alias “Quaff * *” which sends the quaff command on thru and also has a counter that when it reached 8 would drink spring, and reset to 0

It will also allow me to quaff other potions and have them be added to the counter as well down the road.

Convoluted yes, but it should work, and again limit the scripting required to baby steps.

I have gotten a simple counter alias to work, but every attempt at making it reset when it hits 8 has failed me
Any help here would be appreciated.


<aliases>
  <alias
   match="test"
   enabled="y"
   send_to="12"
  >
  <send>tester = (tester or 0) + 1
  Send ("gt tester is at ", tester)</send>
  </alias>
</aliases>
Top

Posted by Chyort   USA  (58 posts)  Bio
Date Reply #1 on Sun 06 Jan 2013 11:42 AM (UTC)
Message
Managed to figure it out after bouncing my head into it another couple times. Now i just need to update it to suit my exact needs. My brute force auto-sipper/auto-quaffer continues to improve. Yay... :P

Posting this so someone doesn't spend time answering a question i figured out myself, and who knows someone else might use it. *Shrugs*


<aliases>
  <alias
   match="test"
   enabled="y"
   send_to="12"
  >
  <send>if tester == nil then
  tester = 0
  Note ("tester is at ", tester)
elseif tester &lt; 8 then
  tester = tester + 1
  Note ("tester is at ", tester)
elseif tester &gt;= 8 then
  tester = 0
  Note ("tester is at ", tester)
end</send>
  </alias>
</aliases>
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.


11,088 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.