Making trigger/scripts

Posted by Unregistered user on Sun 21 Jan 2001 12:00 AM — 4 posts, 20,691 views.

#0
Hello, hopefully this is an easy question to answer:
I have an alias "autotarg * *" which calls a script to define a trigger. It nearly works but I can not for the life of me figure out how to get the trigger to include what was typed into widlcard (1) and wildcard (2). Here is the script I have in VB.

sub doactiontarget (strAliasName, strOutput, strWildcard)
world.addtrigger "auto",<something1> ,<something2> , 545, custom16, 0, "", ""
end sub

I have tried several variations but don't think I have the format correct. <something1> and <something2> are what I need help on...what would by the syntax to make the trigger do this:

^strWildcard (2) has arrived from the (.*). ###text to trigger.
strWildcard (1) <space> strWildcard (2) ###to send

Any help on this would be great..
-Tidy_bowl
yants@mud.arctic.org
Australia Forum Administrator #1

To get the wildcard contents you index into the strWildcard array - see below.

Also, you cannot have duplicate trigger labels, so I have changed it to generate a unique number, as in:


"auto" & world.GetUniqueNumber

This will automatically label each added trigger like this:


auto5, auto6, auto7 and so on.

Finally, it helps if you check the error status - sometimes it is not obvious what is wrong, for instance the duplicate label problem means the first one would work but not the second one. By checking the error code, and displaying it if non-zero you can see what the problem is. The meaning of the error codes is listed at the front of the supplied file exampscript.vbs and also on the web page:

http://www.gammon.com.au/mushclient/functions.htm

Here is the amended script:


sub doactiontarget (strAliasName, strOutput, strWildcard)
err = world.addtrigger ("auto" & world.GetUniqueNumber, _
      strWildcard (1) , strWildcard (2) , 545, custom16, _
      0, "", "")
if err <> 0 then
  world.note "Error adding trigger, error number = " & err
End If
end sub
#2
I must be retarded, because I am still not getting this.

Here is what I would like to do:
Make an alias that creates a trigger using wildcards that are passed from the alias.

alias: settarget bash Mike
this alias would pass bash and mike to the trigger,
Trigger on text: ^Mike has arrived from the north.
Trigger send to mud: bash mike

I just need to know how to include the contents of the wildcards into the "match_text" and "send_text" parameters.

-Thanks for the speedy reply
-Tidy_bowl
Australia Forum Administrator #3
Ah, OK, I see exactly what you are trying to do now. :)

You basically need to drop in and out of "literal" mode using the ampersand (&) character. Here is the amended script that will do exactly what your example specifies:




  
sub doactiontarget (strAliasName, strOutput, strWildcard)
err = world.addtrigger ("auto" & world.GetUniqueNumber, _
                        "^" & strWildcard (1) & " has arrived from the north", _
                        strWildcard (2) & " " & strWildcard (1), _
                        545, custom16, 0, "", "") 
if err <> 0 then
  world.note "Error adding trigger, error number = " & err
End If
end sub