(Newb) Lua Questions

Posted by Renny on Tue 01 Oct 2013 07:07 AM — 4 posts, 18,791 views.

Canada #0
I'll just preface this by saying that I've been playing mud(s) for a grand total of 2 weeks now, so I don't know a lot about them let alone MUSHclient or lua. That being said I have watched all of the youtube tutorials by Gammon.


1. My current goal is to make a trigger for healing. I have seen a few plugins posted by others but they are not automated.

Here is my current attempt


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Potions"
   match="[*/*hp */*mn */*mv]"
   send_to="12"
   sequence="100"
  >
  <send>require "wait"

function cr ()
  if ((%1/%2) &lt; 0.75) then
    Execute "drink_heal"
    wait.match ("You quaff potion", 10)
  end
end

wait.make (cr)</send>
  </trigger>
</triggers>


I must have something wrong because it tries to drink multiple potions instead of waiting for the string match for 10 seconds? Basically I want to drink a potion to heal but have a failsafe so it doesn't fire off again before drinking the first one.

2. If I were to make a trigger for using Spellup, how would I go about doing this? seeing as there are different timers/messages for each spell.

3. Lets say I download a plugin that someone else has made, and I want to make changes to it/see how it works, how can i see all the different aliases/triggers/scripts that it is made up of? Do I just open the xml with a word editor?

4. What is GMCP? Can GMCP be used with triggers to get data without using regex?

Thanks if anyone can answer some of these questions.
Australia Forum Administrator #1
Quote:

2. If I were to make a trigger for using Spellup, how would I go about doing this? seeing as there are different timers/messages for each spell.


I did a spellup plugin a while back. See if you can search for it here.

Quote:

3. Lets say I download a plugin that someone else has made, and I want to make changes to it/see how it works, how can i see all the different aliases/triggers/scripts that it is made up of? Do I just open the xml with a word editor?


Yes the aliases etc are there in the XML. It is normal to edit it with an editor. If you want you can copy and paste the triggers from the XML into the GUI. Make sure you include the <triggers> ... </triggers> part.

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


Quote:

4. What is GMCP? Can GMCP be used with triggers to get data without using regex?


It is a protocol used by a few MUDs (eg. Aardwolf and the Iron Realms ones) to supply some data in a different format "out of band". It does tend to make writing plugins easier.

Australia Forum Administrator #2
Quote:

I must have something wrong because it tries to drink multiple potions instead of waiting for the string match for 10 seconds? Basically I want to drink a potion to heal but have a failsafe so it doesn't fire off again before drinking the first one.


OK, that trigger waits 10 seconds, however if another prompt line arrives the new trigger does another heal.

What you want to do is remember (in a variable) when you last healed.

Probably something like this:

* One trigger detects the prompt and sends a heal, if more than 10 seconds have elapsed since the last heal. Once it does a heal it saves the current time.

* Another trigger detects the "You quaff potion" line and does something with it.
Canada #3
Thanks for the replies. I'll take a look around for a gmcp tutorial if there are any, otherwise I can look at a few plugins and see what other people have done.

As for the trigger, I didn't realize that it was running a new one. I'll check out how to store the current time in a variable...would it have to be a Mushclient variable?