bigbadbrain logo
bbb Home
  Mowerjo - Commands

COMMANDS

COMMAND DESCRIPTION
move() Moves you forward one position
face( ["n", "s", "e", or "w" ] ) Faces you in direction specified
turnLeft() Turns you 90 degrees counter-clockwise
turnRight() Turns you 90 degrees clockwise

CONDITIONALS

CONDITIONAL DESCRIPTION
pathIsClear() Checks if the patch immediately in front of the lawn mower is grass (either cut or not).  If the patch is grass then the path is clear.  If a wall or a lawn gnome is in front of the lawn mower, then the path is NOT clear.
nextNeedsToBeCut() Checks if the patch in front has been cut.
nothingAdjacentNeedsCut() Checks the patches in front, behind, to the left, and to the right.  If all of these 4 patches have already been cut, the condition is true.
pathIsNotClear() Checks if the patch in front of the lawn mower contains a wall or a lawn gnome.
moreToCut() Checks if there is any more grass to be cut.
directionIs(["n", "s", "e", or "w" ] ) Checks if the lawn mower is pointed in the direction that you pass in.  For example, if you type if (directionIs("n")) then it will determine if the lawn mower is facing north.  Notice that you can pass in "n", "s", "e", or "w".  Make sure that the direction is in quotes.
xPositionIs( [1,2,3,4,5,6,7,8,or 9] ) Checks the x-position of the lawn mower. For example, if you type if (xPositionIs(1)) then it will determine if the lawn mower is located at x = 1 (the first column).  You can pass in any integer number between 1 and 9.  Do not put quotes around the number.
yPositionIs( [1,2,3,4,5,6,7,8,or 9] ) Checks the y-position of the lawn mower. For example, if you type if (yPositionIs(1)) then it will determine if the lawn mower is located at y = 1 (the first row).  You can pass in any integer number between 1 and 9.  Do not put quotes around the number.
alongWall(["n", "s", "e", or "w" ] ) Checks if the lawn mower is located along the specified wall. For example, if you type if(alongWall("n")), then it will determine if the lawn mower is along the north wall.  You can pass in "n", "s", "e", or "w".  Make sure that you put quotes around the wall.

CODE

CODE DESCRIPTION

if ( [conditional]  ) {
   [commands]
}

This statement performs the commands if the conditional is true.  Make sure that You can have more than one command.  Put a semi-colon at the end of each command or make sure that the commands are on separate lines.  If you put an exclamation point ("!") before the conditional, then it will check if the conditional is false.  For example, if you type if (!directionIs("n")) then the commands will be executed if the direction is NOT north.  You can also have multiple conditionals using || for OR and && for AND. For example, if you type if(directionIs("n") && pathIsClear()) {move()}, then MowerJo will move only if it is facing North and the path is clear.

while ( [conditional]  ) {
[commands]  
}

This statement repeats the commands while the conditional is true.  You can have more than one command.  Put a semi-colon at the end of each command or make sure that the commands are on separate lines.  You can also have multiple conditionals using || for OR and && for AND.

if ( [conditional]  ) {
   [commands 1]  
}
else {
   [commands 2]
}

This statement performs the first set of commands if the conditional is true and the second set of commands if the condition is false.  You can have more than one command.  Put a semi-colon at the end of each command or make sure that the commands are on separate lines.  You can also have multiple conditionals using || for OR and && for AND.
©dfx interactive, inc. Contact us at bigbadbrain@bigbadbrain.com