how to store information on variables and how to use them

Posted by Zygote on Thu 26 Sep 2002 06:03 PM — 6 posts, 20,060 views.

#0
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?
Australia Forum Administrator #1
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.
#2
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.
Australia Forum Administrator #3
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.
#4
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?
Australia Forum Administrator #5
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.