Recognizing Variables

Posted by Strex on Wed 16 Aug 2017 07:19 AM — 3 posts, 16,590 views.

#0
Hello MUSHers!

So I'm having an issue.
What I'm trying to do is set a trigger to recognize a variable. Only way I can think is by using wildcards in the trigger.
(using picking herbs as an example)

Usually wildcards are used like this:

Trigger:

There are sixty batches of * here.

Send:

Send ("pick %1")

I want it to, rather than picking %1, pick a variable. So say I have a variable @target set to "witan". I want the trigger to see "@target" (in this case "witan")

So the output would be:

There are sixty batches of witan here.

Trigger would be:

There are sixty batches of * here.

And because the target is "witan", it would trigger. And if the target was not witan, it doesn't trigger.

Basically what I want is to script it so that the client recognizes "*" as "@target" or in this example "witan".

I'm not sure if it's possible or if there is another function I need to use. I've looked into it on the MUSHclient website, but know luck as I don't know much of the Lua jargon.

I don't know if any of that makes sense to you guys, but any help would be amazing.

Thanks,
Strex
Australia Forum Administrator #1
That's pretty easy. You check "expand variables". You also need to make it a regexp so you can force the variable to be a capture. Like this:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="^There are sixty batches of (@target) here\.$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Send ("pick %1")</send>
  </trigger>
</triggers>



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





Or, more simply, we don't need a wildcard because we know what the variable is. Thus this would do it:


<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="There are sixty batches of @target here."
   sequence="100"
  >
  <send>pick @target</send>
  </trigger>
</triggers>
Amended on Wed 16 Aug 2017 08:30 PM by Nick Gammon
#2
Thanks!