Advertisement
nerfnerf123

rcturtle

Jul 15th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --THINGS TO ADD: Fuel meter, auto startup, "connect to turtle" - which wakes the turtle?
  2.  
  3. local isRunning = true
  4.  
  5. function Quit()
  6.         isRunning = false
  7.         term.setCursorPos(1,1)
  8.         term.setBackgroundColour(colours.black)
  9.         term.setTextColour(colours.white)
  10.         term.clear()
  11.         error()
  12. end
  13.  
  14. local function getModem()
  15.   for a,b in pairs(rs.getSides()) do
  16.     if peripheral.getType(b) == "modem" and peripheral.call(b,"isWireless") then
  17.       return b
  18.     end
  19.   end
  20. end
  21.  
  22. while isRunning do
  23.   notclicked = true
  24.   side = getModem()
  25.   rednet.open(side)
  26.   term.setBackgroundColor(colors.white)
  27.   term.setCursorPos(1,1)
  28.   term.clear()
  29.   term.setTextColor(colors.blue)
  30.   print("Turtle Control")
  31.   term.setTextColor(colors.lime)
  32.   paintutils.drawFilledBox(2,2,10,5,colors.yellow) -- Forward
  33.   paintutils.drawFilledBox(16,2,24,5,colors.yellow) -- Backward
  34.   paintutils.drawFilledBox(2,7,10,10,colors.yellow) -- Left
  35.   paintutils.drawFilledBox(16,7,24,10,colors.yellow) -- Right
  36.   paintutils.drawFilledBox(2,12,10,15,colors.yellow) -- Turn Left
  37.   paintutils.drawFilledBox(16,12,24,15,colors.yellow) -- Turn Right
  38.   paintutils.drawFilledBox(2,18,10,20,colors.yellow) -- Action
  39.   paintutils.drawFilledBox(16,18,24,20,colors.red) -- Exit
  40.   term.setCursorPos(3,4)
  41.   print("Forward")
  42.   term.setCursorPos(16,4)
  43.   print("Backward")
  44.   term.setCursorPos(4,9)
  45.   print("Left")
  46.   term.setCursorPos(18,9)
  47.   print("Right")
  48.   term.setCursorPos(4,13)
  49.   print("Turn")
  50.   term.setCursorPos(4,14)
  51.   print("Left")
  52.   term.setCursorPos(18,13)
  53.   print("Turn")
  54.   term.setCursorPos(18,14)
  55.   print("Right")
  56.   term.setCursorPos(4,19)
  57.   print("Action")
  58.   term.setCursorPos(18,19)
  59.   print("Quit")
  60.   while notclicked do
  61.     event,button,x,y = os.pullEvent("mouse_click")
  62.     if x == 2 and y == 2 or x == 10 and y == 5 or x > 2 and x < 10 and y > 2 and y < 5 then
  63.       rednet.open(side)
  64.       rednet.broadcast("forward")
  65.       rednet.close(side)
  66.     elseif x == 16 and y == 2 or x == 24 and y == 5 or x > 16 and x < 24 and y > 2 and y < 5 then
  67.       rednet.open(side)
  68.       rednet.broadcast("backwards")
  69.       rednet.close(side)
  70.     elseif x == 2 and y == 7 or x == 10 and y == 10 or x > 2 and x < 10 and y > 7 and y < 10 then
  71.       rednet.open(side)
  72.       rednet.broadcast("left")
  73.       rednet.close(side)
  74.     elseif x == 16 and y == 7 or x == 24 and y == 10 or x > 16 and x < 24 and y > 7 and y < 10 then
  75.       rednet.open(side)
  76.       rednet.broadcast("right")
  77.       rednet.close(side)
  78.     elseif x == 2 and y == 12 or x == 10 and y == 15 or x > 2 and x < 10 and y > 12 and y < 15 then
  79.       rednet.open(side)
  80.       rednet.broadcast("turnleft")
  81.       rednet.close()
  82.     elseif x == 16 and y == 12 or x == 24 and y == 15 or x > 16 and x < 24 and y > 12 and y < 15 then
  83.       rednet.open(side)
  84.       rednet.broadcast("turnright")
  85.       rednet.close()
  86.     elseif x == 2 and y == 18 or x == 10 and y == 20 or x > 2 and x < 10 and y > 18 and y < 20 then
  87.       rednet.open(side)
  88.       rednet.broadcast("action")
  89.       rednet.close()
  90.     elseif x == 16 and y == 18 or x == 24 and y == 20 or x > 16 and x < 24 and y > 18 and y < 20 then
  91.       rednet.open(side)
  92.       rednet.broadcast("quit")
  93.       rednet.close()
  94.       Quit()
  95.     end
  96.   end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement