de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 showButton, within a loop
PostPosted: Sun Oct 12, 2014 12:32 am 
Offline
Active member
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.


Top
 Profile Send private message 
 
 Re: showButton, within a loop
PostPosted: Sun Oct 12, 2014 6:05 am 
Offline
Active member
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?


Top
 Profile Send private message 
 
 Re: showButton, within a loop
PostPosted: Mon Oct 13, 2014 8:17 pm 
Offline
Site Admin
User avatar
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().


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


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 post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.