refactor: update turnToFace method to synchronize turtle facing state with global variable

This commit is contained in:
MayaTheShy
2026-02-20 04:24:24 -05:00
parent cb666a6a45
commit 3b2e00b2b4

View File

@@ -130,13 +130,13 @@ export class BaseState {
const diff = (targetFacing - currentFacing + 4) % 4;
if (diff === 1) {
await this.exec('return turtle.turnRight()');
await this.exec(`turtle.turnRight(); _G._turtleFacing = ${targetFacing}`);
this.turtle.facing = targetFacing;
} else if (diff === 2) {
await this.exec('turtle.turnRight(); return turtle.turnRight()');
await this.exec(`turtle.turnRight(); turtle.turnRight(); _G._turtleFacing = ${targetFacing}`);
this.turtle.facing = targetFacing;
} else if (diff === 3) {
await this.exec('return turtle.turnLeft()');
await this.exec(`turtle.turnLeft(); _G._turtleFacing = ${targetFacing}`);
this.turtle.facing = targetFacing;
}