How do I force a script to stop?
Posted: Fri Dec 16, 2011 12:05 am
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
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