Istok test

By Solitude on Jul 14, 2009

I wanted to try learning something a bit more complicated, so I started looking at token identifiers..$istok looked easiest to me, so..

Just load this into your remotes and whenever someone says whatever you set it to...it, well..replies.

It's very useless, unless you wanna view it as some kind of guise for istok, I don't know.. Is ready for flamer wars

on *:load: {
  set %text.1 $$?="What do you want the script to reply to?"
  set %text.2 $$?="Another text?"
  set %reply.1 $$?="Reply to the text?"
  set %reply.2 $$?="The second reply?"
  set %reply.3 $$?="The third reply?"
  set %reply.4 $$?="The fourth reply.."
}
on *:text:*:*: {
  set %randomreply $r(1,4)
  if ($istok(%text.1 %text.2,$1,32)) {
  if (%randomreply == 1) { msg $chan %reply.1 | halt }
  if (%randomreply == 2) { msg $chan %reply.2 | halt }
  if (%randomreply == 3) { msg $chan %reply.3 | halt }
  if (%randomreply == 4) { msg $chan %reply.4 | halt }
    unset %randomreply
  }
}

Comments

Sign in to comment.
Solitude   -  Jul 14, 2009

lol, yeah. $r(N,N) is the same as $rand(N,N). And thanks, Thelmrac.

 Respond  
TheImrac   -  Jul 14, 2009

$r(1,4) = $rand(1,4), second using slackers code would not work if your reply vars are more than 1 word long. Third you don't use set for the random reply variable use /var as its local and you don't have to worry about a global variable. Lastly,

on *:text:*:*: {
  if ($istok(%text.1 %text.2,$1,32)) { msg $chan  $eval($+(%,reply.,$r(1,4)),2) }
}
 Respond  
MaSOuD   -  Jul 14, 2009

...

 Respond  
Solitude   -  Jul 14, 2009

on *:text:*:*: {
  if ($istok(%text.1 %text.2,$1,32)) { msg $chan $gettok(%reply.1 %reply.2 %reply.3 %reply.4,$r(1,4),32) }
} 

I don't see where that'd look for my variable %randomreply.

on *:text:*:*: {
  set %randomreply $r(1,4)

I am trying to use that to reply depending on what the $r(1,4) sets, not just randomly reply with one of my four %reply.N's.

 Respond  
knoeki   -  Jul 14, 2009
on *:text:*:*: {
  if ($istok(%text.1 %text.2,$1,32)) { msg $chan $gettok(%reply.1 %reply.2 %reply.3 %reply.4,$r(1,4),32) }
}

shorter != better, especially when you're learning... much easier to find bugs when everything is spread out across multiple lines.

 Respond  
slacker   -  Jul 14, 2009
on *:text:*:*: {
  if ($istok(%text.1 %text.2,$1,32)) { msg $chan $gettok(%reply.1 %reply.2 %reply.3 %reply.4,$r(1,4),32) }
}
 Respond  
Solitude   -  Jul 14, 2009

Woops, that was a typing error above all..I was thinking too much about $istok, lol.

 Respond  
blitzz   -  Jul 14, 2009
on *:load {

TO

on *:load: {
 Respond  
Solitude   -  Jul 14, 2009

lmao..

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.