Gah.. It was supposed to be 'world.addtriggerex', for an extended set of options. However, those last two options are only for defining SendTo and Sequence number (where it appears in the trigger list). They really aren't needed as you noticed. ;)
As for:
world.tell Skills(count) & space(20 - len(Skills))
no obvious errors huh? How about trying to get the 'string' length of the entire array, not just the element we are displaying? Doh! ;) It should be:
world.tell Skills(count) & space(20 - len(Skills(count)))
As for the last item. I had kind of assumed that skills worked a bit like on mine, where you get the skill, but then have to train it a bit after. Or that it used something a bit like the Shadowrun rules where each level of the skill cost (current level + 1) to get the next. I take it that instead you just pay the cost for it and 'bingo' you now have it?
Then things are quite simple. Scripts for aliases don't really care what aliases (or even trigger) calls then. You can use some interesting tricks that involves checking the 'name' parameter that gets passed to them in cases where you want the script to do something different depending on the trigger or alias that called it. In one setup I have, there are about 20 triggers that match on protection and booster spells that all call the same sub and fire off announcements to party members based on which trigger called it.
What this means is that you can simply do this:
Alias: gain *
Label: GainIt
script: Remskill
Send: gain %1
The alias can send text 'and' call scripting at the same time, so you can reuse the same script for both cases. ;)
As for some explaination of how things actually work:
DIM and REDIM - The first of these is used to declare variables. Back in the sane pre-VBScript days you would use something like STATIC, COMMON or SHARED. However this was back when Basic actually knew the difference between a String and an Integer. VBScript however uses what is known as a Variant. This means that every variable is initially declared something like a = V123, where V means variant. If you then do something like a = a + 1, then VBScript looks at the contents and changes it to a = I124 or something like that. This is confusing as hell in some cases, because if you accidentally do something that changes it to S123 (string), and then do a = a + 1, get a = S1231 instead. VBScript basically 'guesses' based on the code you give it what the actually variable type is supposed to be. This can cause some odd bugs... More on REDIM later.
What all of this means is that since VB doesn't know the difference between a string or a number until you use them as such, they removed all the convenient options of doing COMMON a AS INTEGER and replaced it with DIM (this makes no sense to me, but.. it is Microsoft we are talking about. lol) The 'only' type you can declare with DIM that acts like it should are arrays, i.e. DIM a(10), but even then it doesn't have a clue if it should be integers, strings or flying pigs, until you place something into it. The only real advantage being that you can probably place anything you want into each seperate element and the script will only complain if you later try to use it some way that isn't allowed. How this is an advantage I leave to someone else to decide. ;)
In most cases you don't even need DIM, you can simply use a variable when you need it and have VBScript automatically declare it. However, plugins that Mushclient generates include a statement 'OPTION EXPLICIT', which forces the script to reject any variables you try to use that you didn't create using DIM first, so it is a good thing to remember to do, or you will spend a lot of time asking why the script you just placed in a plugin doesn't work right. ;) The joke being that 'option explicit' only checks to make sure a variable is pre-declared. It can't/won't warn you that you failed to give it a value before using it. Exactly why this is useful in a language that doesn't care if the variable has been declared, what it contains, the type you wanted it to be, etc. is something I am still trying to figure out. The only case I can see where it 'may' be helpful is with global variables and since you can't use 'common' or the like to 'explicitly' (note the correct use here) declare the variable as global this is pretty worthless imho.
Now p1 and p2 use a function called 'instr'. This finds the first instance of a string 'in' another string and returns the location it was found. If it finds nothing, then it returns 0. I use these positions to basically save everything before and after the part I am interested in changing in T1 and T3 using 'right' and 'left'. I think you can figure out what they do. ;) I also use these numbers to figure out where in the middle of the original string the actual list is and place that into T2 using 'mid'.
Which brings us to 'split'. This command takes a string, searches it for the string you request and splits the result into and array, while dumping the character(s) you had it look for. One very important thing to note here, it for some reason I don't get (Ask MS about bugs some time) it will create an array that can be resized, but acts like one that has been created with DIM otherwise. What do I mean? DIM variable(number of places) creates a non-resizable array. REDIM creates a 'dynamic' array, which means you can go back later and use REDIM it to a size that is bigger or smaller than it currenty is. I.e. REDIM a(10), then later do REDIM Preserve a(20). The 'Preserve' command is where split arrays fail, if you do a = split("a,b,c,d",",") you get:
a(0) = "a", a(1) = "b", a(2) = "c", a(3) = "d"
However, if you then tell it 'redim preserve a(10), you 'should' get:
a(0) = "a", a(1) = "b" ... a(9) = ""
Instead it ignores 'preserve' and gives a(0) = "" ...
I definitely think that this is a bug that MS just hasn't gotten fixed, but it is something to watch out for, not to mention quite irritating if, unlike with your script, you want to add something to an array that is in alphabetical order. And of course, to make life even more impossible, VBScript has no built in sort command.
Some things in Java and Perl definitely make life easier, but VB is a bit easier to understand, so it tends to be a trade of between sometimes doing things the hard way, but being able to understand someone elses code, or being able to do things the easy way and never touching someone elses code. ;) lol
Hope the last bit of rambling is useful. ;) |