[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Recognizing Variables
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Recognizing Variables

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


Posted by Strex   (2 posts)  [Biography] bio
Date Wed 16 Aug 2017 07:19 AM (UTC)
Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (21,323 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Wed 16 Aug 2017 08:29 PM (UTC)

Amended on Wed 16 Aug 2017 08:30 PM (UTC) by Nick Gammon

Message
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>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Strex   (2 posts)  [Biography] bio
Date Reply #2 on Sat 19 Aug 2017 03:43 AM (UTC)
Message
Thanks!
[Go to top] 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.


1,281 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]