mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2005
Posts: 21
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Aug 2005
Posts: 21
Hey i was wondering if there is anybody willing to teach me better at mirc scripting thru msn if so give me a pm or email @ antianarchist666@hotmail.com thanks much appreciated blush

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Best way to learn mIRCscripting is by doing it yourself and reading the help file over and over. Then by going trough other peoples code you can learn optimalisation tricks.


$maybe
Joined: Dec 2002
Posts: 29
H
Ameglian cow
Offline
Ameglian cow
H
Joined: Dec 2002
Posts: 29
There are some simple ways to get started. First make very basic uses of the abilities available (aliases, popups, events). Aliases will be the best way to start out.

Here is a very easy example alias. I will comment it to give you better understanding of how it works.

"reverse alias" : this alias will take inputted text in the format /rev [text] and reverse it.

example uses:
/rev ab cd ef g : <user> g fe dc ba
/rev hello world! : <user> !dlrow olleh

alias rv {

/*
This first step is taking the input ($1-) and replacing any spaces ($chr(32) with the blank character ($chr(160) so that the entire input can be manipulated without the spaces causing us problems
*/

var %fullstring = $replace($1-,$chr(32),$chr(160))

/*
Next we take the length of the input
*/

var %stringlength = $len($1-)

/*
%stringfixed will be our "working" variable, where we will be building our final output
*/

var %stringfixed

/*
This is a while statement. As long as the condition to the right of "while" is true, the code within the statement (between the {}s) will be executed. Here, as long as the length of the original string remains positive, we will keep taking a character off the end of it, and adding it to the end of the working variable (%stringfixed). At the end, I'll show you the step-by-step of what this is doing for clarity.
*/

while (%stringlength > 0) {

/*
This is the guts of the alias. It says "set the working variable as it was, plus the next character left on the original input."
*/

%stringfixed = $+(%stringfixed,$mid(%fullstring,%stringlength,1))

/*
Here, we are decreasing the length measurement of the original string by one, so that as we deplete the available characters from it, the number of times the loop goes will become less
*/

dec %stringlength
}

/*
All of the characters have been used, and the while loop had finished. Now we simply switch the blanks for spaces, and send our result.
*/

return $replace(%stringfixed,$chr(160),$chr(32))
}

/*
The above simply did the work and sends us the result as an identifier. We use the alias below to actually say the result. This is useful, because we might want to use the ability to reverse something within another script, or only in part of a statement.
*/

alias rev { say $rv($1-) }

Step-by-step explanation:

/rev hello world

%fullstring becomes "hello world"
%stringlength becomes 11

The while statement starts out "while 11 is more than 0" do whatever. Since 11 is more, it does this:
%stringfixed becomes d. This is because it adds what is already in %stringfixed (nothing) and then $mid(%fullstring,%stringlength,1) together. That is saying look at the full input (the %fullstring) and go to the 11th place and give us one character at that place. That returns d.
Then %stringlength gets knocked down by 1 to 10.

10 is still more than 0, so it goes again.
%stringfixed becomes "dl" because it already was d, and the next $mid pulled gives the l (go to place ten, and give us one character). Now, you notice the $+() surrounding the %stringfixed,$mid(...). This is a handy way for us to take two or more units, and place them together without a space. If you have ab bc cd de, putting them in a script as is will have spaces between them. $+(ab,bc,cd,de) will give us abbccdde.

This will continue, %stringlength at 9, %stringfixed dlr.
%stringlength 8
"%stringfixed dlro"
%stringlength 7
"%stringfixed dlrow"
%stringlength 6
"%stringfixed dlrow "
%stringlength 5
"%stringfixed dlrow o"
%stringlength 4
"%stringfixed dlrow ol"
%stringlength 3
"%stringfixed dlrow oll"
%stringlength 2
"%stringfixed dlrow olle"
%stringlength 1
"%stringfixed dlrow olleh"

Now %stringlength has become 0. Since it is not more than 0, it will not do the loop any more. Instead it will proceed down the page to the next command in the alias. That is to return the result. That done, the alias hits the end of itself, and it is done.

Now, I realize that this is a very simple thing to do, you are saying to yourself. It is! But that's the basic start of doing more complex things. You learn how to do a simple thing like this, then you learn how to do a more complex thing: by doing a number of simple things together.

I hope it helps, scripting is a great way to expand your understanding of things.

Joined: Mar 2005
Posts: 212
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Mar 2005
Posts: 212
chat.ircx-city.net #r00t

Last edited by NeUtRoN_StaR; 31/12/05 10:05 PM.

Link Copied to Clipboard