mIRC Homepage
Posted By: Xidus Script problem - 13/06/04 04:46 PM
Im working on a script that makes the bot read what txt people have wrote then when his bname is mentioned he responds with a line made up out of random text
i cant figure out how to make him read the words then put then on seperate lines :P any help is much apetiated
Posted By: Zyzzyx26 Re: Script problem - 13/06/04 04:51 PM
Code:
on *:TEXT:$($+(*,$me,*)):#:  msg $chan $read(Filename.txt)
This *should* read a random line from Filename.txt when the bot's nick is mentioned. Untested.

I hope this is what you're looking for smile

Zyzzy.
Posted By: Xidus Re: Script problem - 13/06/04 04:54 PM
er.... not exactly what im looking for but still usful. I need a command line that reads text people say and puts each word from what they say on diffrent lines so if i said 'hi pooface' it would put in the file :
hi
pooface
so then later i can make him read random words togther to make a sentence smile
Posted By: Zyzzyx26 Re: Script problem - 13/06/04 05:02 PM
well.. im not sure how to do that, but ill try smile

Code:
on *:TEXT:*:#: {
 tokenize 32 $strip($1-)
 write Filename.txt $*
}
This is untested.. i dont know if $* will work in the /write command, but give it a try smile This would put each word in a line in Filename.txt

Posted By: Xidus Re: Script problem - 13/06/04 05:14 PM
doesn't seem to work frown
Posted By: Zyzzyx26 Re: Script problem - 13/06/04 05:18 PM
Mind that that is just the code to put the words in the file (i tested it here, and it works).

To say that random line im not quite sure how to get several random lines from the file.
Posted By: Xidus Re: Script problem - 13/06/04 05:19 PM
er... doesn't work for me it keeps saying * Invalid format: $strip (line 2, bottesting.mrc)
Posted By: Zyzzyx26 Re: Script problem - 13/06/04 05:25 PM
Oh, i see.. then take the $strip out wink

Code:
tokenize 32 $1-
Posted By: tidy_trax Re: Script problem - 13/06/04 05:29 PM
Just take that out altogether, there's no point on /tokenize'ing $1- by 32: on *:text:*:#:{ write file.txt $* }
Posted By: Zyzzyx26 Re: Script problem - 13/06/04 05:31 PM
Oh, that's interesting smile Didnt know about that, thanks!
Posted By: Xidus Re: Script problem - 13/06/04 05:31 PM
wahoo working now laugh thanks a ton. Ok no how can it take some words randomly out of the file to make a sentence laugh
Posted By: tidy_trax Re: Script problem - 13/06/04 05:37 PM
//echo -a $randword(versions.txt) $randword(versions.txt) $randword(versions.txt) $randword(versions.txt) $randword(versions.txt)

is:

now bugs. sorting. /mkdir 72.Fixed

Code:
alias randword {
  tokenize 32 $read($1,n,$r(1,$lines($1)))
  return $eval($ $+ $r(1,$0),2)
}


$randword(file)
Posted By: Xidus Re: Script problem - 13/06/04 05:40 PM
first whats the actal code there? theres so many things plus how could i make it do that when their nick is mentioned
Posted By: tidy_trax Re: Script problem - 13/06/04 05:46 PM
The code is this:

alias randword {
tokenize 32 $read($1,n,$r(1,$lines($1)))
return $eval($ $+ $r(1,$0),2)
}

Put it in remote (alt+r), you could make it say a sentence when your nick is mentioned by:

on *:text:$(* $+ $me $+ *):#:{
var %i = 1, %result
while %i <= amount of words you want in the sentence {
%result = %result $randword(file.txt)
inc %i
}
msg $chan %result
}

The text in red should be changed.
Posted By: Xidus Re: Script problem - 13/06/04 06:00 PM
i get all of it exept where do i put how many words iwant in a sentence?
Posted By: tidy_trax Re: Script problem - 13/06/04 06:07 PM
You put it where i typed amount of words you want in the sentence
Posted By: Xidus Re: Script problem - 13/06/04 06:08 PM
ok so the first ting in alias the second in remotes. how can i amke it do it when people can the name of the bot?
EDIT :
Code:
  
 on *:TEXT:*:#: {
  tokenize 32 $1-
  write words.txt $*
}
on *:text:$(* $+ $me $+ *):#:{ 
  var %i = 1, %result
  while %i 5 {
    %result = %result $randword(words.txt)
    inc %i
  }
  msg $chan %result
}

this be right?
Posted By: tidy_trax Re: Script problem - 13/06/04 06:29 PM
Put all of this in remote, nothing goes in aliases.

alias randword {
tokenize 32 $read($1,n,$r(1,$lines($1)))
return $eval($ $+ $r(1,$0),2)
}
on *:TEXT:*:#: {
write words.txt $*
if $me isin $1- {
var %i = 1, %result
while %i <= 5 {
%result = %result $randword(words.txt)
inc %i
}
msg $chan %result
}
}

Don't change it.
Posted By: Xidus Re: Script problem - 13/06/04 06:33 PM
thanks tons laugh So that will say 5 random words whe nmy name is mentioned?
Posted By: tidy_trax Re: Script problem - 13/06/04 06:40 PM
Yep smile
Posted By: Xidus Re: Script problem - 13/06/04 06:46 PM
wow people here are so nice laugh
Posted By: Xidus Re: Script problem - 13/06/04 06:56 PM
Code:
on *:text:*:#:{ write words.txt $* } 
alias randword { 
  tokenize 32 $read($1,n,$r(1,$lines($1))) 
  return $eval($ $+ $r(1,$0),2)
}
on *:TEXT:*:#: { 
  write words.txt $*
  if $me isin $1- {
    var %i = 1, %result 
    while %i &lt;= 5 { 
      %result = %result $randword(words.txt) 
      inc %i 
    } 
    msg $chan %result
  }
}
  

not working :P when i say b0rk2 ( the guys name ) he doesn't do anyhting
Posted By: tidy_trax Re: Script problem - 13/06/04 06:58 PM
You do not need this line: on *:text:*:#:{ write words.txt $* }, that line also breaks the script, you only need alias randword { and everything below it.
Posted By: Xidus Re: Script problem - 13/06/04 07:04 PM
wahoo its all working now laugh is there a way to make him ignore certain things? ? ?
Posted By: Xidus Re: Script problem - 13/06/04 07:25 PM
any ideas?
Posted By: tidy_trax Re: Script problem - 13/06/04 07:32 PM
If you mean to ignore certain words in the file, then this should work:

alias randword {
tokenize 32 $read($1,n,$r(1,$lines($1)))
var %result = $eval($ $+ $r(1,$0),2)
if $0 > 1 {
while $istok(word1 word2 word3 word4 word5 word6 etc,%result,32) { %result = $eval($ $+ $r(1,$0),2) }
}
return %result
}
© mIRC Discussion Forums