Scripts and VBS file..

Posted by Abas on Sat 04 Sep 2004 02:47 AM — 5 posts, 22,348 views.

#0
Ok. Do I need 1 VBS file for every script I have or can I put all my Scripts or groups of scripts in one VBS file?

If I can store multiple scripts in one VBS file, then how do I access/call a particular script with a trigger?

What does the Label: field and Squence mean in the Trigger setup menu?
USA #1
You can have one script for all your worlds, or one per world.

You have one Subroutine per trigger (or at least, each trigger calls a routine, it doesnt have to be 1 to 1).

You access the subroutines in your script file with the "script" box. You would put the name of the routine there. And it passes three values, the name of the trigger, the line, and an array of the wildcards.
so your sub would look something like this:
sub RoutineName (sName, sLine, aryWild)
'stuff goes here
end sub

And then to call that trigger, you would put RoutineName in the "script" box.

You CAN also for smaller more specific script pieces, put them in the 'send' box of your trigger/alias, and then change the 'send to' box to "script". It eliminates the need for a script file for the most part (there are some exceptions) and allows you to keep your code together, and more modular.


Label is a way to label the trigger (for things like getting and setting values, like enabling/disabling), and Sequence is the sequence that theyre evaluated in. Lower numbers are evaluated first.

So you could make a trigger with seq of 1, for something, and have it not have "keep evaluating" checked, and then in effect, turn off all the other triggers for that specific line.

#2
"sub RoutineName (sName, sLine, aryWild)
'stuff goes here
end sub"

sName: Name of the trigger? I don't remember setting a names for triggers when I make them. Is this variable for MUSHclient use only and we don't have to worry about it?

What is sLine? What is it used for?


"You CAN also for smaller more specific script pieces, put them in the 'send' box of your trigger/alias, and then change the 'send to' box to "script"."

What type of simple scripts can do in the Send box of Triggers/Alias? If I do these simple scripts in the Send box then I don't need to put a
name in SendTo ->Script box?


Can a Trigger send value to 2 variables with SendTo:Variable?

OH, how do I make MUSHclient make a few simple sounds when certain things triggered?


Sorry for all these questions, I am still a newbie. :)




Thanks
Amended on Sun 05 Sep 2004 03:51 AM by Abas
USA #3
To play a sound, there is a "sound" option in the center of the trigger menu. Just find the sound.

No, you cant send to two variables at the same time.
You'll have to use Scripting.
Which brings us to our next topic,

Send To Script.

You can actually put ANY script into the sendto box, but more complex ones can become problematic, but not nessisarily. If youre reusing your code, youre better off putting it in the script file.

But, to set two variables:
Send to Script, then in the send box:
SetVariable "variable1name", "%1"
SetVariable "variable2name", "%1"
will set %1 to both the variables (you can set two values, or whatever). Like %1 and %2 to their respective variables.

MC calls the sub with three arguements passed, the first (sName in my example) is the trigger name, in string format (thats what the s is for), the second is the line matched (the whole line), and the third is an array of the wildcards.
Its not for MC to use, MC doesnt care. You CAN use it (name each trigger differently, then you could check to see which trigger you matched on if you have more than one trigger using a subroutine, or whatnot)
But no, you dont need to worry about them if you dont need them (the line is the same way, since MC used to only pass 9 wildcard values, so if you needed more, youd have to parse scriptside).
Australia Forum Administrator #4
The name of the trigger is the "label" field when you enter it. It is so you can tell which trigger fired if more than one shares the same script routine.

The line is the matching line, in case you want the whole line that caused the trigger to fire.

The sequence is the order in which triggers are tested, the lower the earlier.

Quote:

MC used to only pass 9 wildcard values, so if you needed more, youd have to parse scriptside


If you use "send to script" you can access more than 9 wildcards (which would be pretty unusual) by using something like %<15> as a wildcard substitution in the "send" box. Or, use named wildcards, to keep your sanity.