Accessing wildcards from scripts with out using an external script file

Posted by Jimbob on Thu 05 Mar 2009 02:49 PM — 3 posts, 14,578 views.

#0
I've looked at the script examples for triggers to capture text but I'm not sure how to call the subs with out using an external script file and I don't want to use an exteranl script file for various reasons. For example in vbscript I paste the following example in the send box and select send to script

sub MyTrigger (name, line, wildcards)
  world.Note "Trigger " & name & " matched."
  world.Note "Wildcard 1 was" & wildcards (1)
end sub


This doesn't give me any output, how do I get this to actually output to the world? Thanks
Netherlands #1
That is because you should not place it in the Send box. You need to place it in your scriptfile (See: Configuration->Scripting->Scripts, and then the 'External Script file' bit. Just make a new one, throw your code in that file, and make sure the language is set to VBScript since that is the language you are using.

Finally, adjust your trigger - there should be NOTHING inside the Send box, and the Script field should match the name of the sub (MyTrigger in your example).

After that, it should work.
Australia Forum Administrator #2
Quote:

I don't want to use an exteranl script file for various reasons


In that case, don't put a sub there (that only declares something you can use later). Just go straight into script commands. Also in "send to script" wildcard 1 is %1, wildcard 2 is %2, and so on. Like this:


<triggers>
  <trigger
   custom_colour="4"
   enabled="y"
   match="* arrives from *."
   send_to="12"
   sequence="100"
  >
  <send>
Note "Trigger matched."
Note "Wildcard 1 was %1"
Note "Wildcard 2 was %2"
</send>
  </trigger>
</triggers>


See: http://mushclient.com/pasting for how to copy that into the client.

When testing, I saw:


A stray arrives from the north.
Trigger matched.
Wildcard 1 was A stray
Wildcard 2 was the north