Getting Started |
Aliases |
/msg and /echo |
Identifiers
If-Then-Else |
Variables |
Pop-Ups |
Remotes
Now we're going to move on to
identifiers, what they are, and how to use them. identifiers are
like extra commands in mIRC, to be used within scripts. They will
always have a $ prefix. You've probably seen some before, $1 is one
that has come up in this course. Now let's take a look at some
useful identifiers:
$1
As we've seen before, this replaces itself with the first word that comes
after the trigger. Put in your aliases /repeat
/msg $chan $1. Now type /repeat hello
in a channel. You'll see <nick> hello,
try another word, /repeat hey will cause
<nick> hey. Now try two words.
You'll see that /repeat How's it going will
yield only <nick> How's. This is
because the identifier only supplies the first word. Similar
identifiers include $2 $1- $2-4 $$1 #$1. Let's take a look:
$2
This will replace itself with the second word. Just like $3 will be
the third, $4 will be the fourth and so on. Put this in your
aliases: /scramble /msg $chan $3 $1 $2.
Type in your channel /scramble I like IWATS.
You'll say in the channel <nick> IWATS I like.
The third word (IWATS) was placed first, the first word (I) was placed
second, and the second word (like) was placed third. You can use any
number you want for this identifier, $4, $5, $50, anything you want.
But for the identifier to be used, you need that many words after the
/trigger.
$1- and $2-4
The identifier $1- will replace itself with the first, and every preceding
word. Change the /repeat command to /repeat
/msg $chan I like $1-. Now type in a channel
/repeat scripting, becuase it's fun.
You'll see in the channel <nick> I like scripting,
because it's fun. Now let's try using a range of words, like
$2-4. Change /repeat to /repeat /msg $chan
$2-4. Now type in a channel /repeat
Hello, it's a nice day today. You'll see <nick>
it's a nice. This is because $2-4 will replace itself with
the second through fourth word, in this case it's a nice.
$$1
This identifier will replace itself with the first word (or second or
third or fifth) just like $1, but the script will only execute if
that word is supplied. For example, make an alias
/myname /msg $chan My name is $1. Now
type /myname Choosh in a channel.
You'll see <nick> My name is Choosh.
Now do just /myname, which will yield
<nick> My name is. But you don't want
this script to execute if you don't supply a name. So go into your
aliases, and change the $1 to $$1 (It will
now look like /myname /msg $chan My name is $$1).
Now type /myname Choosh. The same thing
will happen as before: <nick> My name is Choosh.
Then type just /myname. As you will
see, nothing happens. This is because the $$1 means that that word
has to be present for the script to execute.
#$1
This identifier will replace itself with the first word (or second or
third or fifth), but it will require for that word to start with a # (as
in a channel), or it will return nothing. Make a new alias
/joinchan /join #$1. Now type
/joinchan #scriptIWATS. You'll join the
channel #scriptIWATS. But if you type
/joinchan scriptIWATS (no #) the #$1 will ignore the word, because
it doesn't start with a #. Let's move on to $?
$?
This is a very fun script, because it will put up a box that asks for
input. Make a new alias /ask /echo $chan $?.
Now type /ask. Type
hello in the box that pops up. You'll
see hello as an echo in your window (note: it
won't actually be orange, but that's the color code for this course).
If you don't type anything in the box, you'll see *
/echo: insufficient parameters (line 1, aliases.ini). This
script can be useful in scripts given to other people, and there are some
nifty things you can do with it:
$?="Enter Name"
Change the alias /myname to
/myname /msg $chan My name is $?="Enter Name".
Now type /myname. You'll see a box that
says Enter Name. Type in Choosh.
You'll say to the channel <nick> My name is Choosh.
Now make it a multi-line script (using {} )
/myname {
/msg $chan My name is $?="Enter Name".
/echo $chan $!
}
Type /myname, and enter
Choosh as the name. You'll say to channel
<nick> My name is Choosh. And then
you'll say in just an echo to yourself Choosh.
This is because the $! identifier will return the same thing as the last
$? did.
One last identifier for now before we move on.
$+
This will put two things together, with no space. For example:
/hello /say Hel $+ lo th $+ ere $+ !.
Now when you type /hello, you'll see
<nick> Hello there! with no spaces because
the $+ took them out. This script doesn't do much now, but later on,
you'll see it's useful for combining variables.
All of these identifiers can be used together in scripts
If-Then-Else and Gotos |