heresjohnny32

computercraft2

Feb 12th, 2021
1,654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.30 KB | None | 0 0
  1. if turtle then
  2. print[[---------------------------------------
  3. Welcome to RemoteTurtle V2.2.4
  4. ---------------------------------------]]
  5. else
  6. if term.isColor() then
  7. term.setTextColor(colors.lime)
  8. end
  9. print[[---------------------------------------------------
  10. Welcome to RemoteTurtle V2.2.4
  11. ---------------------------------------------------
  12. ]]
  13. end
  14. if term.isColor() then
  15. term.setTextColor(colors.white)
  16. end
  17. repeat
  18.   print("Does the program already exist on your device")
  19.   q=read()
  20.   if
  21.         q==("yes")
  22.   then
  23.         sleep(0)
  24.   else
  25.         if
  26.           q==("no")
  27.         then
  28.           os.setComputerLabel("not yet defined")
  29.           fs.copy("disk/startup","startup")
  30.           print("You can now safely break the device and place it somewhere else without program loss")
  31.  
  32.           error()  
  33.          end
  34.   end
  35. until q==("yes") or q==("no")
  36.  
  37. print("")
  38. repeat
  39.   print("Do you want this device to transmit or receive?")
  40.   p=read()
  41.   if
  42.         p==("receive")
  43.   then
  44.  
  45. os.setComputerLabel("Remote Turtle")
  46. print("")
  47. shell.run("id")
  48. rednet.open("right")
  49. print("")
  50. print("What Id Do You Want To Link To?")
  51. l=tonumber(read())
  52. repeat
  53. i,k=rednet.receive()
  54. z=turtle.getFuelLevel()
  55. if
  56.   z==0 then
  57.   shell.run("refuel")
  58. end
  59. z=turtle.getFuelLevel()
  60. if
  61.   z==0 then
  62.   rednet.send(l,"p2")
  63. end
  64. if
  65.   l==i and k==("w") then
  66.   turtle.forward()
  67. elseif
  68.   l==i and k==("a") then
  69.   turtle.turnLeft()
  70. elseif
  71.   l==i and k==("s") then
  72.   turtle.turnRight()
  73.   turtle.turnRight()
  74. elseif
  75.   l==i and k==("d") then
  76.   turtle.turnRight()
  77. elseif
  78.   l==i and k==("q") then
  79.   turtle.up()
  80. elseif
  81.   l==i and k==("z") then
  82.   turtle.down()
  83. elseif
  84.   l==i and k==("r") then
  85.   shell.run("refuel")
  86. elseif
  87.   l==i and k==("x") then
  88.   turtle.dig()
  89. elseif
  90.   l==i and k==("xup") then
  91.   turtle.digUp()
  92. elseif
  93.   l==i and k==("xdown") then
  94.   turtle.digDown()
  95. elseif
  96.   l==i and tonumber(k)~=nil then -- dig up, Left, up, right, right, down, left
  97.   while k>=1 do
  98.     turtle.digUp()
  99.     turtle.turnLeft()
  100.     turtle.dig()
  101.     turtle.up()
  102.     turtle.dig()
  103.     turtle.turnRight()
  104.     turtle.turnRight()
  105.     turtle.dig()
  106.     turtle.down()
  107.     turtle.dig()
  108.     turtle.turnLeft()
  109.     k = k-1
  110.     if
  111.         k>=1 then
  112.         turtle.dig()
  113.         turtle.forward()
  114.     end
  115.   end
  116. elseif
  117.   l==i and k==("clear") then
  118.   os.setComputerLabel("")
  119. elseif
  120.   l==i and k==("f") then
  121.   turtle.attack()
  122. elseif
  123.   l==i and k==("fup") then
  124.   turtle.attackUp()
  125. elseif
  126.   l==i and k==("fdown") then
  127.   turtle.attackDown()
  128. elseif
  129.   l==i and k==("reboot") then
  130.   os.reboot()
  131. elseif
  132.   l==i and k==("shutdown") then
  133.   os.shutdown()
  134. elseif
  135.   l==i and k==(cmd1) then
  136.   turtle[cmd1e]()
  137. elseif
  138.   l==i and k==(cmd2) then
  139.   turtle[cmd2e]()
  140. elseif
  141.   l==i and k==(cmd3) then
  142.   turtle[cmd3e]()
  143. elseif
  144.  
  145.   l==i and k==("AddCommand") then
  146.   print("Which command do you want to change? 1/2/3")
  147.   cwhat=read()
  148.   print("for the question :What do you want to execute? you answer has to be what would fill in the blank spot: turtle.[BLANK SPOT]()")
  149.  
  150.   if cwhat == ("1") then
  151.         print("What do you want to type to to execute")
  152.  
  153.         cmd1=read()  
  154.         print("What do you want to execute?")
  155.         cmd1e=read()
  156.   elseif
  157.         chwat == ("2") then
  158.         print("What do you want to type to execute?")
  159.         cmd2=read()
  160.         print("What do you want to execute?")
  161.         cmd2e=read()
  162.   elseif
  163.         chwat == ("3") then
  164.         print("What do you want to type to execute?")
  165.         cmd3=read()
  166.         print("What do you want to execute?")
  167.         cmd3e=read()
  168.   end
  169.  
  170.  
  171. else
  172.   sleep(0.2)
  173.   print("Doesn't match")
  174.   rednet.send(l,"p")
  175. end
  176. sleep(0.2)
  177. rednet.send(l,"Matches")
  178.  
  179. until
  180. l==i and k==("stop") or l==i and k==("clear")
  181. elseif
  182.         p==("transmit")
  183.   then
  184.         os.setComputerLabel("Remote Controller")
  185.         print("")
  186.         shell.run("id")
  187.         print("")
  188.  
  189.  
  190.           if
  191.                 peripheral.getType("right") == "modem" then
  192.                 rednet.open("right")
  193.           elseif
  194.                 peripheral.getType("left") == "modem" then
  195.                 rednet.open("left")
  196.           elseif
  197.                 peripheral.getType("top") == "modem" then
  198.                 rednet.open("top")
  199.           elseif
  200.                 peripheral.getType("bottom") == "modem" then
  201.                 rednet.open("bottom")
  202.           elseif
  203.                 peripheral.getType("back") == "modem" then
  204.                 rednet.open("back")
  205.           elseif
  206.                 peripheral.getType("front") == "modem" then
  207.                 rednet.open("front")
  208.           end
  209.  
  210.  
  211.  
  212.         print("")
  213.  
  214.         print("What id would you like to connect to?")
  215.         l=tonumber(read())
  216.  
  217.         print("")
  218.         print("Type /list for a list of commands")
  219.         print("")
  220.  
  221.         repeat
  222.           write("Command : ")
  223.           x=read()
  224.           if
  225.                 x==("/list")
  226.           then
  227.                 print("r --> refuel (This should be done automaticly)")
  228.                 print("w/a/s/d --> movement")
  229.                 print("q/z --> up/down")
  230.                 print("x --> dig")
  231.                 print("xup --> dig up")
  232.                 print("xdown --> dig down")
  233.                 print("tunnel --> dig 3x2")
  234.                 print("f --> attack")
  235.                 print("fup/fdown --> attacks up/down")
  236.                 print("shutdown --> Shuts down transmitter and receiver")
  237.                 print("reboot --> reboots transmitter and receiver")
  238.                 print("stop --> Stops using this program")
  239.                 print("clear --> Clear Memory after picking up")
  240.                 print("AddCommand --> Allows you to add commands")
  241.  
  242.           elseif
  243.                 x==("AddCommand") then
  244.                 print("To set this up you have to go to your turtle")
  245.                 rednet.send(l,x)
  246.  
  247.           else
  248.                 if
  249.                     x=="tunnel"
  250.                 then
  251.                     repeat
  252.                     print("how many times?")
  253.                     z = tonumber(read())
  254.                     until z >=1
  255.                     rednet.send(l,z)
  256.                 else
  257.                     rednet.send(l,x)
  258.                     end
  259.                 sleep(0.00000001)
  260.                 y,u=rednet.receive(3)
  261.                 if u==("p2") and y==l then
  262.                   if term.isColor() then
  263.                         term.setTextColor(colors.red)
  264.                   end
  265.                   print("Out of coal and fuel")
  266.                   if term.setTextColor then
  267.                         term.setTextColor(colors.white)
  268.                   end                  
  269.                 end
  270.                 if u==("p") and y==l then
  271.                   if term.isColor() then
  272.                         term.setTextColor(colors.red)
  273.                   end
  274.                   print("Incorrect Comand")
  275.                   if term.isColor() then
  276.                         term.setTextColor(colors.white)
  277.                   end
  278.  
  279.                 elseif u==("Matches") and y==l then
  280.                   if term.isColor() then
  281.                         term.setTextColor(colors.green)
  282.                   end
  283.                 end
  284.                   print("Command Correct")
  285.                   if term.isColor() then
  286.                         term.setTextColor(colors.white)
  287.                   end
  288.                 end
  289.  
  290.         until
  291.           x==("clear") or x==("stop")
  292.         end
  293.  
  294.         if
  295.           x==("clear")
  296.         then
  297.           os.setComputerLabel("")
  298.         end
  299.  
  300.   until
  301. p==("receive") or p==("transmit")
Advertisement
Add Comment
Please, Sign In to add comment