Advertisement
Heracles421

RC_Console

Oct 21st, 2012
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 36.68 KB | None | 0 0
  1. function menu(id, text)
  2.     if sid == id then
  3.         print("["..text.."]")
  4.     else
  5.         print(" "..text)
  6.     end
  7. end
  8.  
  9. function RCmaster()
  10. sid = 0
  11. fuel = ""
  12. coords = ""
  13. while true do
  14.     term.clear()
  15.     term.setCursorPos(1,1)
  16.     print("TurtleControl V "..version..". Mode: Broadcast")
  17.     menu(0, "Movement")
  18.     menu(1, "Block Placing")
  19.     menu(2, "Others")
  20.     menu(3, "Exit")
  21.     local sEvent, param = os.pullEvent("key")
  22.     if(sEvent == "key") then
  23.         if(param == 200) then
  24.             if sid > 0 then
  25.                 sid = sid - 1
  26.             elseif sid == 0 then
  27.                 sid = 3
  28.             end
  29.         elseif (param == 208) then
  30.             if sid < 3 then
  31.                 sid = sid + 1
  32.             elseif sid == 3 then
  33.                 sid = 0
  34.             end
  35.         elseif (param == 28) then
  36.             if (sid == 0) then
  37.                 sid = 0
  38.                 while true do
  39.                     term.clear()
  40.                     term.setCursorPos(1,1)
  41.                     print("TurtleControl V "..version..". Mode: Broadcast")
  42.                     menu(0, "Forward")
  43.                     menu(1, "Backward")
  44.                     menu(2, "Turn Left")
  45.                     menu(3, "Turn Right")
  46.                     menu(4, "Up")
  47.                     menu(5, "Down")
  48.                     menu(6, "Attack")
  49.                     menu(7, "Mine")
  50.                     menu(8, "Return to main menu")
  51.                     print("")
  52.                     print("Coordinates: "..coords)
  53.                     print("Fuel level: "..fuel)
  54.                     local sEvent, param = os.pullEvent("key")
  55.                     if(sEvent == "key") then
  56.                         if(param == 200) then
  57.                             if sid > 0 then
  58.                                 sid = sid - 1
  59.                             elseif sid == 0 then
  60.                                 sid = 8
  61.                             end
  62.                         elseif (param == 208) then
  63.                             if sid < 8 then
  64.                                 sid = sid + 1
  65.                             elseif sid == 8 then
  66.                                 sid = 0
  67.                             end
  68.                         elseif (param == 28) then
  69.                             if sid == 0 then
  70.                                 rednet.broadcast("TS Forward")
  71.                                 data()
  72.                             elseif sid == 1 then
  73.                                 rednet.broadcast("TS Backward")
  74.                                 data()
  75.                             elseif sid == 2 then
  76.                                 rednet.broadcast("TS TurnLeft")
  77.                             elseif sid == 3 then
  78.                                 rednet.broadcast("TS TurnRight")
  79.                             elseif sid == 4 then
  80.                                 rednet.broadcast("TS Up")
  81.                                 data()
  82.                             elseif sid == 5 then
  83.                                 rednet.broadcast("TS Down")                    
  84.                                 data()
  85.                             elseif sid == 6 then
  86.                                 rednet.broadcast("TS Attack")
  87.                             elseif sid == 7 then
  88.                                 rednet.broadcast("TS Mine")
  89.                             elseif sid == 8 then
  90.                                 RCmaster()
  91.                             end
  92.                         end
  93.                     end
  94.                 end
  95.             elseif sid == 1 then
  96.                 sid = 0
  97.                 while true do
  98.                     term.clear()
  99.                     term.setCursorPos(1,1)
  100.                     print("TurtleControl V "..version..". Mode: Broadcast")
  101.                     menu(0, "Place in front")
  102.                     menu(1, "Place Up")
  103.                     menu(2, "Place Down")
  104.                     menu(3, "Return to main menu")
  105.                     local sEvent, param = os.pullEvent("key")
  106.                     if(sEvent == "key") then
  107.                         if(param == 200) then
  108.                             if sid > 0 then
  109.                                 sid = sid - 1
  110.                             elseif sid == 0 then
  111.                                 sid = 3
  112.                             end
  113.                         elseif (param == 208) then
  114.                             if sid < 3 then
  115.                                 sid = sid + 1
  116.                             elseif sid == 3 then
  117.                                 sid = 0
  118.                             end
  119.                         elseif (param == 28) then
  120.                             if sid == 0 then
  121.                                 rednet.broadcast("TS PlaceBlock")
  122.                             elseif sid == 1 then
  123.                                 rednet.broadcast("TS PlaceBlockUp")
  124.                             elseif sid == 2 then
  125.                                 rednet.broadcast("TS PlaceBlockDown")
  126.                             elseif sid == 3 then
  127.                                 RCmaster()
  128.                             end
  129.                         end
  130.                     end
  131.                 end
  132.             elseif sid == 2 then
  133.                 sid = 0
  134.                 while true do
  135.                     term.clear()
  136.                     term.setCursorPos(1,1)
  137.                     print("TurtleControl V "..version..". Mode: Broadcast")
  138.                     menu(0, "Redstone Current")
  139.                     menu(1, "Refuel (Use coal only)")
  140.                     menu(2, "Slot Forward")
  141.                     menu(3, "Slot Backward")
  142.                     menu(4, "Use *Send* instead of *Broadcast*")
  143.                     menu(5, "Key based control")
  144.                     menu(6, "Cursor based control")
  145.                     menu(7, "Remote program")
  146.                     menu(8, "Return to main menu")
  147.                     print("")
  148.                     print("Current Slot: "..s)
  149.                     local sEvent, param = os.pullEvent("key")
  150.                     if(sEvent == "key") then
  151.                         if(param == 200) then
  152.                             if sid > 0 then
  153.                                 sid = sid - 1
  154.                             elseif sid == 0 then
  155.                                 sid = 8
  156.                             end
  157.                         elseif (param == 208) then
  158.                             if sid < 8 then
  159.                                 sid = sid + 1
  160.                             elseif sid == 8 then
  161.                                 sid = 0
  162.                         end
  163.                         elseif (param == 28) then
  164.                             if sid == 0 then
  165.                                 rednet.broadcast("TS Redstone")
  166.                             elseif sid == 1 then
  167.                                 rednet.broadcast("TS Refuel")
  168.                             elseif sid == 2 then
  169.                                 if s >= 16 then
  170.                                 else
  171.                                     rednet.broadcast("TS NextSlot")
  172.                                     s=s+1
  173.                                     rednet.broadcast(tostring(s))
  174.                                 end
  175.                             elseif sid == 3 then
  176.                                 if s <= 1 then
  177.                                 else
  178.                                     rednet.broadcast("TS PreviousSlot")
  179.                                     s=s-1
  180.                                     rednet.broadcast(tostring(s))
  181.                                 end
  182.                             elseif sid == 4 then
  183.                                 RCmaster_send()
  184.                             elseif sid == 5 then
  185.                                 RCmaster_keys()
  186.                             elseif sid == 6 then
  187.                                 RCmaster_mouse()
  188.                             elseif sid == 7 then
  189.                                 rednet.broadcast("TS Program")
  190.                                 term.clear()
  191.                                 term.setCursorPos(1,1)
  192.                                 print("What program do you want to run?")
  193.                                 program = io.read()
  194.                                 rednet.broadcast(program)
  195.                             elseif sid == 8 then
  196.                                 RCmaster()
  197.                             end
  198.                         end
  199.                     end
  200.                 end
  201.             elseif sid == 3 then
  202.                 os.reboot()
  203.             end
  204.         end
  205.     end
  206. end
  207. end
  208.  
  209. function RCmaster_send()
  210. sid = 0
  211. fuel = ""
  212. coords = ""
  213. while true do
  214.     term.clear()
  215.     term.setCursorPos(1,1)
  216.     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  217.     menu(0, "Movement")
  218.     menu(1, "Block Placing")
  219.     menu(2, "Others")
  220.     menu(3, "Exit")
  221.     local sEvent, param = os.pullEvent("key")
  222.     if(sEvent == "key") then
  223.         if(param == 200) then
  224.             if sid > 0 then
  225.                 sid = sid - 1
  226.             elseif sid == 0 then
  227.                 sid = 3
  228.             end
  229.         elseif (param == 208) then
  230.             if sid < 3 then
  231.                 sid = sid + 1
  232.             elseif sid == 3 then
  233.                 sid = 0
  234.             end
  235.         elseif (param == 28) then
  236.             if sid == 0 then
  237.                 sid = 0
  238.                 while true do
  239.                     term.clear()
  240.                     term.setCursorPos(1,1)
  241.                     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  242.                     menu(0, "Forward")
  243.                     menu(1, "Backward")
  244.                     menu(2, "Turn Left")
  245.                     menu(3, "Turn Right")
  246.                     menu(4, "Up")
  247.                     menu(5, "Down")
  248.                     menu(6, "Attack")
  249.                     menu(7, "Mine")
  250.                     menu(8, "Return to main menu")
  251.                     print("")
  252.                     print("Coordinates: "..coords)
  253.                     print("Fuel level: "..fuel)
  254.                     local sEvent, param = os.pullEvent("key")
  255.                     if(sEvent == "key") then
  256.                         if(param == 200) then
  257.                             if sid > 0 then
  258.                                 sid = sid - 1
  259.                             elseif sid == 0 then
  260.                                 sid = 8
  261.                             end
  262.                         elseif (param == 208) then
  263.                             if sid < 8 then
  264.                                 sid = sid + 1
  265.                             elseif sid == 8 then
  266.                                 sid = 0
  267.                             end
  268.                         elseif (param == 28) then
  269.                             if sid == 0 then
  270.                                 rednet.send(tid, "TS Forward")
  271.                                 data_send()
  272.                             elseif sid == 1 then
  273.                                 rednet.send(tid, "TS Backward")
  274.                                 data_send()
  275.                             elseif sid == 2 then
  276.                                 rednet.send(tid, "TS TurnLeft")
  277.                             elseif sid == 3 then
  278.                                 rednet.send(tid, "TS TurnRight")
  279.                             elseif sid == 4 then
  280.                                 rednet.send(tid, "TS Up")
  281.                                 data_send()
  282.                             elseif sid == 5 then
  283.                                 rednet.send(tid, "TS Down")
  284.                                 data_send()
  285.                             elseif sid == 6 then
  286.                                 rednet.send(tid, "TS Attack")
  287.                             elseif sid == 7 then
  288.                                 rednet.send(tid, "TS Mine")
  289.                             elseif sid == 8 then
  290.                                 RCmaster_send()
  291.                             end
  292.                         end
  293.                     end
  294.                 end
  295.             elseif sid == 1 then
  296.                 sid = 0
  297.                 while true do
  298.                     term.clear()
  299.                     term.setCursorPos(1,1)
  300.                     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  301.                     menu(0, "Place in front")
  302.                     menu(1, "Place Up")
  303.                     menu(2, "Place Down")
  304.                     menu(3, "Return to main menu")
  305.                     local sEvent, param = os.pullEvent("key")
  306.                     if(sEvent == "key") then
  307.                         if(param == 200) then
  308.                             if sid > 0 then
  309.                                 sid = sid - 1
  310.                             elseif sid == 0 then
  311.                                 sid = 3
  312.                             end
  313.                         elseif (param == 208) then
  314.                             if sid < 3 then
  315.                                 sid = sid + 1
  316.                             elseif sid == 3 then
  317.                                 sid = 0
  318.                             end
  319.                         elseif (param == 28) then
  320.                             if sid == 0 then
  321.                                 rednet.send(tid, "TS PlaceBlock")
  322.                             elseif sid == 1 then
  323.                                 rednet.send(tid, "TS PlaceBlockUp")
  324.                             elseif sid == 2 then
  325.                                 rednet.send(tid, "TS PlaceBlockDown")
  326.                             elseif sid == 3 then
  327.                                 RCmaster_send()
  328.                             end
  329.                         end
  330.                     end
  331.                 end
  332.             elseif sid == 2 then
  333.                 sid = 0
  334.                 while true do
  335.                     term.clear()
  336.                     term.setCursorPos(1,1)
  337.                     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  338.                     menu(0, "Redstone Current")
  339.                     menu(1, "Refuel (Use coal only)")
  340.                     menu(2, "Slot Forward")
  341.                     menu(3, "Slot Backward")
  342.                     menu(4, "Use *Broadcast* instead of *Send*")
  343.                     menu(5, "Send ID Forward")
  344.                     menu(6, "Send ID Backward")
  345.                     menu(7, "Key based control")
  346.                     menu(8, "Cursor based control")
  347.                     menu(9, "Remote program")
  348.                     menu(10, "Return to main menu")
  349.                     print("")
  350.                     print("Current Slot: "..s)
  351.                     print("Selected ID: "..tid)
  352.                     local sEvent, param = os.pullEvent("key")
  353.                     if(sEvent == "key") then
  354.                         if(param == 200) then
  355.                             if sid > 0 then
  356.                                 sid = sid - 1
  357.                             elseif sid == 0 then
  358.                                 sid = 10
  359.                             end
  360.                         elseif (param == 208) then
  361.                             if sid < 10 then
  362.                                 sid = sid + 1
  363.                             elseif sid == 10 then
  364.                                 sid = 0
  365.                             end
  366.                         elseif (param == 28) then
  367.                             if sid == 0 then
  368.                                 rednet.send(tid, "TS Redstone")
  369.                             elseif sid == 1 then
  370.                                 rednet.send(tid, "TS Refuel")
  371.                             elseif sid == 2 then
  372.                                 if s >= 16 then
  373.                                 else
  374.                                     rednet.send(tid, "TS NextSlot")
  375.                                     s=s+1
  376.                                     rednet.send(tid, tostring(s))
  377.                                 end
  378.                             elseif sid == 3 then
  379.                                 if s <= 1 then
  380.                                 else
  381.                                     rednet.send(tid, "TS PreviousSlot")
  382.                                     s=s-1
  383.                                     rednet.send(tid, tostring(s))
  384.                                 end
  385.                             elseif sid == 4 then
  386.                                 RCmaster()
  387.                             elseif sid == 5 then
  388.                                 if tid >= 100000000 then
  389.                                 else
  390.                                     tid=tid+1
  391.                                 end
  392.                             elseif sid == 6 then
  393.                                 if tid <= 1 then
  394.                                 else
  395.                                     tid=tid-1
  396.                                 end
  397.                             elseif sid == 7 then
  398.                                 RCmaster_keys_send()
  399.                             elseif sid == 8 then
  400.                                 RCmaster_mouse_send()
  401.                             elseif sid == 9 then
  402.                                 rednet.send(tid, "TS Program")
  403.                                 term.clear()
  404.                                 term.setCursorPos(1,1)
  405.                                 print("What program do you want to run?")
  406.                                 program = io.read()
  407.                                 rednet.send(tid, program)
  408.                             elseif sid == 10 then
  409.                                 RCmaster_send()
  410.                             end
  411.                         end
  412.                     end
  413.                 end
  414.             elseif sid == 3 then
  415.                 os.reboot()
  416.             end
  417.         end
  418.     end
  419. end
  420. end
  421.  
  422. function RCmaster_keys()
  423. fuel = ""
  424. coords = ""
  425. term.clear()
  426. term.setCursorPos(1,1)
  427. print("TurtleControl V "..version..". Mode: Broadcast")
  428. print("W/A/S/D: Movement\nQ/E: Up and Down\nZ/X/C: Place blocks Down, In Front and Up\nR/F: Change slots\nT: Output redstone signal\nG: Attack\nV: Mine Down, In Front and Up\nH: Display help\nO: Change mode\nB: Back to menu based control\nN: Refuel\n(Press any key to continue...)")
  429. local sEvent, param = os.pullEvent("key")
  430. if(sEvent == "key") then
  431. end
  432. term.clear()
  433. term.setCursorPos(1,1)
  434. print("TurtleControl V "..version..". Mode: Broadcast")
  435. print("")
  436. print("")
  437. print("Coordinates: "..coords)
  438. print("Fuel level: "..fuel)
  439. while true do
  440.     local sEvent, param = os.pullEvent("key")
  441.     if(sEvent == "key") then
  442.         if(param == 17) then
  443.             rednet.broadcast("TS Forward")
  444.             data()
  445.             term.clear()
  446.             term.setCursorPos(1,1)
  447.             print("TurtleControl V "..version..". Mode: Broadcast")
  448.             print("Forward")
  449.             print("")
  450.             print("Coordinates: "..coords)
  451.             print("Fuel level: "..fuel)
  452.         elseif (param == 31) then
  453.             rednet.broadcast("TS Backward")
  454.             data()
  455.             term.clear()
  456.             term.setCursorPos(1,1)
  457.             print("TurtleControl V "..version..". Mode: Broadcast")
  458.             print("Backward")
  459.             print("")
  460.             print("Coordinates: "..coords)
  461.             print("Fuel level: "..fuel)
  462.         elseif (param == 30) then
  463.             rednet.broadcast("TS TurnLeft")
  464.             term.clear()
  465.             term.setCursorPos(1,1)
  466.             print("TurtleControl V "..version..". Mode: Broadcast")
  467.             print("Turn Left")
  468.             print("")
  469.             print("Coordinates: "..coords)
  470.             print("Fuel level: "..fuel)
  471.         elseif (param == 32) then
  472.             rednet.broadcast("TS TurnRight")
  473.             term.clear()
  474.             term.setCursorPos(1,1)
  475.             print("TurtleControl V "..version..". Mode: Broadcast")
  476.             print("Turn Right")
  477.             print("")
  478.             print("Coordinates: "..coords)
  479.             print("Fuel level: "..fuel)
  480.         elseif (param == 18) then
  481.             rednet.broadcast("TS Up")
  482.             data()
  483.             term.clear()
  484.             term.setCursorPos(1,1)
  485.             print("TurtleControl V "..version..". Mode: Broadcast")
  486.             print("Up")
  487.         elseif (param == 16) then
  488.             rednet.broadcast("TS Down")
  489.             data()
  490.             term.clear()
  491.             term.setCursorPos(1,1)
  492.             print("TurtleControl V "..version..". Mode: Broadcast")
  493.             print("Down")
  494.             print("")
  495.             print("Coordinates: "..coords)
  496.             print("Fuel level: "..fuel)
  497.         elseif (param == 45) then
  498.             rednet.broadcast("TS PlaceBlock")
  499.             term.clear()
  500.             term.setCursorPos(1,1)
  501.             print("TurtleControl V "..version..". Mode: Broadcast")
  502.             print("Place Block")
  503.             print("")
  504.             print("Coordinates: "..coords)
  505.             print("Fuel level: "..fuel)
  506.         elseif (param == 46) then
  507.             rednet.broadcast("TS PlaceBlockUp")
  508.             term.clear()
  509.             term.setCursorPos(1,1)
  510.             print("TurtleControl V "..version..". Mode: Broadcast")
  511.             print("Place Block Up")
  512.             print("")
  513.             print("Coordinates: "..coords)
  514.             print("Fuel level: "..fuel)
  515.         elseif (param == 44) then
  516.             rednet.broadcast("TS PlaceBlockDown")
  517.             term.clear()
  518.             term.setCursorPos(1,1)
  519.             print("TurtleControl V "..version..". Mode: Broadcast")
  520.             print("Place Block Down")
  521.             print("")
  522.             print("Coordinates: "..coords)
  523.             print("Fuel level: "..fuel)
  524.         elseif (param == 19) then
  525.             if s >= 16 then
  526.                 term.clear()
  527.                 term.setCursorPos(1,1)
  528.                 print("TurtleControl V "..version..". Mode: Broadcast")
  529.                 print("No more slots left")
  530.                 print("")
  531.                 print("Coordinates: "..coords)
  532.                 print("Fuel level: "..fuel)
  533.             else
  534.                 rednet.broadcast("TS NextSlot")
  535.                 s=s+1
  536.                 rednet.broadcast(tostring(s))
  537.                 term.clear()
  538.                 term.setCursorPos(1,1)
  539.                 print("TurtleControl V "..version..". Mode: Broadcast")
  540.                 print("Now using slot " ..s)
  541.                 print("")
  542.                 print("Coordinates: "..coords)
  543.                 print("Fuel level: "..fuel)
  544.             end
  545.         elseif (param == 33) then
  546.             if s <= 1 then
  547.                 term.clear()
  548.                 term.setCursorPos(1,1)
  549.                 print("TurtleControl V "..version..". Mode: Broadcast")
  550.                 print("No more slots left")
  551.                 print("")
  552.                 print("Coordinates: "..coords)
  553.                 print("Fuel level: "..fuel)
  554.             else
  555.                 rednet.broadcast("TS PreviousSlot")
  556.                 s=s-1
  557.                 rednet.broadcast(tostring(s))
  558.                 term.clear()
  559.                 term.setCursorPos(1,1)
  560.                 print("TurtleControl V "..version..". Mode: Broadcast")
  561.                 print("Now using slot " ..s)
  562.                 print("")
  563.                 print("Coordinates: "..coords)
  564.                 print("Fuel level: "..fuel)
  565.             end
  566.         elseif (param == 20) then
  567.             rednet.broadcast("TS Redstone")
  568.             term.clear()
  569.             term.setCursorPos(1,1)
  570.             print("TurtleControl V "..version..". Mode: Broadcast")
  571.             print("Redstone")
  572.             print("")
  573.             print("Coordinates: "..coords)
  574.             print("Fuel level: "..fuel)
  575.         elseif (param == 34) then
  576.             rednet.broadcast("TS Attack")
  577.             term.clear()
  578.             term.setCursorPos(1,1)
  579.             print("TurtleControl V "..version..". Mode: Broadcast")
  580.             print("Attack")
  581.             print("")
  582.             print("Coordinates: "..coords)
  583.             print("Fuel level: "..fuel)
  584.         elseif (param == 47) then
  585.             rednet.broadcast("TS Mine")
  586.             term.clear()
  587.             term.setCursorPos(1,1)
  588.             print("TurtleControl V "..version..". Mode: Broadcast")
  589.             print("Mine")
  590.             print("")
  591.             print("Coordinates: "..coords)
  592.             print("Fuel level: "..fuel)
  593.         elseif (param == 35) then
  594.             term.clear()
  595.             term.setCursorPos(1,1)
  596.             print("TurtleControl V "..version..". Mode: Broadcast")
  597.             print("W/A/S/D: Movement\nQ/E: Up and Down\nZ/X/C: Place blocks Down, In Front and Up\nR/F: Change slots\nT: Output redstone signal\nG: Attack\nV: Mine Down, In Front and Up\nH: Display help\nO: Change mode\nB: Back to menu based control\nN: Refuel\n(Press any key to continue...)")
  598.             local sEvent, param = os.pullEvent("key")
  599.            if(sEvent == "key") then
  600.                 term.clear()
  601.                 term.setCursorPos(1,1)
  602.                 print("TurtleControl V "..version..". Mode: Broadcast")
  603.                 print("")
  604.                 print("")
  605.                 print("Coordinates: "..coords)
  606.                 print("Fuel level: "..fuel)
  607.             end
  608.         elseif (param == 24) then
  609.             RCmaster_keys_send()
  610.         elseif (param == 48) then
  611.             RCmaster()
  612.         elseif (param == 49) then
  613.             rednet.broadcast("TS Refuel")
  614.             print("Refuel")
  615.             print("")
  616.             print("Coordinates: "..coords)
  617.             print("Fuel level: "..fuel)
  618.         end
  619.     end
  620. end
  621. end
  622.  
  623. function RCmaster_keys_send()
  624. fuel = ""
  625. coords = ""
  626. term.clear()
  627. term.setCursorPos(1,1)
  628. print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  629. print("W/A/S/D: Movement\nQ/E: Up and Down\nZ/X/C: Place blocks Down, In Front and Up\nR/F: Change slots\nT: Output redstone signal\nG: Attack\nV: Mine Down, In Front and Up\nH: Display help\nUp/Down arrows: Change sending ID\nO: Change mode\nB: Back to menu based control\nN: Refuel\n(Press any key to continue...)")
  630. local sEvent, param = os.pullEvent("key")
  631. if(sEvent == "key") then
  632. end
  633. term.clear()
  634. term.setCursorPos(1,1)
  635. print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  636. print("")
  637. print("")
  638. print("Coordinates: "..coords)
  639. print("Fuel level: "..fuel)
  640. while true do
  641.     local sEvent, param = os.pullEvent("key")
  642.     if(sEvent == "key") then
  643.         if(param == 17) then
  644.             rednet.send(tid, "TS Forward")
  645.             data_send()
  646.             term.clear()
  647.             term.setCursorPos(1,1)
  648.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  649.             print("Forward")
  650.             print("")
  651.             print("Coordinates: "..coords)
  652.             print("Fuel level: "..fuel)
  653.         elseif (param == 31) then
  654.             rednet.send(tid, "TS Backward")
  655.             data_send()
  656.             term.clear()
  657.             term.setCursorPos(1,1)
  658.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  659.             print("Backward")
  660.             print("")
  661.             print("Coordinates: "..coords)
  662.             print("Fuel level: "..fuel)
  663.         elseif (param == 30) then
  664.             rednet.send(tid, "TS TurnLeft")
  665.             term.clear()
  666.             term.setCursorPos(1,1)
  667.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  668.             print("Turn Left")
  669.             print("")
  670.             print("Coordinates: "..coords)
  671.             print("Fuel level: "..fuel)
  672.         elseif (param == 32) then
  673.             rednet.send(tid, "TS TurnRight")
  674.             term.clear()
  675.             term.setCursorPos(1,1)
  676.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  677.             print("Turn Right")
  678.             print("")
  679.             print("Coordinates: "..coords)
  680.             print("Fuel level: "..fuel)
  681.         elseif (param == 18) then
  682.             rednet.send(tid, "TS Up")
  683.             data_send()
  684.             term.clear()
  685.             term.setCursorPos(1,1)
  686.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  687.             print("Up")
  688.             print("")
  689.             print("Coordinates: "..coords)
  690.             print("Fuel level: "..fuel)
  691.         elseif (param == 16) then
  692.             rednet.send(tid, "TS Down")
  693.             data_send()
  694.             term.clear()
  695.             term.setCursorPos(1,1)
  696.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  697.             print("Down")
  698.             print("")
  699.             print("Coordinates: "..coords)
  700.             print("Fuel level: "..fuel)
  701.         elseif (param == 45) then
  702.             rednet.send(tid, "TS PlaceBlock")
  703.             term.clear()
  704.             term.setCursorPos(1,1)
  705.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  706.             print("Place Block")
  707.             print("")
  708.             print("Coordinates: "..coords)
  709.             print("Fuel level: "..fuel)
  710.         elseif (param == 46) then
  711.             rednet.send(tid, "TS PlaceBlockUp")
  712.             term.clear()
  713.             term.setCursorPos(1,1)
  714.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  715.             print("Place Block Up")
  716.         elseif (param == 44) then
  717.             rednet.send(tid, "TS PlaceBlockDown")
  718.             term.clear()
  719.             term.setCursorPos(1,1)
  720.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  721.             print("Place Block Down")
  722.             print("")
  723.             print("Coordinates: "..coords)
  724.             print("Fuel level: "..fuel)
  725.         elseif (param == 19) then
  726.             if s >= 16 then
  727.                 term.clear()
  728.                 term.setCursorPos(1,1)
  729.                 print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  730.                 print("No more slots left")
  731.                 print("")
  732.                 print("Coordinates: "..coords)
  733.                 print("Fuel level: "..fuel)
  734.             else
  735.                 rednet.send(tid, "TS NextSlot")
  736.                 s=s+1
  737.                 rednet.send(tid, tostring(s))
  738.                 term.clear()
  739.                 term.setCursorPos(1,1)
  740.                 print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  741.                 print("Now using slot " ..s)
  742.                 print("")
  743.                 print("Coordinates: "..coords)
  744.                 print("Fuel level: "..fuel)
  745.             end
  746.         elseif (param == 33) then
  747.             if s <= 1 then
  748.                 term.clear()
  749.                 term.setCursorPos(1,1)
  750.                 print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  751.                 print("No more slots left")
  752.                 print("")
  753.                 print("Coordinates: "..coords)
  754.                 print("Fuel level: "..fuel)
  755.             else
  756.                 rednet.send(tid, "TS PreviousSlot")
  757.                 s=s-1
  758.                 rednet.send(tid, tostring(s))
  759.                 term.clear()
  760.                 term.setCursorPos(1,1)
  761.                 print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  762.                 print("Now using slot " ..s)
  763.                 print("")
  764.                 print("Coordinates: "..coords)
  765.                 print("Fuel level: "..fuel)
  766.             end
  767.         elseif (param == 20) then
  768.             rednet.send(tid, "TS Redstone")
  769.             term.clear()
  770.             term.setCursorPos(1,1)
  771.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  772.             print("Redstone")
  773.             print("")
  774.             print("Coordinates: "..coords)
  775.             print("Fuel level: "..fuel)
  776.         elseif (param == 34) then
  777.             rednet.send(tid, "TS Attack")
  778.             term.clear()
  779.             term.setCursorPos(1,1)
  780.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  781.             print("Attack")
  782.             print("")
  783.             print("Coordinates: "..coords)
  784.             print("Fuel level: "..fuel)
  785.         elseif (param == 47) then
  786.             rednet.send(tid, "TS Mine")
  787.             term.clear()
  788.             term.setCursorPos(1,1)
  789.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  790.             print("Mine")
  791.             print("")
  792.             print("Coordinates: "..coords)
  793.             print("Fuel level: "..fuel)
  794.         elseif (param == 35) then
  795.             term.clear()
  796.             term.setCursorPos(1,1)
  797.             print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  798.             print("W/A/S/D: Movement\nQ/E: Up and Down\nZ/X/C: Place blocks Down, In Front and Up\nR/F: Change slots\nT: Output redstone signal\nG: Attack\nV: Mine Down, In Front and Up\nH: Display help\nUp/Down arrows: Change sending ID\nO: Change mode\nB: Back to menu based control\nN: Refuel\n(Press any key to continue...)")
  799.             local sEvent, param = os.pullEvent("key")
  800.            if(sEvent == "key") then
  801.                 term.clear()
  802.                 term.setCursorPos(1,1)
  803.                 print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  804.                 print("")
  805.                 print("")
  806.                 print("Coordinates: "..coords)
  807.                 print("Fuel level: "..fuel)
  808.             end
  809.         elseif (param == 200) then
  810.             if tid >= 100000000 then
  811.             else
  812.                 tid=tid+1
  813.                 term.clear()
  814.                 term.setCursorPos(1,1)
  815.                 print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  816.                 print("Now sending to " ..tid)
  817.                 print("")
  818.                 print("Coordinates: "..coords)
  819.                 print("Fuel level: "..fuel)
  820.             end
  821.         elseif (param == 208) then
  822.             if tid <= 1 then
  823.             else
  824.                 tid=tid-1
  825.                 term.clear()
  826.                 term.setCursorPos(1,1)
  827.                 print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  828.                 print("Now sending to " ..tid)
  829.                 print("")
  830.                 print("Coordinates: "..coords)
  831.                 print("Fuel level: "..fuel)
  832.             end
  833.         elseif (param == 24) then
  834.             RCmaster_keys()
  835.         elseif (param == 48) then
  836.             RCmaster_send()
  837.         elseif (param == 49) then
  838.             rednet.send(tid, "TS Refuel")
  839.             print("Refuel")
  840.             print("")
  841.             print("Coordinates: "..coords)
  842.             print("Fuel level: "..fuel)
  843.         end
  844.     end
  845. end
  846. end
  847.  
  848. function RCmaster_mouse()
  849. fuel = ""
  850. coords = ""
  851. while true do
  852.     term.clear()
  853.     term.setCursorPos(1,1)
  854.     print("TurtleControl V "..version..". Mode: Broadcast")
  855.     print("- Movement")
  856.     print("- Block Placing")
  857.     print("- Others")
  858.     print("- Exit")
  859.     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  860.     if(sEvent == "mouse_click") then
  861.         if (param == 1) then
  862.             if (xMousePos <= 10 and yMousePos == 2 and xMousePos >= 1) then
  863.                 while true do
  864.                     term.clear()
  865.                     term.setCursorPos(1,1)
  866.                     print("TurtleControl V "..version..". Mode: Broadcast")
  867.                     print("- Forward")
  868.                     print("- Backward")
  869.                     print("- Turn Left")
  870.                     print("- Turn Right")
  871.                     print("- Up")
  872.                     print("- Down")
  873.                     print("- Attack")
  874.                     print("- Mine")
  875.                     print("- Return to main menu")
  876.                     print("")
  877.                     print("Coordinates: "..coords)
  878.                     print("Fuel level: "..fuel)
  879.                     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  880.                     if(sEvent == "mouse_click") then
  881.                         if (param == 1) then
  882.                             if (xMousePos <= 9 and yMousePos == 2 and xMousePos >= 1) then
  883.                                 rednet.broadcast("TS Forward")
  884.                                 data()
  885.                             elseif (xMousePos <= 10 and yMousePos == 3 and xMousePos >= 1) then
  886.                                 rednet.broadcast("TS Backward")
  887.                                 data()
  888.                             elseif (xMousePos <= 11 and yMousePos == 4 and xMousePos >= 1) then
  889.                                 rednet.broadcast("TS TurnLeft")
  890.                             elseif (xMousePos <= 12 and yMousePos == 5 and xMousePos >= 1) then
  891.                                 rednet.broadcast("TS TurnRight")
  892.                             elseif (xMousePos <= 4 and yMousePos == 6 and xMousePos >= 1) then
  893.                                 rednet.broadcast("TS Up")
  894.                                 data()
  895.                             elseif (xMousePos <= 6 and yMousePos == 7 and xMousePos >= 1) then
  896.                                 rednet.broadcast("TS Down")
  897.                                 data()
  898.                             elseif (xMousePos <= 8 and yMousePos == 8 and xMousePos >= 1) then
  899.                                 rednet.broadcast("TS Attack")
  900.                             elseif (xMousePos <= 12 and yMousePos == 9 and xMousePos >= 1) then
  901.                                 rednet.broadcast("TS Mine")
  902.                             elseif (xMousePos <= 21 and yMousePos == 10 and xMousePos >= 1) then
  903.                                 RCmaster_mouse()
  904.                             end
  905.                         end
  906.                     end
  907.                 end
  908.             elseif (xMousePos <= 15 and yMousePos == 3 and xMousePos >= 1) then
  909.                 while true do
  910.                     term.clear()
  911.                     term.setCursorPos(1,1)
  912.                     print("TurtleControl V "..version..". Mode: Broadcast")
  913.                     print("- Place in front")
  914.                     print("- Place Up")
  915.                     print("- Place Down")
  916.                     print("- Return to main menu")
  917.                     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  918.                     if(sEvent == "mouse_click") then
  919.                         if (param == 1) then
  920.                             if (xMousePos <= 16 and yMousePos == 2 and xMousePos >= 1) then
  921.                                 rednet.broadcast("TS PlaceBlock")
  922.                             elseif (xMousePos <= 10 and yMousePos == 3 and xMousePos >= 1)then
  923.                                 rednet.broadcast("TS PlaceBlockUp")
  924.                             elseif (xMousePos <= 12 and yMousePos == 4 and xMousePos >= 1) then
  925.                                 rednet.broadcast("TS PlaceBlockDown")
  926.                             elseif (xMousePos <= 21 and yMousePos == 5 and xMousePos >= 1) then
  927.                                 RCmaster_mouse()
  928.                             end
  929.                         end
  930.                     end
  931.                 end
  932.             elseif (xMousePos <= 8 and yMousePos == 4 and xMousePos >= 1) then
  933.                 while true do
  934.                     term.clear()
  935.                     term.setCursorPos(1,1)
  936.                     print("TurtleControl V "..version..". Mode: Broadcast")
  937.                     print("- Redstone Current")
  938.                     print("- Refuel (Use coal only)")
  939.                     print("- Slot Forward")
  940.                     print("- Slot Backward")
  941.                     print("- Use *Send* instead of *Broadcast*")
  942.                     print("- Key based control")
  943.                     print("- Menu based control")
  944.                     print("- Remote program")
  945.                     print("- Return to main menu")
  946.                     print("")
  947.                     print("Current Slot: "..s)
  948.                     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  949.                     if(sEvent == "mouse_click") then
  950.                         if (param == 1) then
  951.                             if (xMousePos <= 18 and yMousePos == 2 and xMousePos >= 1) then
  952.                                 rednet.broadcast("TS Redstone")
  953.                             elseif (xMousePos <= 24 and yMousePos == 3 and xMousePos >= 1) then
  954.                                 rednet.broadcast("TS Refuel")
  955.                             elseif (xMousePos <= 14 and yMousePos == 4 and xMousePos >= 1) then
  956.                                 if s >= 16 then
  957.                                 else
  958.                                     rednet.broadcast("TS NextSlot")
  959.                                     s=s+1
  960.                                     rednet.broadcast(tostring(s))
  961.                                 end
  962.                             elseif (xMousePos <= 15 and yMousePos == 5 and xMousePos >= 1) then
  963.                                 if s <= 1 then
  964.                                 else
  965.                                     rednet.broadcast("TS PreviousSlot")
  966.                                     s=s-1
  967.                                     rednet.broadcast(tostring(s))
  968.                                 end
  969.                             elseif (xMousePos <= 35 and yMousePos == 6 and xMousePos >= 1) then
  970.                                 RCmaster_mouse_send()
  971.                             elseif (xMousePos <= 19 and yMousePos == 7 and xMousePos >= 1) then
  972.                                 RCmaster_keys()
  973.                             elseif (xMousePos <= 20 and yMousePos == 8 and xMousePos >= 1) then
  974.                                 RCmaster()
  975.                             elseif (xMousePos <= 16 and yMousePos == 9 and xMousePos >= 1) then
  976.                                 rednet.broadcast("TS Program")
  977.                                 term.clear()
  978.                                 term.setCursorPos(1,1)
  979.                                 print("What program do you want to run?")
  980.                                 program = io.read()
  981.                                 rednet.broadcast(program)
  982.                             elseif (xMousePos <= 21 and yMousePos == 10 and xMousePos >= 1) then
  983.                                 RCmaster_mouse()
  984.                             end
  985.                         end
  986.                     end
  987.                 end
  988.             elseif (xMousePos <= 6 and yMousePos == 5 and xMousePos >= 1) then
  989.                 os.reboot()
  990.             end
  991.         end
  992.     end
  993. end
  994. end
  995.  
  996. function RCmaster_mouse_send()
  997. fuel = ""
  998. coords = ""
  999. while true do
  1000.     term.clear()
  1001.     term.setCursorPos(1,1)
  1002.     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  1003.     print("- Movement")
  1004.     print("- Block Placing")
  1005.     print("- Others")
  1006.     print("- Exit")
  1007.     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  1008.     if(sEvent == "mouse_click") then
  1009.         if (param == 1) then
  1010.             if (xMousePos <= 10 and yMousePos == 2 and xMousePos >= 1) then
  1011.                 while true do
  1012.                     term.clear()
  1013.                     term.setCursorPos(1,1)
  1014.                     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  1015.                     print("- Forward")
  1016.                     print("- Backward")
  1017.                     print("- Turn Left")
  1018.                     print("- Turn Right")
  1019.                     print("- Up")
  1020.                     print("- Down")
  1021.                     print("- Attack")
  1022.                     print("- Mine")
  1023.                     print("- Return to main menu")
  1024.                     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  1025.                     if(sEvent == "mouse_click") then
  1026.                         if (param == 1) then
  1027.                             if (xMousePos <= 9 and yMousePos == 2 and xMousePos >= 1) then
  1028.                                 rednet.send(tid, "TS Forward")
  1029.                                 data_send()
  1030.                             elseif (xMousePos <= 10 and yMousePos == 3 and xMousePos >= 1) then
  1031.                                 rednet.send(tid, "TS Backward")
  1032.                                 data_send()
  1033.                             elseif (xMousePos <= 11 and yMousePos == 4 and xMousePos >= 1) then
  1034.                                 rednet.send(tid, "TS TurnLeft")
  1035.                             elseif (xMousePos <= 12 and yMousePos == 5 and xMousePos >= 1) then
  1036.                                 rednet.send(tid, "TS TurnRight")
  1037.                             elseif (xMousePos <= 4 and yMousePos == 6 and xMousePos >= 1) then
  1038.                                 rednet.send(tid, "TS Up")
  1039.                                 data_send()
  1040.                             elseif (xMousePos <= 6 and yMousePos == 7 and xMousePos >= 1) then
  1041.                                 rednet.send(tid, "TS Down")
  1042.                                 data_send()
  1043.                             elseif (xMousePos <= 8 and yMousePos == 8 and xMousePos >= 1) then
  1044.                                 rednet.send(tid, "TS Attack")
  1045.                             elseif (xMousePos <= 12 and yMousePos == 9 and xMousePos >= 1) then
  1046.                                 rednet.send(tid, "TS Mine")
  1047.                             elseif (xMousePos <= 21 and yMousePos == 10 and xMousePos >= 1) then
  1048.                                 RCmaster_mouse_send()
  1049.                             end
  1050.                         end
  1051.                     end
  1052.                 end
  1053.             elseif (xMousePos <= 15 and yMousePos == 3 and xMousePos >= 1) then
  1054.                 while true do
  1055.                     term.clear()
  1056.                     term.setCursorPos(1,1)
  1057.                     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  1058.                     print("- Place in front")
  1059.                     print("- Place Up")
  1060.                     print("- Place Down")
  1061.                     print("- Return to main menu")
  1062.                     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  1063.                     if(sEvent == "mouse_click") then
  1064.                         if (param == 1) then
  1065.                             if (xMousePos <= 16 and yMousePos == 2 and xMousePos >= 1) then
  1066.                                 rednet.send(tid, "TS PlaceBlock")
  1067.                             elseif (xMousePos <= 10 and yMousePos == 3 and xMousePos >= 1)then
  1068.                                 rednet.send(tid, "TS PlaceBlockUp")
  1069.                             elseif (xMousePos <= 12 and yMousePos == 4 and xMousePos >= 1) then
  1070.                                 rednet.send(tid, "TS PlaceBlockDown")
  1071.                             elseif (xMousePos <= 21 and yMousePos == 5 and xMousePos >= 1) then
  1072.                                 RCmaster_mouse_send()
  1073.                             end
  1074.                         end
  1075.                     end
  1076.                 end
  1077.             elseif (xMousePos <= 8 and yMousePos == 4 and xMousePos >= 1) then
  1078.                 while true do
  1079.                     term.clear()
  1080.                     term.setCursorPos(1,1)
  1081.                     print("TurtleControl V "..version..". Mode: Send. Sending to ID: "..tid)
  1082.                     print("- Redstone Current")
  1083.                     print("- Refuel (Use coal only)")
  1084.                     print("- Slot Forward")
  1085.                     print("- Slot Backward")
  1086.                     print("- Use *Broadcast* instead of *Send*")
  1087.                     print("- Send ID Forward")
  1088.                     print("- Send ID Backward")
  1089.                     print("- Key based control")
  1090.                     print("- Menu based control")
  1091.                     print("- Remote program")
  1092.                     print("- Return to main menu")
  1093.                     print("")
  1094.                     print("Current Slot: "..s)
  1095.                     print("Selected ID: "..tid)
  1096.                     local sEvent, param, xMousePos, yMousePos = os.pullEvent("mouse_click")
  1097.                     if(sEvent == "mouse_click") then
  1098.                         if (param == 1) then
  1099.                             if (xMousePos <= 18 and yMousePos == 2 and xMousePos >= 1) then
  1100.                                 rednet.send(tid, "TS Redstone")
  1101.                             elseif (xMousePos <= 24 and yMousePos == 3 and xMousePos >= 1) then
  1102.                                 rednet.send(tid, "TS Refuel")
  1103.                             elseif (xMousePos <= 14 and yMousePos == 4 and xMousePos >= 1) then
  1104.                                 if s >= 16 then
  1105.                                 else
  1106.                                     rednet.send(tid, "TS NextSlot")
  1107.                                     s=s+1
  1108.                                     rednet.send(tid, tostring(s))
  1109.                                 end
  1110.                             elseif (xMousePos <= 15 and yMousePos == 5 and xMousePos >= 1) then
  1111.                                 if s <= 1 then
  1112.                                 else
  1113.                                     rednet.send(tid, "TS PreviousSlot")
  1114.                                     s=s-1
  1115.                                     rednet.send(tid, tostring(s))
  1116.                                 end
  1117.                             elseif (xMousePos <= 35 and yMousePos == 6 and xMousePos >= 1) then
  1118.                                 RCmaster_mouse()
  1119.                             elseif (xMousePos <= 19 and yMousePos == 7 and xMousePos >= 1) then
  1120.                                 if tid >= 100000000 then
  1121.                                 else
  1122.                                     tid=tid+1
  1123.                                 end
  1124.                             elseif (xMousePos <= 17 and yMousePos == 8 and xMousePos >= 1) then
  1125.                                 if tid <= 1 then
  1126.                                 else
  1127.                                     tid=tid-1
  1128.                                 end
  1129.                             elseif (xMousePos <= 19 and yMousePos == 9 and xMousePos >= 1) then
  1130.                                 RCmaster_keys_send()
  1131.                             elseif (xMousePos <= 20 and yMousePos == 10 and xMousePos >= 1) then
  1132.                                 RCmaster_send()
  1133.                             elseif (xMousePos <= 16 and yMousePos == 11 and xMousePos >= 1) then
  1134.                                 rednet.send(tid, "TS Program")
  1135.                                 term.clear()
  1136.                                 term.setCursorPos(1,1)
  1137.                                 print("What program do you want to run?")
  1138.                                 program = io.read()
  1139.                                 rednet.send(tid, program)
  1140.                             elseif (xMousePos <= 21 and yMousePos == 12 and xMousePos >= 1) then
  1141.                                 RCmaster_mouse_send()
  1142.                             end
  1143.                         end
  1144.                     end
  1145.                 end
  1146.             elseif (xMousePos <= 6 and yMousePos == 5 and xMousePos >= 1) then
  1147.                 os.reboot()
  1148.             end
  1149.         end
  1150.     end
  1151. end
  1152. end
  1153.  
  1154. function startup()
  1155. local bOpen, sFreeSide = false, nil
  1156. for n,sSide in pairs(rs.getSides()) do 
  1157.     if peripheral.getType( sSide ) == "modem" then
  1158.         sFreeSide = sSide
  1159.         if rednet.isOpen( sSide ) then
  1160.             bOpen = true
  1161.         end
  1162.     end
  1163. end
  1164. if not bOpen then
  1165.     if sFreeSide then
  1166.         rednet.open( sFreeSide )
  1167.     else
  1168.         print("No modem attached")
  1169.         print("Press any key to continue")
  1170.         local sEvent, param = os.pullEvent("key")
  1171.         if(sEvent == "key") then
  1172.             os.reboot()
  1173.         end
  1174.     end
  1175. end
  1176. term.clear()
  1177. term.setCursorPos(1,1)
  1178. textutils.slowPrint("TurtleControl V "..version.." Initiated.")
  1179. sleep(2)
  1180. sid=0
  1181. fuel = ""
  1182. coords = ""
  1183. while true do
  1184.     term.clear()
  1185.     term.setCursorPos(1,1)
  1186.     print("What mode do you want to use?")
  1187.     menu(0, "Menu Mode")
  1188.     menu(1, "Key Mode")
  1189.     menu(2, "Cursor Mode")
  1190.     local sEvent, param = os.pullEvent("key")
  1191.     if(sEvent == "key") then
  1192.         if(param == 200) then
  1193.             if sid > 0 then
  1194.                 sid = sid - 1
  1195.             elseif sid == 0 then
  1196.                 sid = 2
  1197.             end
  1198.         elseif (param == 208) then
  1199.             if sid < 2 then
  1200.                 sid = sid + 1
  1201.             elseif sid == 2 then
  1202.                 sid = 0
  1203.             end
  1204.         elseif (param == 28) then
  1205.             if sid == 0 then
  1206.                 RCmaster()
  1207.             elseif sid == 1 then
  1208.                 RCmaster_keys()
  1209.             elseif sid == 2 then
  1210.                 RCmaster_mouse()
  1211.             end
  1212.         end
  1213.     end
  1214. end
  1215. end
  1216.  
  1217. function data()
  1218. sleep(.2)
  1219. rednet.broadcast("TS GetPos")
  1220. sleep(.1)
  1221. scrap, message = rednet.receive(.2)
  1222. if message ~= nil then
  1223.     coords = message
  1224. else
  1225.     coords = "Couldn't contact turtle"
  1226. end
  1227. sleep(.2)
  1228. rednet.broadcast("TS GetFuel")
  1229. sleep(.1)
  1230. scrap, message = rednet.receive(.2)
  1231. if message ~= nil then
  1232.     fuel = message
  1233. else
  1234.     fuel = "Couldn't contact turtle"
  1235. end
  1236. end
  1237.  
  1238. function data_send()
  1239. sleep(.2)
  1240. rednet.send(tid, "TS GetPos")
  1241. sleep(.1)
  1242. scrap, message = rednet.receive(.2)
  1243. if message ~= nil then
  1244.     coords = message
  1245. else
  1246.     coords = "Couldn't contact turtle"
  1247. end
  1248. sleep(.2)
  1249. rednet.send(tid, "TS GetFuel")
  1250. sleep(.1)
  1251. scrap, message = rednet.receive(.2)
  1252. if message ~= nil then
  1253.     fuel = message
  1254. else
  1255.     fuel = "Couldn't contact turtle"
  1256. end
  1257. end
  1258.  
  1259. tid=1
  1260. s=1
  1261. version=1.0
  1262. startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement