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
➜ Lua
➜ Recognizing Variables
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Strex
(2 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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>
 |
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 | Top |
|
Posted by
| Strex
(2 posts) Bio
|
Date
| Reply #2 on Sat 19 Aug 2017 03:43 AM (UTC) |
Message
| |
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.
12,627 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top