diff --git a/server/Turtle.js b/server/Turtle.js index 1f9a3bd..06f40dc 100644 --- a/server/Turtle.js +++ b/server/Turtle.js @@ -400,6 +400,30 @@ export class Turtle extends EventEmitter { } } + /** + * Turn the turtle left + */ + async turnLeft() { + const result = await this.exec('return turtle.turnLeft()'); + if (result === true || (Array.isArray(result) && result[0] === true)) { + this._facing = (this._facing + 3) % 4; + this._emitUpdate(); + } + return result; + } + + /** + * Turn the turtle right + */ + async turnRight() { + const result = await this.exec('return turtle.turnRight()'); + if (result === true || (Array.isArray(result) && result[0] === true)) { + this._facing = (this._facing + 1) % 4; + this._emitUpdate(); + } + return result; + } + /** * Move the turtle forward. Updates position and deletes block at destination. */