Welcome to Level 2 Class 3.
Today we are going to continue
with what we were working on
in the last class.
We are going to build a script,
that will listen for a question.
The choose a silly response.
This script today will have
different MODULES, that will work
together to create the result.
A module is a part of a script
that may be called by different
parts of the script. This is very
handy if you have to have various
parts of a script do the exact same thing.
First lets build our Module.
For this example I will call it mod.one
This module, will chose at random
two nicks from the channel, and
make sure that the nicks do not
match you or each other..
This module uses RETURN
/return [value]
Halts a currently executing script and
allows the calling routine to continue
processing. You can also optionally return
a value which will be stored in the $result
identifier. The $result can then be used in
the calling routine.
Please add this 'module' to your remote.
ALIAS MOD.ONE {
set %me $me
set %loop.test 0
set %n.total $nick(%chan,0)
:loop.a
inc %loop.test 1
set %ran $rand(1,%n.total)
set %ran2 $rand(1,%n.total)
set %nick $nick(%chan,%ran)
set %nick2 $nick(%chan,%ran2)
if ( %loop.test = 4 ) { goto EXIT }
if (%nick == %me) { goto loop.a }
if (%nick2 == %me) { goto loop.a }
if (%nick == %nick2) { goto loop.a }
return
:exit
echo 4 -a ERROR: Script Halted
halt
}
PLease let me know when you have this added.
Now, Lets add this Alias to test our module.
After you have added it,
please test it in the lab.
Alias Test {
mod.one
msg $chan %nick hit %nick2
}
Ok.. At this time, lets take a break.
If you have any questions concerning
todays material now is the time to ask.
If not.. take a 5 minute break.
Ok.. lets add this script to the remote,
and test it in the lab. Let me know
when you have added the script so I can
test it. Add it to the same script
that has the mod.one alias.
on 1:TEXT:yournick where*:#:{
set %chan $chan
:loop.b
mod.one
if (%nick == $nick) { goto loop.b }
if (%nick2 == $nick) { goto loop.b }
If ($parm1 != $me) { halt }
If ($parm2 != where) { halt }
set %r $rand(1,5)
IF (%r == 1 ) {
msg $chan $nick Ask %nick and %nick2 }
IF (%r == 2 ) {
msg $chan Not here $nick }
IF (%r == 3 ) {
msg $chan At %nick $+ 's house with %nick2 }
IF (%r == 4 ) {
msg $chan At a party with %nick and %nick2 }
IF (%r == 5 ) {
msg $chan Hey %nick hit $nick }
}
This script first calls on the mod.one to give
us to different nicks randomly, other than yourown.
In the part of the script...
if (%nick == $nick) { goto loop.b }
if (%nick2 == $nick) { goto loop.b }
the script makes sure that the random nicks
chosen do not match the nick of the person
who triggered this event.
In "if ($parm1 != $me) {halt} the script
determines if you are being spoken to, if
your nick is not the first word, it halts
the script.
If the second word, is NOT "WHERE", then the
script is halted.
In other words, the script is looking for the
first two words in a text to be <yournick> where
If those are not the first two words in the text,
the script is halted.
If the first two words in the text were
<yournick> where, the script continues,
and chose a random number between 1 and 5.
Using the numbers between 1 and 5 the script
returns a response, sometimes using the random
nicks that were chosen using mod.one.
Ok.. NOW For you your HOMEWORK assignment <grin>
Please have this script ready to turn in at
the beginning of next weeks class.
Write ONE Script that will look for
<YOURNICK> where
<YOURNICK> when
<YOURNICK> who
This script must be able to give
10 different silly answers for each question.
Two of the questions must call a module.
One of the questions must not call a module.
In at least 4 responses to each question,
you must use at least one RANDOM nick from
the channel. In 3 of the response to a
questoin, you must use 2 RANDOM nicks.
The random nicks can not match each other
and the random nicks can not match the
person who asked the question.
EXTRA BONUS:
See if you can make it so that if when
someone asks the same question 2 times
in a row, they can NEVER get the same
response. (Think about this, you can do it)
We will now open the channel to question, and
if you have no questions we will see you next week.
Today we are going to continue
with what we were working on
in the last class.
We are going to build a script,
that will listen for a question.
The choose a silly response.
This script today will have
different MODULES, that will work
together to create the result.
A module is a part of a script
that may be called by different
parts of the script. This is very
handy if you have to have various
parts of a script do the exact same thing.
First lets build our Module.
For this example I will call it mod.one
This module, will chose at random
two nicks from the channel, and
make sure that the nicks do not
match you or each other..
This module uses RETURN
/return [value]
Halts a currently executing script and
allows the calling routine to continue
processing. You can also optionally return
a value which will be stored in the $result
identifier. The $result can then be used in
the calling routine.
Please add this 'module' to your remote.
ALIAS MOD.ONE {
set %me $me
set %loop.test 0
set %n.total $nick(%chan,0)
:loop.a
inc %loop.test 1
set %ran $rand(1,%n.total)
set %ran2 $rand(1,%n.total)
set %nick $nick(%chan,%ran)
set %nick2 $nick(%chan,%ran2)
if ( %loop.test = 4 ) { goto EXIT }
if (%nick == %me) { goto loop.a }
if (%nick2 == %me) { goto loop.a }
if (%nick == %nick2) { goto loop.a }
return
:exit
echo 4 -a ERROR: Script Halted
halt
}
PLease let me know when you have this added.
Now, Lets add this Alias to test our module.
After you have added it,
please test it in the lab.
Alias Test {
mod.one
msg $chan %nick hit %nick2
}
Ok.. At this time, lets take a break.
If you have any questions concerning
todays material now is the time to ask.
If not.. take a 5 minute break.
Ok.. lets add this script to the remote,
and test it in the lab. Let me know
when you have added the script so I can
test it. Add it to the same script
that has the mod.one alias.
on 1:TEXT:yournick where*:#:{
set %chan $chan
:loop.b
mod.one
if (%nick == $nick) { goto loop.b }
if (%nick2 == $nick) { goto loop.b }
If ($parm1 != $me) { halt }
If ($parm2 != where) { halt }
set %r $rand(1,5)
IF (%r == 1 ) {
msg $chan $nick Ask %nick and %nick2 }
IF (%r == 2 ) {
msg $chan Not here $nick }
IF (%r == 3 ) {
msg $chan At %nick $+ 's house with %nick2 }
IF (%r == 4 ) {
msg $chan At a party with %nick and %nick2 }
IF (%r == 5 ) {
msg $chan Hey %nick hit $nick }
}
This script first calls on the mod.one to give
us to different nicks randomly, other than yourown.
In the part of the script...
if (%nick == $nick) { goto loop.b }
if (%nick2 == $nick) { goto loop.b }
the script makes sure that the random nicks
chosen do not match the nick of the person
who triggered this event.
In "if ($parm1 != $me) {halt} the script
determines if you are being spoken to, if
your nick is not the first word, it halts
the script.
If the second word, is NOT "WHERE", then the
script is halted.
In other words, the script is looking for the
first two words in a text to be <yournick> where
If those are not the first two words in the text,
the script is halted.
If the first two words in the text were
<yournick> where, the script continues,
and chose a random number between 1 and 5.
Using the numbers between 1 and 5 the script
returns a response, sometimes using the random
nicks that were chosen using mod.one.
Ok.. NOW For you your HOMEWORK assignment <grin>
Please have this script ready to turn in at
the beginning of next weeks class.
Write ONE Script that will look for
<YOURNICK> where
<YOURNICK> when
<YOURNICK> who
This script must be able to give
10 different silly answers for each question.
Two of the questions must call a module.
One of the questions must not call a module.
In at least 4 responses to each question,
you must use at least one RANDOM nick from
the channel. In 3 of the response to a
questoin, you must use 2 RANDOM nicks.
The random nicks can not match each other
and the random nicks can not match the
person who asked the question.
EXTRA BONUS:
See if you can make it so that if when
someone asks the same question 2 times
in a row, they can NEVER get the same
response. (Think about this, you can do it)
We will now open the channel to question, and
if you have no questions we will see you next week.