| SexScripts : showButton, within a loop - https://ss.deviatenow.com:443/viewtopic.php?f=4&t=438 | Page 1 of 1 |
showButton, within a loop |
kb215 [ Sun Oct 12, 2014 12:32 am ] |
|---|---|
Hey, so I'm trying to write a pause button into a metronome loop, so that the user can pause the sound of a metronome (It's an edging metronome). I'm drawing the button and adding a timeout on the button inside an each statement. It causes the button to flash because it's being redrawn on each iteration of the loop. Can I draw a button outside of the loop and have it not interfere with the continuation of the loop? I'm really wanting to give the user 60 seconds to edge, present a button so that if they do it in time the metronome stops and returns a value, else script knows that user didn't edge in time. This in essense is what I have. Code: (1..10).each { def hasBeenPressed = showButton("Pause", 0.25); if button pressed > 0 pause loop else ... playBackgroundSound("tom.wav"); } I would like to call the button outside the loop but not wait on the user clicking it, because havig the button outside the loop means the loop doesn't get run until pause is pressed. |
|
Re: showButton, within a loop |
kb215 [ Sun Oct 12, 2014 6:05 am ] |
|---|---|
Does my pause button have to be pressed for the script to get to the loop? As I undertand it showButton() returns the number of seconds it took to be pressed. while( button not pressed ... do this loop){ playsound ... sleep 250 if button pressed in under 60 seconds exit the loop? } end of while Is that possible? |
|
Re: showButton, within a loop |
doti [ Mon Oct 13, 2014 8:17 pm ] |
|---|---|
You can not show a button and do something else (playing a sound, or any code line) at the same time. So, I'm sorry, you'll have a flashing button anyway (because you want to play the sound again). The rest of your predictions are correct, you can know if the user pushed the button if the waiting time parameter is higher than the result of showButton(). |
|
| Page 1 of 1 | All times are UTC + 1 hour [ DST ] |