-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🪲 For-list command stops when placed in an if_pressed statement #5681
Comments
The issue seems to be that Skulpt stops the program when a time.sleep() is encountered (and there is one added at the end of the for-loop body). This seems to have been an issue before skulpt/skulpt#764 but it should have been already addressed. Not sure if the issue persists in our fork. We could:
|
I am ok with trying that but we should totally check with @jpelay whether/how that would impact us since we did a lot of work on top of Skulpt with the debugger.
Do you mean only in the |
Actually, I just checked that syncing the fork would not resolve the issue. The problem still exists in Skulpt and can be reproduced with the following programs:
and
Yes, I meant removing the time.sleep only for commands placed in an if-pressed statement. Ideally, I'd find a way to keep the delay because it is handy, but I agree this might be an overkill for now. |
Yeah, that's what I was going to say. Our version of Skulpts dates late 2023, and this issue is from 2018. |
I am ok with that! |
This PR addresses the following issues: - When the body of an if-pressed command contains more than one turtle functions, only the first one will be executed. - When the body of an if-pressed command contains time.sleep(), the execution would terminate when reaching this line. Fixes #5729 #5681 **How to test** Run locally, go to level 15 and run the following scenarios: 1. Check that the code below outputs all items in the list. Note that they should not appear at once, but with a tiny delay in between: ``` lijstje is "1", "2", "3", "4", "5" if x is pressed for dier in lijstje print dier else print 'onbekend dier' ``` 2. Check that when pressing x, all statements are executed. Note that the waiting-for-key-press modal should appear and then disappear while the action is being executed. Note that pressing the x button while the turtle is moving should not trigger a new run. If an error occurs, the keys should not be animated anymore. ``` i = 0 while i < 20 if x is pressed turn 10 color 'blue' turn 90 forward 50 color 'red' turn 90 forward 50 color 'orange' turn 90 forward 50 color 'green' turn 90 forward 50 else turn -15 color 'blue' turn -90 forward 50 color 'red' turn -90 forward 50 color 'orange' turn -90 forward 50 color 'green' turn -90 forward 50 i = i + 1 ```
Closed by PR #5763 |
Describe the bug
In level 10, the following code should output all elements of the list if the key x is pressed. However, the for loop outputs the first element of the array and then the program stops:
Add a screenshot (optional)
The text was updated successfully, but these errors were encountered: