wxyzsupermod

Turtle Attack Laser

Jan 17th, 2021 (edited)
459
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local modem = peripheral.wrap("left")
  2. local clearCount = 0
  3. local totalTurtles = 5
  4. local turtleNumber = ...
  5. modem.open(42)
  6. local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  7. if message == "start" then
  8. print("Recieved Start Command")
  9. print(turtleNumber)
  10. end
  11. while true do
  12.     if turtle.getFuelLevel() < 5 then
  13.         turtle.up()
  14.         turtle.up()
  15.         turtle.suckUp()
  16.         turtle.refuel(64)
  17.         turtle.down()
  18.         turtle.down()
  19.     end
  20.     print("entered while loop")
  21.     local laser = peripheral.wrap("right")
  22.         if turtleNumber=="1" then
  23.             print("entered if")
  24.             for yaw = 0, 90, 1 do
  25.                 laser.fire(yaw, 0, 5)
  26.             end
  27.         end
  28.         if turtleNumber=="2" then
  29.             for yaw = 90, 180, 1 do
  30.                 laser.fire(yaw, 0, 5)
  31.             end
  32.         end
  33.         if turtleNumber=="3" then
  34.             for yaw = 180, 270, 1 do
  35.                 laser.fire(yaw, 0, 5)
  36.             end
  37.         end
  38.         if turtleNumber=="4" then
  39.             for yaw = 270, 360, 1 do
  40.                 laser.fire(yaw, 0, 5)
  41.             end
  42.         end
  43.         turtle.up()
  44.         modem.transmit(42, 1, "allClear")
  45.         clearCount = 0
  46.         while clearCount <= totalTurtles do
  47.             local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  48.             if message == "pickupClear" then
  49.                 clearCount = clearCount + 1
  50.             end
  51.         end
  52.         turtle.down()
  53.     end
RAW Paste Data