triggers and a few questions

Posted by Zack on Fri 24 Dec 2010 09:40 AM — 2 posts, 14,149 views.

#0
Hello, I'm trying to get a trigger to send back a number from a list. Heres the following text. Generic store menu.
[1] Silver blood crafted dagger
[2] soul snatching gloves
[3] torch of flame
[4] chaos butterfly
Ok so I want to buy 4 so I have the trigger match chaos butterfly cuz I always want to buy that. So I put %1 chaos butterfly. In the send box I put%1 because the store has a menu system where you just do buy then it brings up the options so I want it to insert the number of chaos butterfly. It changes so how can I do this? If you need clarification let me know.
Australia Forum Administrator #1
It would look something like this. First an alias to do the "list" command to get the shop goods, which also enables the trigger to match on "chaos butterfly":


<aliases>
  <alias
   match="buy chaos"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("list")

EnableTrigger ( "chaos_butterfly_trigger", true )

</send>
  </alias>
</aliases>


Then a trigger to match on the list, find which number it was, and buy that one. Then it disables itself so it doesn't keep matching if you are trying to buy something else.


<triggers>
  <trigger
   match="^\[(\d+)\] chaos butterfly$"
   name="chaos_butterfly_trigger"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("buy %1")

EnableTrigger ( "chaos_butterfly_trigger", false)

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


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


You may need to amend the trigger slightly if you had more spaces than you showed in your post (or chaos butterfly had caps in it or something). Triggers match on exact text, not approximate text.