Skip to content
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

🪲 Fix bug in custom Skulpt module extensions #5763

Merged
merged 3 commits into from
Sep 13, 2024

Conversation

boryanagoncharenko
Copy link
Collaborator

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'
  1. 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

Copy link
Member

@jpelay jpelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works!

var f = Sk.misceval.loadname(name, Sk.globals);
var currentProgram = window.sessionStorage.getItem("currentProgram");

Sk.misceval.asyncToPromise(() =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh it makes sense! AsyncToPromise is the one to use

Copy link
Contributor

mergify bot commented Sep 13, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit ac1f8c0 into main Sep 13, 2024
12 checks passed
Copy link
Contributor

mergify bot commented Sep 13, 2024

Thank you for contributing! Your pull request is now going on the merge train (choo choo! Do not click update from main anymore, and be sure to allow changes to be pushed to your fork).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🪲Turtle commands in if-pressed statements terminate unexpectedly
2 participants