Hi All,
I did something foolish, I think.
I'm on Mac 10.6.8, runrev 5.0.2.
I had a image on the screen, then put up a graphic that just happens to be touching by 5-6 pixels. I wanted to check out the intersect command, and I had seen the 'answer' event, and thought "Hey, I'll give that a try".
I've set up a game loop based on the updateScreen event published in the Game Academy. So in the updateScreen event I have this:
if intersect(image "hard place",graphic "rock","pixels") then
answer("between")
end if
So, all you pro's are probably chuckling to yourselves at this point...
My stack, (which I hadn't saved for 10-15 minutes or so), was stuck in a modal loop telling me "between"...I couldn't seem to break out of it. If I clicked the 'OK' button, I just get another. If I pressed 'Return', I just got another. It's modal, so I wasn't able to do much of anything else to livecode or my stack.
Fortunately for me, farther down in the event handling my code responded to the 'left' arrow key, and finally moved the character off the graphic. I was just lucky to have stumbled across that, and lucky that the key event to move the image was still enabled.
So, one of the things I'm finding hard to digest here is that the stack seems to always be alive. Much to my chagrin. Is there a way to tell a stack to only handle events when it's got the window manager focus?
Further, there should be a back door to such modal problems (the message box would be a great candidate). Something "modal" should be overridable, don't you think?
Finally, is there a way to force a 'save' when a stack is 'run'? I know this is a pretty ambiguous event in runrev, but one possible time is the transition from the 'Edit Tool' to the 'Run Tool'. If I hvae to shoot LiveCode in the foot to recover from my own stupidity, I'd rather not lose anything worth keeping.
Hopefully,
-Ken
How do I force a script to stop?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 22
- Joined: Mon Dec 05, 2011 5:33 pm
Re: How do I force a script to stop?
I've gotten myself into this situation, and usually before I do a test in "run" mode, I'll save with Command+S. Then if I get stuck like this, I'll do a Command+Q to exit LiveCode and then I can re-open my stack. If there is a better way anyone can suggest, please let us know!
-
- Posts: 10
- Joined: Sun Jan 25, 2009 3:27 pm
Re: How do I force a script to stop?
kcorey wrote:Hi All,
I did something foolish, I think.
I'm on Mac 10.6.8, runrev 5.0.2.
I had a image on the screen, then put up a graphic that just happens to be touching by 5-6 pixels. I wanted to check out the intersect command, and I had seen the 'answer' event, and thought "Hey, I'll give that a try".
I've set up a game loop based on the updateScreen event published in the Game Academy. So in the updateScreen event I have this:
if intersect(image "hard place",graphic "rock","pixels") then
answer("between")
end if
So, all you pro's are probably chuckling to yourselves at this point...
My stack, (which I hadn't saved for 10-15 minutes or so), was stuck in a modal loop telling me "between"...I couldn't seem to break out of it. If I clicked the 'OK' button, I just get another. If I pressed 'Return', I just got another. It's modal, so I wasn't able to do much of anything else to livecode or my stack.
Fortunately for me, farther down in the event handling my code responded to the 'left' arrow key, and finally moved the character off the graphic. I was just lucky to have stumbled across that, and lucky that the key event to move the image was still enabled.
So, one of the things I'm finding hard to digest here is that the stack seems to always be alive. Much to my chagrin. Is there a way to tell a stack to only handle events when it's got the window manager focus?
Further, there should be a back door to such modal problems (the message box would be a great candidate). Something "modal" should be overridable, don't you think?
Finally, is there a way to force a 'save' when a stack is 'run'? I know this is a pretty ambiguous event in runrev, but one possible time is the transition from the 'Edit Tool' to the 'Run Tool'. If I hvae to shoot LiveCode in the foot to recover from my own stupidity, I'd rather not lose anything worth keeping.
Hopefully,
-Ken
Check allowInterrupts in the Dictionary. Maybe that helps..
Re: How do I force a script to stop?
Hi Ken,
in your case you can stop the loop by checking the "Stop Messages" in the Development Menu. (Also accessible from the Menue Bar as "Messages") It will stop the loop and you can change your code. This is also a good technique if you got yourself into a problem by creating a runaway script in the openstack preopenstack handler. It will prevent the handler to execute and you can open your stack for editing.
At times if you create a tight runaway repeat loop it is difficult to stop that. You can always try to press the command key and period. Sometimes you dont manage to stop the repeat loop with this technique. Then a "wait 0 milliseconds with messages" in the repeat loop helps to stopt the loop by pressing command period since the engine has a far better chance to register your input.
As far as automatically saving is concerned: in the Development Menu /Plugins there is a plugin "revSmartSave". It allows you to set a time interval as to when to auto-save. But you will probably soon get into the habit of saving manually if and when you do changes before running the code. Also it is a good idea to have backups of your stack at various stages.
Most of the time if I want to watch if an event occurs (like your intersect) I don't use the answer command. I either make a temporary field where I put the information I am interested in or I just put the info into the message box by saying: I add the milliseconds to see if it is constantly changing as in your case. It is faster that way and I don't have to hit the OK button. The simple put statement without any destination directs the output to the message box.
Kind regards
Bernd
in your case you can stop the loop by checking the "Stop Messages" in the Development Menu. (Also accessible from the Menue Bar as "Messages") It will stop the loop and you can change your code. This is also a good technique if you got yourself into a problem by creating a runaway script in the openstack preopenstack handler. It will prevent the handler to execute and you can open your stack for editing.
At times if you create a tight runaway repeat loop it is difficult to stop that. You can always try to press the command key and period. Sometimes you dont manage to stop the repeat loop with this technique. Then a "wait 0 milliseconds with messages" in the repeat loop helps to stopt the loop by pressing command period since the engine has a far better chance to register your input.
Not really, probably everyone has gotten himself into that trouble before and they will have "fond memories" of that....So, all you pro's are probably chuckling to yourselves at this point...
As far as automatically saving is concerned: in the Development Menu /Plugins there is a plugin "revSmartSave". It allows you to set a time interval as to when to auto-save. But you will probably soon get into the habit of saving manually if and when you do changes before running the code. Also it is a good idea to have backups of your stack at various stages.
Most of the time if I want to watch if an event occurs (like your intersect) I don't use the answer command. I either make a temporary field where I put the information I am interested in or I just put the info into the message box by saying:
Code: Select all
if intersect(image "hard place",graphic "rock","pixels") then
put "between" && the milliseconds
else
put "no intersect" && the milliseconds
end if
Kind regards
Bernd