Register forum user name Search FAQ

Gammon Forum

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 ➜ General ➜ Making trigger/scripts

Making trigger/scripts

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


Posted by Unregistered user   (72 posts)  Bio
Date Sun 21 Jan 2001 (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 21 Jan 2001 01:26 PM (UTC)
Message

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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Unregistered user   (72 posts)  Bio
Date Reply #2 on Sun 21 Jan 2001 04:31 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 21 Jan 2001 09:54 PM (UTC)
Message
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

- Nick Gammon

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


15,853 views.

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

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.