Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Wed May 18, 2011 9:09 pm   

exec %yesno question in #WAITFOR
 
Code:
#waitfor {%yesno("question")} 5000 {match-commands} {timeout-commands}


I need to wait for user decision but this example is not fire %yesno message.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu May 19, 2011 1:05 am   
 
The first argument of #WAITFOR is a trigger pattern. In other words, a pattern that needs to match displayed text. You are trying to do something completely different. Probably what you want is something like:
Code:
#IF (%yesno("should I do something?") = TRUE) {do something}
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Thu May 19, 2011 3:20 am   
 
I need "timeout-commands" sections. ;]
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu May 19, 2011 2:03 pm   
 
So, you are trying to have only a limited time for the user to click "yes" or "no"? Then you'll have to do it completely differently. #WAITFOR waits for specific text from the mud; it won't do what you are trying to do.

Doing this actually won't be easy. #YESNO and %yesno essentially stop processing of the current thread while waiting for a response. What you will need to do is have two threads running--one with the #YESNO or %yesno, and a second which performs a #STOP on the first if it runs too long. If you can give a little more detail about what exactly you are trying to do, perhaps some people here can help figure out how best to do it. Depending on exactly what you are trying to do within the yesno code, doing it badly could cause major problems. For instance, what if the #STOP thread stops the yesno in the middle of the "do something" code? You could really mess up your state if it is only partially finished.
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Sat May 21, 2011 4:42 am   
 
So... example code:
Code:

#thread "abc2" {#wait 4000;#say timeout;#stop abc}
#thread "abc" {#yesno "bbb" {a} {b}}

I stop #thread abc but #yesno message is still activ on screen and cmd line is jammed.

conclusion:
thread is OK but I need kill #yesno msg. ;]
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat May 21, 2011 2:17 pm   
 
Hm. I'm out of ideas then. It is possible that #YESNO and %yesno simply can't be used in the fashion. Anyone else have any ideas?
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Sat May 21, 2011 4:25 pm   
 
crude solution to this problem -> alternatice code

Code:
#MXP %concat("             ------------------------------")
#MXP %concat("             |                            |")
#MXP %concat("             |       <send dummy-yesno1>YES</send>      <send dummy-yesno2>NO</send>          |")
#MXP %concat("             |                            |")
#MXP %concat("             ------------------------------")
#thread "abc" {#wait 10000;#say timeout;dummy-yesno1}


Code:
#ALIAS dummy-yesno1 {#stop abc;quest giveup}
#ALIAS dummy-yesno2 {#stop abc;#20 {#beep;#wait 100}}
Reply with quote
Araadan
Wanderer


Joined: 07 Jun 2009
Posts: 65

PostPosted: Sun May 22, 2011 7:56 am   
 
google translate wrote:
This code crashes the program when it is executed second time, but only if there is time for a timeout section.
If you do the same STOP #abc, or use one of the aliases is a problem does not occur.

I'll try it with traditional methods - # IF / # WAIT / # WAITSIGNAL - and answer. But I think that could use a command closes #yesno.

ps. content of the post is understood, translated in an appropriate manner?
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net