How to start
This tutorial is supposed to give an introduction into scripting in mIRC. It will explain the so-called Scripts-Editor and it's functions, followed by a little example. At the end it will give some hints about how to debug a script.
Contents
The Remote Editor
If you want to begin to script in mIRC, you need to open the Script-Editor. You can do it in two ways: pressing "Alt + R" or with mIRC's menubar (Tools -> Scripts Editor).
If you are using a premade script (for example nnscript), you will probably see a lot of code. Note that it is difficult to implement own scripts in such a premade one, as functions could interfere (if you want to change mIRC's default output for example).
At first, you should open a new remote file. To do it, click on File -> New (see picture below).
Note that your script files will be saved automatically; all you need to do is pressing 'Ok'.
The next part is about the five different tabs of mIRC's Scripts Editor:
Aliases-Tab
Basically, you do not need to use aliases.ini (that you can edit using this tab). Usually, if you want to add a new alias, it would look like:
alias moo { return moo }
in your 'Remote-Section' of the editor (the one that's active after pressing Alt + R). You can add the same alias in your Aliases-Section:
moo { return moo }
Notice that you don't need to write 'alias' infront of the new alias. Note that you cannot add events in this section.
Popups-Tab
Again you do not need to use this section. It's the same as using the menu alias in the remote section. Usually, there will be some menus added in this section (for example your nicklist-menu).
Remote-Tab
This is the "maintab". Every script is supposed to be saved in here.
Note that you should not have two same events in one file, as only the first matching one will be triggered. Example:
; will be triggered on *:Text:*:*: { echo moo } ; will never be triggered on 10:Text:*:*: { echo maa }
; will be trigger for level 10 on 10:Text:*:*: { echo maa } ; will be triggered for all but level 10 on *:Text:*:*: { echo moo }
So if you aren't sure whether it will work or not, just use another (a new) file (look above to see how to make a new file).
The following script will trigger on every "!moo" in every channel and response with "moo00oo00":
on *:TEXT:!moo:#: { msg $chan moo00oo00 }
This would look like:
If you are scripting something more complex, you want to use the "{}"-button in the upper right corner (see below).
If you've pressed it and nothing happended, everything is ok (note that it doesn't mean that your scripts will work, just that there is no obvious bracket mistake (mIRC just counts the open and closed brackets)). If something's wrong, you will get the following popup:
Users-Tab
In this file your userlist is saved. You don't need to edit it manually, as there are aliases to do so. See auser, guser and ruser.
Variables-Tab
All your global variables are saved in here. Again, you don't need to edit it manually, as you can use set, unset or unsetall.
How to debug
After you've written some lines and you've tested it, you will most likely notice, that it doesn't do what you expect it to do. The next step is to debug your script. At first take a look at your Status Window and check for error messages. If there are any, search for these errors in your script and correct them. If they aren't any, you should add echo's in your script to see where it stops to work. For example:
on *:TEXT:*:*: { if (%moo) { echo -a we are here } elseif (%moo2) { echo -a we are here 2 } echo -a after the if clauses }
With this method, you can exactly see where it stops to work and correct this part.
Note You cannot trigger on text, on notice, on action... events by yourself, for that you will need someones help or another client or multiserver (/server -m ...) to test them.