From WikiChip
Editing mirc/introduction
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | {{ | + | {{Template:mIRC Guide}} |
− | This article focuses on the very basics of mIRC | + | |
+ | This article focuses on the very basics of mIRC. The target audience is people with no knowledge, or very limited knowledge, of the [[mIRC scripting language]]. | ||
== Where does the code go? == | == Where does the code go? == | ||
− | All | + | All your code, regardless of its type, should go in the Script Editor. To open the script editor type: <Alt>+R. Alternatively, you can go to the Tools Menu -> Script editor. |
− | + | All Events go in the "Remote" tab of the script editor. Popups go in the "Popups" tab of the script editor. Aliases are special, in that they may go in the "Remote" tab, if and only if the code is prefixed with the "alias" keyword, or they can go in the "Aliases" tab, which does not require the "alias" prefix.. | |
[[File:Remote menu.png|center|Remote Editor]] | [[File:Remote menu.png|center|Remote Editor]] | ||
− | |||
− | |||
== The very basics == | == The very basics == | ||
− | + | Before we can do anything productive, we must understand some of the most basic parts of a script. Therefore, let's take a few moments to help familiarize you with the following key components: | |
=== Statements === | === Statements === | ||
− | Every script is composed of one or more statements. A statement describes something that needs to happen. Each statement must go on its own line, or it must be separated by a pipe, which is the '|' symbol. | + | Every script is composed of one or more statements. A statement describes something that needs to happen. Each statement must go on its own line, or it must be separated by a pipe, which is the '|' symbol. For example, the following two are the same: |
− | |||
− | |||
− | |||
− | For example, the following two are the same: | ||
===== Piping ===== | ===== Piping ===== | ||
<pre>statement 1 | statement 2 | statement 3 | statement 4</pre> | <pre>statement 1 | statement 2 | statement 3 | statement 4</pre> | ||
+ | |||
+ | and: | ||
===== Code blocks ===== | ===== Code blocks ===== | ||
Line 29: | Line 26: | ||
statement 3 | statement 3 | ||
statement 4</pre> | statement 4</pre> | ||
− | |||
− | |||
=== What's with the slashes? === | === What's with the slashes? === | ||
− | If you asked any script related question in a help channel, you were probably told to type some code that begin with a forward slash. | + | If you asked any script related question in a help channel, you were probably told to type some code that begin with a forward slash. In order to execute any code from the mIRC editbox (the box where you normally type all of your text), you must prefix the code with at least one forward slash. |
− | |||
− | In order to execute any code from the mIRC editbox (the box where you normally type all of your text), you must prefix the code with at least one forward slash. | ||
− | + | The difference between using one or two forward slash is that with one, the rest of the line is not interpreted as a command, we will discuss this difference later. | |
We usually refer to commands by prefixing them with a slash. | We usually refer to commands by prefixing them with a slash. | ||
=== /echo command === | === /echo command === | ||
− | The most common type of statements are | + | The most common type of statements are [[commands - mIRC|commands]]. Commands are a way to tell mIRC to perform a basic operation. By far the most common command you will be using is the [[/echo command - mIRC|/echo command]]. The /echo command simply prints text to the screen. Every echo command prints on a line of its own. |
Let's dive right into an example! Type the following code into your editbox: | Let's dive right into an example! Type the following code into your editbox: | ||
Line 52: | Line 45: | ||
<pre>Hello World!</pre> | <pre>Hello World!</pre> | ||
[[File:Hello edit.png]] | [[File:Hello edit.png]] | ||
− | |||
− | |||
Recall we said earlier that multiple statements can be combined by using the pipe '|'? Let's print 3 lines to the screen using the echo command and some pipes. Type the following code into your editbox (''Remember to hit the Return or Enter keys from now on''): | Recall we said earlier that multiple statements can be combined by using the pipe '|'? Let's print 3 lines to the screen using the echo command and some pipes. Type the following code into your editbox (''Remember to hit the Return or Enter keys from now on''): | ||
Line 66: | Line 57: | ||
[[File:Fun edit.png]] | [[File:Fun edit.png]] | ||
− | + | You will notice that after the first ''//echo'' command, once we've piped, we do not need to type anymore slashes; this is because mIRC interprets the rest of the statements via the first initial slashes. | |
− | + | If you use one slash here, "Scripting | echo Is | echo Fun!" will be echoed, because the pipes have not been interpreted. We usually refer to this as 'evaluation', we will discuss it later. | |
− | You will notice that after the first ''//echo'' command, once we've piped, we do not need to type | ||
− | If you use one slash here, "Scripting | echo Is | echo Fun!" will be echoed, because the pipes have not been interpreted | ||
− | |||
− | |||
− | |||
− | |||
=== Let's make it into an alias, shall we? === | === Let's make it into an alias, shall we? === | ||
Line 95: | Line 80: | ||
# The two // were removed; we only really need one or two forward-slashes when we want to execute code directly from the editbox. Using slashes in your script editor adds nothing but clutter. | # The two // were removed; we only really need one or two forward-slashes when we want to execute code directly from the editbox. Using slashes in your script editor adds nothing but clutter. | ||
− | |||
# Because we used the '''alias''' keyword, the code must go in the '''Remote Tab''' of the script editor. In order to use that code from the aliases tab, you must remove the "alias" keyword. The rest of the code stays the same. | # Because we used the '''alias''' keyword, the code must go in the '''Remote Tab''' of the script editor. In order to use that code from the aliases tab, you must remove the "alias" keyword. The rest of the code stays the same. | ||
Line 109: | Line 93: | ||
<pre>/fun</pre> | <pre>/fun</pre> | ||
− | '''Note:''' Two forward-slashes will also call it | + | '''Note:''' Two forward-slashes will also call it, but for now, let's only use a single forward-slash |
That should print our text again: | That should print our text again: | ||
Line 125: | Line 109: | ||
statement 3 | statement 3 | ||
}</source> | }</source> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
A few notes about the language limitations: | A few notes about the language limitations: | ||
Line 158: | Line 116: | ||
# <span style="color: #DB0000;">The closing bracket '''must not''' touch anything else</span> | # <span style="color: #DB0000;">The closing bracket '''must not''' touch anything else</span> | ||
# <span style="color: #DB0000;">The closing bracket '''must''' be the last part of the block of code</span> | # <span style="color: #DB0000;">The closing bracket '''must''' be the last part of the block of code</span> | ||
− | |||
− | |||
=== <span style="color: #256B22;">Right Examples</span> === | === <span style="color: #256B22;">Right Examples</span> === | ||
Line 198: | Line 154: | ||
you are noticing the repetitiveness of the ''echo'' command, don't worry, in later examples we will show | you are noticing the repetitiveness of the ''echo'' command, don't worry, in later examples we will show | ||
you tricks on how to get around repeating certain reused commands in your code. | you tricks on how to get around repeating certain reused commands in your code. | ||
+ | |||
== Comments == | == Comments == | ||
Comments are normal, readable text that can be placed inside of your script, and they are a good practice to help better explain to other scripters what's going on in your code. Technically speaking, a comment can say whatever you want it to say, and they are ignored when the program is executed, meaning they have no effect on the actual behavior of the code. | Comments are normal, readable text that can be placed inside of your script, and they are a good practice to help better explain to other scripters what's going on in your code. Technically speaking, a comment can say whatever you want it to say, and they are ignored when the program is executed, meaning they have no effect on the actual behavior of the code. | ||
+ | |||
+ | All comments are preceded by the ''';''' character, which is the semi-colon. | ||
=== Single-line Comments === | === Single-line Comments === | ||
Line 220: | Line 179: | ||
[[File:Fun comment.png]] | [[File:Fun comment.png]] | ||
− | |||
− | |||
=== Multi-line Comments === | === Multi-line Comments === | ||
The second type of comment is the multi-line comment. A multi-line comment can, as its name suggests, span multiple lines. Multi-line comments are enclosed between the '''/*''' & '''*/''' characters. The syntax for a multi-line comment is: | The second type of comment is the multi-line comment. A multi-line comment can, as its name suggests, span multiple lines. Multi-line comments are enclosed between the '''/*''' & '''*/''' characters. The syntax for a multi-line comment is: | ||
− | <source lang="mIRC"> | + | <source lang="mIRC">/* This is |
− | |||
− | /* This is | ||
a multi-line | a multi-line | ||
comment! | comment! | ||
Line 235: | Line 190: | ||
A few notes about the language limitations: | A few notes about the language limitations: | ||
− | # <span style="color: #DB0000;">Text may touch the opening '''/*''' | + | # <span style="color: #DB0000;">Text may touch the opening '''/*'''</span> |
# <span style="color: #DB0000;">The closing '''*/''' must be on a line of its own</span> | # <span style="color: #DB0000;">The closing '''*/''' must be on a line of its own</span> | ||
− | |||
=== <span style="color: #256B22;">Right Examples</span> === | === <span style="color: #256B22;">Right Examples</span> === | ||
Line 255: | Line 209: | ||
the lines are spaced out and the closing parameters are by themselves. These are both | the lines are spaced out and the closing parameters are by themselves. These are both | ||
examples of proper multi-line comment blocks. | examples of proper multi-line comment blocks. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 286: | Line 220: | ||
The */ is not on a line of Its own. | The */ is not on a line of Its own. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Identifiers == | == Identifiers == | ||
− | {{main| | + | {{main|aliases - mIRC}} |
Before we wrap up this tutorial, we need to talk about one last concept: $identifiers. All identifiers have a dollar symbol sigil and have the following syntax: | Before we wrap up this tutorial, we need to talk about one last concept: $identifiers. All identifiers have a dollar symbol sigil and have the following syntax: | ||
Line 327: | Line 233: | ||
Commands seperate their parameters/arguments by space, while identifiers use a comma. | Commands seperate their parameters/arguments by space, while identifiers use a comma. | ||
− | Both commands and identifiers are also | + | Both commands and identifiers are also reffered to as alias(es): you create a custom command/identifier by using the "alias" prefix (in the Remote section of the script editor only) |
− | For example, if we want to print out | + | For example, if we want to print out your current nickname, we would use the following code: |
<source lang="mIRC">//echo -a $me</source> | <source lang="mIRC">//echo -a $me</source> | ||
+ | |||
+ | ==Evaluating/Interpreting== | ||
+ | Here we used two slashes. This indicates to mIRC that it must interpret the line. In the script editor, you don't need any slash, lines are always executed as though two of them were used, the difference only applies when you execute commands from the editboxes in mIRC. | ||
+ | |||
+ | Interpreting or we also say 'evaluating' a line or an expression means the line/expression is processed according to the language's semantic. | ||
+ | Just like commands, identifiers are just functions, evaluating an identifier is the action of calling that function and replacing the identifier with the value returned by the function. | ||
+ | So <source lang="mIRC">//echo -a $me</source>Here the value of your nickname is retrieved by the built-in identifier $me and is inserted in the line; if your nickname is Clickhere, the line becomes: | ||
+ | <source lang="mIRC">//echo -a Clickhere</source> | ||
+ | In general we use the terms evaluating/interpreting for the whole job done on a line, there are a few others things mIRC is doing besides grabbing identifiers's values and replacing them accordingly. | ||
+ | For example, [[Variables - mIRC|variables] are also special and need to be evaluated the same way to produce the value hold by the variable. | ||
+ | Piping, which we saw earlier, is also working because the pipes characters are special and is interpreted in a special way: it's a delimiter for commands on one line. | ||
=== $rand() === | === $rand() === | ||
− | One of the most common operations we use is to generate random numbers. This is where the | + | One of the most common operations we use is to generate random numbers. This is where the [[$rand identifier - mIRC|$rand()]] identifier comes into play; it can generate a random number between a given range. The $rand() has the following syntax: |
<source lang="mIRC">$rand(<low>, <high>)</source> | <source lang="mIRC">$rand(<low>, <high>)</source> | ||
Line 348: | Line 265: | ||
[[File:Random example.png]] | [[File:Random example.png]] | ||
The results that mIRC generates for you will be different than the ones listed above in the screenshot; this is the nature of the $rand identifier. | The results that mIRC generates for you will be different than the ones listed above in the screenshot; this is the nature of the $rand identifier. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== On your own: == | == On your own: == | ||
Line 399: | Line 286: | ||
<span style="color: #009300;">This</span> <span style="color: #FF0000;">is</span> <span style="color: #9C009C;">a</span> <span style="color: #009393;">cool</span> <span style="color: #D2D2D2;">example</span><span style="color: #009300;">.</span> | <span style="color: #009300;">This</span> <span style="color: #FF0000;">is</span> <span style="color: #9C009C;">a</span> <span style="color: #009393;">cool</span> <span style="color: #D2D2D2;">example</span><span style="color: #009300;">.</span> | ||
− | <source lang="mIRC">//echo -a The number | + | <source lang="mIRC">//echo -a The number �42� is even.</source> |
− | |||
− | |||
Will produce the following result: | Will produce the following result: | ||
Line 407: | Line 292: | ||
The number is even. | The number is even. | ||
− | Notice that the number is not showing. That's because it was considered part of the color number '42' | + | Notice that the number is not showing. That's because it was considered part of the color number '42'. Prefixing the color value with a zero will fix this issue: |
<source lang="mIRC">//echo -a The number �042� is even.</source> | <source lang="mIRC">//echo -a The number �042� is even.</source> | ||
Line 414: | Line 299: | ||
The number <span style="color: #FF0000;">2</span> is even. | The number <span style="color: #FF0000;">2</span> is even. | ||
− | |||
− | |||
=== Actions === | === Actions === | ||
Line 449: | Line 332: | ||
By now you should be grasping the basics of mSL, or at the very least beginning to understand how things work. It is highly recommended that you take it upon yourself to play around with the code on your own, in order to see what happens when you change different things around. | By now you should be grasping the basics of mSL, or at the very least beginning to understand how things work. It is highly recommended that you take it upon yourself to play around with the code on your own, in order to see what happens when you change different things around. | ||
− | Next up are the | + | Next up are the [[alias - mIRC|aliases]]. If you feel comfortable with aliases, feel free to move on to [[variables - mIRC|variables]]. |
− | [[Category:mIRC | + | [[Category:mIRC]] |