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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  how to store information on variables and how to use them

how to store information on variables and how to use them

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


Posted by Zygote   (4 posts)  [Biography] bio
Date Thu 26 Sep 2002 06:03 PM (UTC)
Message
A black * lies here.

I want to store %1 to a variable 'target'.
I want an alias 'k' to send the message kill <target> to the mud.

How do i do this?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 26 Sep 2002 11:06 PM (UTC)
Message
Quote:

Message
A black * lies here.

I want to store %1 to a variable 'target'.



<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="A black * lies here."
   name="target"
   send_to="9"
   sequence="100"
  >
  <send>%1</send>
  </trigger>
</triggers>


Quote:

I want an alias 'k' to send the message kill <target> to the mud.



<aliases>
  <alias
   match="k"
   enabled="y"
   expand_variables="y"
  >
  <send>kill @target
</send>
  </alias>
</aliases>


You can select the examples above, and copy and paste them into the triggers/aliases configuration windows.

- Nick Gammon

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

Posted by Zygote   (4 posts)  [Biography] bio
Date Reply #2 on Fri 27 Sep 2002 08:07 AM (UTC)
Message
Ok its works, but i how to make that variable so that multiple triggers can refer to it?

So that different triggers would save their info in it and you could use the latest content with the 'k' alias.
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Fri 27 Sep 2002 09:28 PM (UTC)
Message
The simple approach is to stick with one trigger and use a regular expression to match on more than one thing, then the basic idea still works. For example:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^A (?:black )?(.*?) (lies here|attacks you|lunges for you)\.$"
   name="target"
   regexp="y"
   send_to="9"
   sequence="100"
  >
  <send>%1</send>
  </trigger>
</triggers>



This would match on:


A black something lies here.
A black something lunges for you.
A black something attacks you.
A something attacks you.


However if that won't work have multiple triggers call a simple script, like this:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="A black * lies here."
   script="SetTargetVariable"
   sequence="100"
  >
  </trigger>
</triggers>


Then add a script to your script file, or make a separate script file, like this:


sub SetTargetVariable (sName, sLine, wildcards)
world.SetVariable "target", wildcards (1)
end sub


This script sets the variable "target" to the contents of the first wildcard. You can then have lots of triggers like the above that call the same script. Make sure you enable scripting (language VBscript) and select that file as your script file.

- Nick Gammon

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

Posted by Zygote   (4 posts)  [Biography] bio
Date Reply #4 on Wed 02 Oct 2002 08:51 AM (UTC)
Message
it complains like this when it to that scripting section:

the following erros were encountered when attempting to link to script subroutines. The missing subroutines will not be called.

There was a problem in script file "U:\mush\scripts\settargetvariable.vbs":

The trigger subroutine named "target" could not be found.

I probably messed something up. Is this even the right place to put it?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 04 Oct 2002 12:55 AM (UTC)
Message
Did you copy and paste the exact trigger from above? The script can be in an file name, as long as the file name is that set in the scripting configuration tab.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


13,206 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 HostDash]