Exiting a repeat loop

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Exiting a repeat loop

Knapp Martin via use-livecode
I have little game where the user runs a repeat loop. And I want to let
the user stop at any time. So what I  do set a local flag.

Here is the simple logic

----------

local sStopFlag

*on mouseup*

*    repeat* sCycles times

*        if* sStopFlag=1*then*

*            exit* *repeat*


**            put "0" into sStopFlag # reinitialize in case they want to
continue**

*        end* *if*

*  **            #SNIP  -- Cool stuff happens on screen*

*end mouseup*

*#and another button that sets the flag*

*# button "pause"
*

*on mouseup*

*  put 1 into sStopFlag*

*end mouseup*

*# but on mobile, the user can't exit repeat until she clicks the
"pause" multiple time.*

*What the secret on exit a running repeat loop?*

*Do add a little idle time?
*

*BR
*

*
*

*
*

*
*

*
*






_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Exiting a repeat loop

Knapp Martin via use-livecode
Yes, probably need a wait with messages inside the loop. Also the reset probably needs to go above the exit.

Thanks,
Brian
On Oct 4, 2018, 4:14 PM -0400, Sannyasin Brahmanathaswami via use-livecode <[hidden email]>, wrote:

> I have little game where the user runs a repeat loop. And I want to let
> the user stop at any time. So what I do set a local flag.
>
> Here is the simple logic
>
> ----------
>
> local sStopFlag
>
> *on mouseup*
>
> * repeat* sCycles times
>
> * if* sStopFlag=1*then*
>
> * exit* *repeat*
>
>
> ** put "0" into sStopFlag # reinitialize in case they want to
> continue**
>
> * end* *if*
>
> * ** #SNIP -- Cool stuff happens on screen*
>
> *end mouseup*
>
> *#and another button that sets the flag*
>
> *# button "pause"
> *
>
> *on mouseup*
>
> * put 1 into sStopFlag*
>
> *end mouseup*
>
> *# but on mobile, the user can't exit repeat until she clicks the
> "pause" multiple time.*
>
> *What the secret on exit a running repeat loop?*
>
> *Do add a little idle time?
> *
>
> *BR
> *
>
> *
> *
>
> *
> *
>
> *
> *
>
> *
> *
>
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Exiting a repeat loop

Knapp Martin via use-livecode
In reply to this post by Knapp Martin via use-livecode
This might not work for you but, I put:

if the optionkey is down then
    exit repeat
end if

So not trying to capture a specific event, just looking to see if a key is pressed down. What happens is that I put one of these within every repeat loop and when it hits one, it quickly dumps out of the repeat loop.

Kee

> On Oct 4, 2018, at 1:14 PM, Sannyasin Brahmanathaswami via use-livecode <[hidden email]> wrote:
>
> I have little game where the user runs a repeat loop. And I want to let
> the user stop at any time. So what I  do set a local flag.
>
> Here is the simple logic
>
> ----------
>
> local sStopFlag
>
> *on mouseup*
>
> *    repeat* sCycles times
>
> *        if* sStopFlag=1*then*
>
> *            exit* *repeat*
>
>
> **            put "0" into sStopFlag # reinitialize in case they want to
> continue**
>
> *        end* *if*
>
> *  **            #SNIP  -- Cool stuff happens on screen*
>
> *end mouseup*
>
> *#and another button that sets the flag*
>
> *# button "pause"
> *
>
> *on mouseup*
>
> *  put 1 into sStopFlag*
>
> *end mouseup*
>
> *# but on mobile, the user can't exit repeat until she clicks the
> "pause" multiple time.*
>
> *What the secret on exit a running repeat loop?*
>
> *Do add a little idle time?
> *
>
> *BR
> *
>
> *
> *
>
> *
> *
>
> *
> *
>
> *
> *
>
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Exiting a repeat loop

Knapp Martin via use-livecode
In reply to this post by Knapp Martin via use-livecode
BR,

you could try to "send in time" instead of a repeat loop.
say use 32 millisecs.

Then every action to stop has enough time to come in.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode