src/tasks/Task.js
// React refs in the function.
React refs in the function.
React refs in the function .
function interpreterStep() {
    const workspaceInterpreter = workspaceInterpreterRef.current;
    const robot = robotListRef.current["left"][0];
    const ballRef = ballStateRef.current
    if (workspaceInterpreter === null) return;
    if (reachedCodeEnd.current === null || reachedCodeEnd.current) return;
    if (robot.isActive || ballRef.isMoving) {
      return;
    }
    console_log("interpreterStep()");
     TODO: Maybe we should use .stepCallExpression() here instead? It is
     weird that we need to call the step function multiple times for one
     function call.
    workspaceInterpreter.step();
  }
function interpreterStep ( ) { const workspaceInterpreter = workspaceInterpreterRef . current ; const robot = robotListRef . current [ "left" ] [ 0 ] ; const ballRef = ballStateRef . current if ( workspaceInterpreter === null ) return ; if ( reachedCodeEnd . current === null || reachedCodeEnd . current ) return ; if ( robot . isActive || ballRef . isMoving ) { return ; } console_log ( "interpreterStep()" ) ; workspaceInterpreter . step ( ) ; }
React refs in the function.
React refs in the function .
// Execution was stopped via the reset button (or never begun) // Execution of the current code is finished // If the robot is still moving (i.e. the robot is still executing the // last task), then don't begin the next task. // Note: If you here get a JS error at this line that states // something like "ReferenceError: ... is not defined" this means // that inside the JS interpreter an object couldn't be found. // Inside the JS interpreter you can't access objects from // outside the JS interpreter - you have to pass everything // explicitly into the JS interpreter (compare how we pass the // dispatch function into the blockly functions). // // TODO: Maybe we should use .stepCallExpression() here instead? It is // weird that we need to call the step function multiple times for one // function call.