Advertisement
44shades44

Computer Craft RC Turtle Alpha - Turtle

Apr 3rd, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.35 KB | None | 0 0
  1. function RCT()
  2.  while true do
  3.   local scrap, msg = rednet.recieve()
  4.   local td = turtle.detect()
  5.   if msg == "RCF" then
  6.    print("Attempting to Move Forward")
  7.    if td == true then
  8.     print("Move Failed, Block Detected!")
  9.    else
  10.     print("Success! Moving Forward")
  11.     turtle.forward()
  12.    end
  13.   elseif msg == "RCMF" then
  14.    print("Moving and Mining Forward")
  15.    if td == true then
  16.     print("Block detected, Mining and Moving Forward")
  17.     turtle.dig()
  18.    else
  19.     print("No block detected, Moving Forward normally")
  20.    end
  21.    turtle.forward()
  22.   elseif msg == "RCBF" then
  23.    print("Attempting to Mine Block at Front")
  24.    if td == true then
  25.     print("Mining Block at Front")
  26.     turtle.dig()
  27.    else
  28.     print("Mine Front Failed! No Block to Mine")
  29.    end
  30.   elseif msg == "RCPF" then
  31.    print("Attempting to Place block Front")
  32.    if turtle.detect() == true then
  33.     print("Place block Front Failed! Block Detected")
  34.    else
  35.     print("Placing block Front")
  36.     turtle.place()
  37.    end
  38.   elseif msg == "RCAF" then
  39.    print("Attacking Front")
  40.    turtle.attack()
  41.   elseif msg == "RCB" then
  42.    print("Moving Backwards")
  43.    turtle.back()
  44.   elseif msg == "RCR" then
  45.    print("Turning Right")
  46.    turtle.turnRight()
  47.   elseif msg == "RCL" then
  48.    print("Turning Left")
  49.    turtle.turnLeft()
  50.   elseif msg == "RCU" then
  51.    print("Attempting to Move Up")
  52.    if turtle.detectUp() == true then
  53.     print("Move Up Failed! Block Detected")
  54.    else
  55.     print("Success! Moving Up")
  56.     turtle.up()
  57.    end
  58.   elseif msg == "RCMU" then
  59.    print("Moving and Mining Up")
  60.    if turtle.detectUp() == true then
  61.     print("Block detected, Mining and Moving Up")
  62.     turtle.digUp()
  63.    else
  64.     print("No block detected, Moving Up normally")
  65.    end
  66.    turtle.up()
  67.   elseif msg == "RCBU" then
  68.    print("Attempting to Mine Block Above")
  69.    if turtle.detectUp() == true then
  70.     print("Mining Block Above")
  71.     turtle.digUp()
  72.    else
  73.     print("Mine Up Failed! No Block to Mine")
  74.    end
  75.   elseif msg == "RCPU" then
  76.    print("Attempting to Place Block Up")
  77.    if turtle.detectUp() == true then
  78.     print("Place block Up Failed! Block Detected")
  79.    else
  80.     print("Placing Block Up")
  81.     turtle.placeUp()
  82.    end
  83.   elseif msg == "RCAU" then
  84.    print("Attacking Up")
  85.    turtle.attackUp()
  86.   elseif msg == "RCD" then
  87.    print("Attempting to Move Down")
  88.    if turtle.detectDown() == true then
  89.     print("Move Down Failed! Block Detected")
  90.    else
  91.     print("Success! Moving Down")
  92.     turtle.down()
  93.    end
  94.   elseif msg == "RCMD" then
  95.    print("Moving and Mining Down")
  96.    if turtle.detectDown() == true then
  97.     print("Block detected, Mining and Moving Down")
  98.     turtle.digDown()
  99.    else
  100.     print("No block detected, Moving Down normally")
  101.    end
  102.    turtle.down()
  103.   elseif msg == "RCBD" then
  104.    print("Attempting to Mine Block Below")
  105.    if turtle.detectDown() == true then
  106.     print("Mining Block Below")
  107.     turtle.digDown()
  108.    else
  109.     print("Mine Down Failed! No Block to Mine")
  110.    end
  111.   elseif msg == "RCPD" then
  112.    print("Attempting to Place Block Down")
  113.    if turtle.detectDown() == true then
  114.     print("Place block Down Failed! Block Detected")
  115.    else
  116.     print("Placing Block Down")
  117.     turtle.placeDown()
  118.    end
  119.   elseif msg == "RCAD" then
  120.    print("Attacking Down")
  121.    turtle.attackDown()
  122.   elseif msg == "RC1" then
  123.    turtle.select(1)
  124.   elseif msg == "RC2" then
  125.    turtle.select(2)
  126.   elseif msg == "RC3" then
  127.    turtle.select(3)
  128.   elseif msg == "RC4" then
  129.    turtle.select(4)
  130.   elseif msg == "RC5" then
  131.    turtle.select(5)
  132.   elseif msg == "RC6" then
  133.    turtle.select(6)
  134.   elseif msg == "RC7" then
  135.    turtle.select(7)
  136.   elseif msg == "RC8" then
  137.    turtle.select(8)
  138.   elseif msg == "RCRF" then
  139.    print("Attempting Refuel")
  140.    if turtle.getItemCount(16) = 0 then
  141.     print("Refuel Failed, No fuel in Slot 16!")
  142.    elseif turtle.getItemCount(16) > 0 then
  143.     if turtle.getFuelLevel() > 64 then
  144.      print("No need to refuel, atleast 64 blocks to go")
  145.     elseif turtle.getFuelLevel() < 64 then
  146.      if turtle.refuel(0) == false then
  147.       print("Refuel failed, Item in slot 16 is not fuel!")
  148.      elseif turtle.refuel(0) == true then
  149.       turtle.refuel(1)
  150.       print("Refuelling")
  151.      end
  152.     end
  153.    end
  154.   end
  155.  end
  156. end
  157. rednet.open("right")
  158. term.clear()
  159. term.setCursorPos(1,1)
  160. print("Remote Turtle Initiated")
  161. RCT()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement