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 ➜ General ➜ Using if to decide whether to cure now or later

Using if to decide whether to cure now or later

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


Posted by Faedara   (106 posts)  Bio
Date Thu 25 Nov 2010 12:58 PM (UTC)

Amended on Thu 25 Nov 2010 10:19 PM (UTC) by Faedara

Message
I'm working on my AutoHealerAlpha since AutoSipperAlpha is stable and running, only I've already encountered a problem based on Achaea's "locking" system:

I might want to cure something, but if I'm afflicted by something else that has to be cured first. Therefor I have to prioritize things and queue cures, and I'm not at all sure how queue works in situations like this where certain things need priority over other things.

Right now I have this:

<triggers>
  <trigger
   enabled="y"
   match="^You are paralysed and cannot do that\.$"
   regexp="y"
   sequence="100"
  >
  <send>paralysis = "y"
if herb_bal == "y" and arms == "y" then
   Execute ("outr bloodroot;eat bloodroot")
end</send>
  </trigger>
</triggers>


However, if I need to eat more than one herb because I was afflicted by two different things, then I need it to queue the next herb without interrupting what I'm doing (fighting), while still waiting for herb_bal (herb balance).

Notes you probably don't need but could be helpful anyways:
If your arms are broken then you can't get herbs out of the 'rift' (sorta like a magical bag) and you can't eat them, so I need to put curing the broken arms before trying to eat any herbs. I was thinking that it would set a trigger for the variable herb_bal to 0.5 (balance on but not ready), however I see this conflicting with the herb queue. Also, is it possible to have multiple queue at once?

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 25 Nov 2010 10:33 PM (UTC)
Message
I seem to recall healing and curing systems for Achaea have been done before. Try a search.

The overall approach would be to have a table of the order in which things are to be cured. In your example, curing broken arms would be high up the list.

Then you would go through the table of the correct order (eg. using ipairs) and then for each item, consult another table of things you actually are afflicted with, to see if you need to apply that cure.

Then you might cross-reference the affliction to the cure, to whether or not you have the cure on you, and whether enough time has elapsed, etc. to work out whether to do it now or soon.

- Nick Gammon

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

Posted by Faedara   (106 posts)  Bio
Date Reply #2 on Thu 25 Nov 2010 10:35 PM (UTC)

Amended on Thu 25 Nov 2010 11:08 PM (UTC) by Faedara

Message
I came up with a few different possible ways of doing this, though I still haven't figured out the coding needed.

Timer: Have a timer that checks all the affliction variables and then cures them in a specific order

Example:


<timers>
  <timer enabled="y" second="0.30" offset_second="0.00" >
  <send>if herb_bal == "y" and bound == "n" and arms == "y" and anorexia == "n" and stupidity == "n" then
  if paralysis == "y" then 
    Execute ("outr bloodroot; eat bloodroot")
    herb_bal = "no"
  elseif nausea == "y" then
    Execute ("outr ginseng; eat ginseng")
    herb_bal = "no"</send>
  -- more elseif statements covering the various herb-cured afflictions
  </timer>
</timers>


However this can easily be broken, and with the numerous afflictions and different balances (elixir, herb, and salve), the fact that this will constantly be running feels like it could slow MUSHclient, or at the very least my computer.

Thoughts, opinions, improvements, etc?

While I wait for a response I'll build and test it like this, just to see how effective it'll be.

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 25 Nov 2010 10:41 PM (UTC)
Message
Template:post=9220 Please see the forum thread: http://gammon.com.au/forum/?id=9220.

- Nick Gammon

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

Posted by Faedara   (106 posts)  Bio
Date Reply #4 on Thu 25 Nov 2010 11:08 PM (UTC)
Message
Thanks Nick, I'm looking into it. I still don't understand tables or ipairs yet, so I'll do some research

The eternally clueless <3
Currently looking for a mentor/tutor to help me learn everything about Lua from the ground up. I can't understand 28*41 until I learn what causes 2+2.
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.


16,969 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.