mIRC Homepage
Posted By: Ninko Form script - 17/08/05 05:44 PM
Hi there,
How can you make, like a form script, where the script asks a question, records the answer to a .txt file then asks another question etc? Is it possible basically to get the script to only respond to a certain command only when another command has been triggered, eg !cmd2 is ignored untill !cmd1 is triggered.

Thanks


Ninko
Posted By: RusselB Re: Form script - 17/08/05 11:40 PM
Yes all of this can be done, however, you're details are too sketchy for me to be able to code it.

For the first part it would be best if you had the questions in a text file. Then send each line of the text file, one at a time, and wait for a variable to be filled before going to the next question.

As to the second part of your query, the easiest way to do it is to have your script in groups, then when a command is issued you can turn a group on until it's done. If the second command is in the group it won't be recognized unless the group is on.

eg:
Code:
on *:text:!group1*:*:{
if ($2 == on) { .enable #group1 }
elseif ($2 == off) { .disable #group2 }
#group1 off
on *:text:run:#:describe # is running
#group1 end
  


In order for the command 'run' to work (which is located in #group1), someone would have to type !group1 on first.
Posted By: ReK_ Re: Form script - 18/08/05 12:11 AM
You could use a dialog that would not allow Ok to be hit until all the fields are filled.
Posted By: RusselB Re: Form script - 18/08/05 12:49 AM
Yes, if he's entering the answers himself, but if he's looking for a response from someone else, as would be the case if he was running the code on a bot, then dialogs are of no use.
Posted By: ReK_ Re: Form script - 18/08/05 12:59 AM
I never saw anything about bots, but yes.
Posted By: RusselB Re: Form script - 18/08/05 02:54 AM
It wasn't specified as to if this was for a bot or not. Guess we'll have to wait for him to get back to us as to whether it's for a bot or not. (rhyme was unintentional)
Posted By: Ninko Re: Form script - 18/08/05 10:14 AM
Hi there,
The idea I was after, was basically the script asks a question, that person answers, answer is stored, then it asks another question and so on till the end.

Code:
on *:TEXT:!help:*:{
  msg # What is the problem?
  write "C:\Program Files\mIRC\Messages\Messages.txt" $1-
  msg # Contact email address?
  write "C:\Program Files\mIRC\Messages\Messages.txt" $1-
}


I know this isn't right, but I'm a newbie to scripting, thats as much as I know at the moment lol.

Thanks


Ninko
Posted By: RusselB Re: Form script - 19/08/05 01:41 AM
Code:
 on *:text:!help:#:{
var %q = 1
while %q <= $lines(questions.txt) {
.msg $chan You will have one minute to answer each question
.msg $chan $nick $read(questions.txt,%q)
$+(.timer,$nick) 1 60 inc %q
}
}
on *:text:*:#:{
if ($timer($nick)) {
.write -l $+ %q $+($nick,.txt) $1-
}
}


Put your questions into questions.txt using a different line for each question. The person will have one minute (60 seconds) to answer the question before the next question comes up. Each time they use the !help command, the questions will be asked again, with the most recent answers overwriting the previous ones.
Posted By: Ninko Re: Form script - 19/08/05 03:08 AM
Is it not possible to not have to put the questions in a text file, to just put them into the script? Also rather then wait 1 min for the next question to be asked, can it not know that its got an answer with a command in front?

Thanks


Ninko
Posted By: RusselB Re: Form script - 19/08/05 07:03 AM
You could put the questions into your script, and as to the second, the timer could be removed and hve the bot wait until it gets a specific command (eg: !next) before going to the next question.

Personally, I do not like this code, as the only way I could figure out to do it putting the questions into the script required using goto commands
You'll have to make appropriate modifications to the script for the questions, but this is what I came up with
Code:
 on *:text:*:#:{
if ($1 == !help) {
:q
inc %q
goto %q
:1
<question 1>
.write -l $+ %q $+($nick,.txt) $1-
halt
:2
<question 2>
.write -l $+ %q $+($nick,.txt) $1-
halt
:3
<question 3>
.write -l $+ %q $+($nick,.txt) $1-
halt
;and so on for however many questions you have
:%q
}
elseif ($1 == !next) { goto q }
}
 
Posted By: Ninko Re: Form script - 19/08/05 07:25 AM
I'm learning as I go along, I understand more or less most of that script, but what does inc mean and does, that I keep seeing you using?

Thanks


Ninko
Posted By: Riamus2 Re: Form script - 19/08/05 02:44 PM
/help /inc

inc increases the value of a variable.

Also, it's much easier having questions in a text file than in a script for when you want to add more or remove them or edit them.
Posted By: RusselB Re: Form script - 20/08/05 12:18 AM
Which is exactly why I coded for the questions to be in a text file in the first place.

The only downside, that I can think of, to having the questions in a text file rather than the script, is if you want to share the script with someone else, you also have to send the questions.txt file and the script to the person you want to share it with, rather than just the script file..presuming you want to ensure that both you and the person you're sharing the script with have the same questions.
© mIRC Discussion Forums