RussellReal's Introduction to scripting guide!
Index:
I introduction
II aliases
III read|write from|to text files
IV Variables
V conclusion
I Introduction
Hey, and welcome to RussellReal's first ever tutorial, or better yet, step by step help with scripting, with this guide I'll do my best to make sure you understand everything you're about to see, this tutorial will consist of a little bit of aliases, some easy but powerful while loops, introduction to variables, and how to write and read from a text file.
II Aliases
Aliases are very important for a number of reasons, and one of those ways, is that it allows you to trigger your own scripts, basic knowledge indicates that someone on mIRC can't and will not be able to activate their own on TEXT events. in this case, an alias would come in handy, its the same as an on TEXT event (in a way) but only you can activate it :).
OKAY so lets get started with aliases:
K so here is where you have to think, similar to the /join command or /quit command, after you finish this alias it will be a command like that, so for this tutorials sake, lets make this event say a random number :) Hows that sound? Good? OKAY!
First you want to make the command to start the alias.
[code]/random {[/code]
;there is your first line of your alias, that make the command to activate whatever is after the { (bracket) and do what you like, to activate this you'd type /random into a channel window :)
K so now lets make the random number, then make it message the channel :)
[code]/msg $chan random number is: $rand(1,99)[/code]
;The "/msg" means "Message" and "$chan" means the channel that you activated the script on, and You might not be too familiar with the $rand Identifier, so let me briefly explain it, it gets a random letter number etc from the range you specify within the () if you did $rand(1,2) it will return (at random) 1 or 2. All together, it should be read like this if you were reading the line "Message Channel Random number is: 1-99" and that doesn't seem so hard does it?
Lastly, You'd like to close off the script for every { there is there should be a } to close it off.
[code]}[/code]
;congratulations if you have followed the guide, you have just created your first alias!
III Read|Write From|To a text file.
Okay, this is a very basic, but another very powerful technique to storing information for later use. (Note: If what I tell you here is too basic for what You need, then in the mIRC window, type /help write or /help $read for more detailed information).
;/write:
Okay lets get this outta the way, This to me seems pretty hard for a beginner, to learn now, but Lets give you a shot :) It was one of the first things I learned, and I still use it often.
Basics: Say we want to write everybody's name that says "lol", to a text file to a text file named lol.txt
Okay lets start off, most of anybody knows about on TEXT events, but if you don't lets start you off on a good foot.
on TEXT events follow this syntax: on <User Level>:TEXT:<Match Text>:<Channel>:{
on TEXT events trigger when someone says what is in the <match text>
Okay so lets get started, We arn't getting into user levels in this tutorial, so lets not worry about the <user level> area for now, just use * as the user level.
now so far this is what we have: [code]on *:TEXT[/code]
now to fill in the match text field, lets for this script, make it *lol* the reason "lol" is encased in * (asterisks) is that it means "lol" is before or after anything, or inside anything even. :) so you can be sure you'll catch every lol :) lol
now so far we have this: [code] on *:TEXT:*lol*: [/code]
now to fill in the channel field, for this tutorial, you will use just # that means any channel.
now what we have is this: [code] on *:TEXT:*lol*:#:{ [/code]
______________________________________________________________________
Back to the write command.
the proper way to use write is (in basic terms) /write <text file> <what to write to the file>
so here we have your first like:
[code] on *text:*lol*:#:{ [/code]
;this part just states that when someone says lol in any spot in the line, the script will trigger.
now to add the /write command.
[code]/write lol.txt $nick[/code]
;this "writes to text file lol.txt the nickname of the person who triggered the script"
now to close it off, like I said in the alias tutorial above, for every { "opening bracket" there should be a } "Closing Bracket"
[code]}[/code]
;that closes off the script, congratulations you have just made a write script! :)
________________________________________________________________________
;Read:
Now the cool part, This will be another basic "Just for your knowledge" script.
To read from the text file you just wrote, You might want another event to take place. (although thats not nesessary)
but to start us off, lets revert back to the write section where you learned how to make an event or "check" so lets make it [code]on *:TEXT:!read:#:{[/code]
so here you go, lets start this off.
[code]on *:TEXT:!read:#:{[/code]
;thats just what triggers it, Read like: "When Someone on # (means any channel You are on) says !read, trigger the following commands:"
now you wanna fill in the commands you want, so for this, you want to $read from lol.txt for this script we'll read it at random.
[code]/msg $chan Someone Who said "lol": $read(lol.txt)[/code]
;that is the read part, its read like: "Message Channel Someone who said "lol": Read random line from lol.txt"
now you just gotta close it off
[code]}[/code]
;that closes the script, congratulations you have just read the text file you wrote to :).
IV Variables
These are tricky, (not really trying to scare you lol) They are so easy! You'll be like "OH GOSH! THAT WAS SO EASY!" they just look tricky lol, well here lets start you off. % is the prefix for a variable, any variable will start with that.
we arn't going to get into temporary variables, or dynamic variables, just regular, easy to use, basic variables. Be sure to type /help variables if this doesn't give you a general enough idea.
here you will learn to set, and unset, and read whats inside of the variable. and learn ways to use them. this is yet another powerfull tool.
to set a variable you will have to use /set %<variable name> <whatever to put inside of it>
k so lets start off,