mIRC Home    About    Download    Register    News    Help

Print Thread
Form script #127858 17/08/05 05:44 PM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
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

Re: Form script #127859 17/08/05 11:40 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Form script #127860 18/08/05 12:11 AM
Joined: Aug 2005
Posts: 9
R
ReK_ Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
You could use a dialog that would not allow Ok to be hit until all the fields are filled.


"So long and thanks for all the fish"
Re: Form script #127861 18/08/05 12:49 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Form script #127862 18/08/05 12:59 AM
Joined: Aug 2005
Posts: 9
R
ReK_ Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
I never saw anything about bots, but yes.


"So long and thanks for all the fish"
Re: Form script #127863 18/08/05 02:54 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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)

Re: Form script #127864 18/08/05 10:14 AM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
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

Re: Form script #127865 19/08/05 01:41 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: Form script #127866 19/08/05 03:08 AM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
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

Re: Form script #127867 19/08/05 07:03 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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 }
}
 

Re: Form script #127868 19/08/05 07:25 AM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
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

Re: Form script #127869 19/08/05 02:44 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
/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.


Invision Support
#Invision on irc.irchighway.net
Re: Form script #127870 20/08/05 12:18 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.