*** This script selects or deselects the walls with a specified orientation. Script must be executed in WALL selecting mode.

// Parameter list begins
mov r96 1 // 0 - deselect, 1 - select
mov r97 1 // 0 - false condition, 1 - true condition
mov r98 0 // Wall angle (0 orients upward, 65536 per revolution, clockwise)
mov r99 256 // Angle tolerance
// Parameter list ends
~~~ Default parameters:
~~~ mov r96 1 // 0 - deselect, 1 - select
~~~ mov r97 1 // 0 - false condition, 1 - true condition
~~~ mov r98 0 // Wall angle (0 orients upward, 65536 per revolution, clockwise)
~~~ mov r99 256 // Angle tolerance
and r98 65535
mov r00 -1
for each nonignored wall r00
  getwall r00 x r01
  getwall r00 y r02
  getwall r00 point2 r03
  getwall r03 x r04
  getwall r03 y r05
  sub r04 r01
  sub r05 r02
  atan2 r03 r04 r05
  sub r03 r98
  if r03 > 32768  sub r03 65536  endif // Values must be in range
  if r03 < -32767  add r03 65536  endif // from -32767 to 32768
  if r03 < 0  neg r03  endif
  if r97 != 0
    if r03 <= r99
      selectwall r00 r96
    endif
  else
    if r03 > r99
      selectwall r00 r96
    endif
  endif
continue