mIRC Homepage
Posted By: Necro Reading from file help/direction - 10/12/14 07:51 AM
i am trying to set up a script that would take a word bank in a file, randomly picking one, then using in a script. Outcome would be a random word raffle. This is what i have so far. Where monkey is i want it to be from file random. What route should i use? i have found $read(file.txt, n) but how would i embed that to work the way i need on the "on *:text:*monkey*:#:?

#random off
on *:text:*monkey*:#: {
if (%flood) { return }
set -u10 %flood On
msg $chan !kraffle open Monkey 20
.disable #random
}
#random end
---------------------------------------------
Word file would be something like

monkey
house
cake
cookie
Posted By: Wims Re: Reading from file help/direction - 10/12/14 08:31 AM
Note that the correct forum to ask for scripting help is the script & popups section.

You can use $() to dynamically evaluate the content of the parameter of an event, you can use $read to pick a random line in a file.

Code:
#random off
on *:text:$($+(*,$read(wordsbank.txt,tn),*):#: {
if (%flood) { return }
set -u10 %flood On
msg $chan !kraffle open $mid($matchkey,2,-1) 20
.disable #random
}
#random end
Posted By: Necro Re: Reading from file help/direction - 10/12/14 08:32 AM
Thank you so much. And sorry for using wrong section.
© mIRC Discussion Forums