|
Araadan Wanderer
Joined: 07 Jun 2009 Posts: 65
|
Posted: 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. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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} |
|
|
|
|
Araadan Wanderer
Joined: 07 Jun 2009 Posts: 65
|
Posted: Thu May 19, 2011 3:20 am |
I need "timeout-commands" sections. ;]
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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. |
|
|
|
Araadan Wanderer
Joined: 07 Jun 2009 Posts: 65
|
Posted: 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. ;] |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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?
|
|
|
|
Araadan Wanderer
Joined: 07 Jun 2009 Posts: 65
|
Posted: 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}} |
|
|
|
|
Araadan Wanderer
Joined: 07 Jun 2009 Posts: 65
|
Posted: 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? |
|
|
|
|
|
|