This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Pausing for user input?

Old posts that have not been replied to for several years.
Locked
j
jestrix

Post by jestrix »

Is there a way to make a script pause for user input? basically I want to create a menu-driven (through dcc) script.

The script would be started with a CONNECT command, then handed over to the menu proc via CONTROL. Hopefully, something like:

1. Go to A
2. Go to B
3. Go to C
----
Your selection?
----
could be created, then when the user types 1, another menu would come up, etc etc.

how do I make the script wait for the first input before moving on to the next menu level?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

The pause happens automatically. Your control procedure is called only when they type something in. So it'll just sit there, and then they type "3" or whatever, and eggdrop calls your control procedure with "3" as the text argument.
j
jestrix

Post by jestrix »

OK, so here's the layout. Someone tell me if I'm on the right track :wink:

Code: Select all

#binding for initiating menu system
bind pub o|-  !menu startmenu

#start menu procedure
proc startmenu {nick uhost hand chan args} {
  #get the hostname part of uhost
   set uhostname [lindex [split $uhost @] 1]
  
  #connect to the user (port 45123 is random) and return the user's idx
   set idx [connect $uhostname 45123]
  
  #pass off chat to control function
   control $idx menusystem $args

  #all done
   exit
   
} #end startmenu
in the above, does it matter what port I have the connect set to? I just picked a random high # port....

Now, all input should be passed to my startmenu procedure, correct? Hopefully I've got that much correct :wink:

ok - now in this procedure, if any input text gets sent to the script, that means I can't have the first menu be something like:

1. Type 1
2. Type 2

and if they type "1" they get:

1. Type 1
2 Type 2

since there are two possible times for them to type "1" or "2". basically, is there any way to pause the script in the middle of a procedure, wait for input, call that input some variable, then continue the procedure based on the content of that var?

hopefully I'm explaining myself clearly.... and if anyone knows of a script that uses a dcc menu system, i would love to look at it!!
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

On 2002-03-18 12:33, jestrix wrote:
OK, so here's the layout. Someone tell me if I'm on the right track :wink:

Code: Select all

#binding for initiating menu system
bind pub o|-  !menu startmenu

#start menu procedure
proc startmenu {nick uhost hand chan args} {
  #get the hostname part of uhost
   set uhostname [lindex [split $uhost @] 1]
  
  #connect to the user (port 45123 is random) and return the user's idx
   set idx [connect $uhostname 45123]
  
  #pass off chat to control function
   control $idx menusystem $args

  #all done
   exit
   
} #end startmenu
in the above, does it matter what port I have the connect set to? I just picked a random high # port....
You are not completely on the right track.
1. trying to [connect] to the machine of the user doing !menu on port 45123 doesn't make much sense. What does your firewall do when there is a connection attempt on port 45123 on your machine. [connect] to a port does make sense if you are sure there is a service listening on that port e.g. port 80 of http://www.egghelp.org :smile:
2. handing over [control] is with two arguments: the connection idx and the procedure name you hand the control over to.
Eggdrop will then know to what procedure to send data to, when data is coming through the connection idx. The nice part is that you can continue to handover [control] from one procedure to the other.
Now, all input should be passed to my startmenu procedure, correct? Hopefully I've got that much correct :wink:

ok - now in this procedure... blabla...

[snip]

hopefully I'm explaining myself clearly....
Actually, that wasn't to clear to me... :smile: maybe the below example will help you further...
and if anyone knows of a script that uses a dcc menu system, i would love to look at it!!
Well, I've made a small example which you can test, play with and modify...

http://www.geocities.com/eggheadtcl/menu.tcl.txt

<font size=-1>[ This Message was edited by: egghead on 2002-03-18 16:31 ]</font>
j
jestrix

Post by jestrix »

perfect :grin:

thanks for all the help, egghead!

first time I'm attempting a script of this nature - would like to get away from the standard public triggers and bot msgs/ctcps :wink:

Locked