I would like my students to create virtual alarms with Pencil Code.
I am stuck on a problem where I have various buttons:
one button is to confirm everything is okay;
the second button sets off the alarm in a forever loop (I don't want it to stop until another button or key is pressed);
the third button resets the alarm (with the hope of overriding the forever loop)
I have tried various different loop options and also tried the stop() code but I can't get anything to work the way I have in mind.
My code so far is this:
start = ->
button 'Click this if everything is okay!', ->
button 'Set off alarm', ->
forever 1, ->
dot green, 30
dot red, 30
button 'Reset alarm', ->
Is there a way that I can add or change something something in either of the the 'Reset alarm' or the 'Set off alarm' buttons to make it so that if I press a key on the keyboard or click the third button, the whole code clears the screen and goes back to the starting point? Otherwise I have to use the usual PencilCode stop/play buttons or refresh the page entirely.
Also please let me know if this might also be affected by any sound effects (tone or play).