Ninja8370

Remote Control GUI

Mar 3rd, 2015
2,421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.78 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. rednet.open("back")
  5.  
  6.  
  7. --ID test-read
  8. local file = fs.open("config","r")
  9. id = tonumber(file.readAll())
  10. file.close()
  11.  
  12. --Config fix(if needed)
  13. function confix()
  14.         if id == nil then
  15.                 local file = fs.open("config","w")
  16.                 file.write(tostring(000))
  17.                 file.close()
  18.                 sleep(1)
  19.         end
  20. end
  21.  
  22. --run confix
  23.  
  24. confix()
  25.  
  26.  
  27. --Fixed id
  28.  
  29. local file = fs.open("config","r")
  30. id = tonumber(file.readAll())
  31. file.close()
  32.  
  33.  
  34.  
  35. function setup()
  36.         term.clear()
  37.         term.setCursorPos(1,1)
  38.         print("Remote Control GUI v2.2 - [Setup]")
  39.         term.setCursorPos(3,3)
  40.         print("Turtle ID:")
  41.         term.setCursorPos(3,4)
  42.        
  43.         local file = fs.open("config","w")
  44.         file.write(tostring(read()))
  45.         file.close()
  46.         sleep(1)
  47.        
  48.         shell.run("startup")
  49.        
  50. end
  51.  
  52.  
  53.  
  54. function GUI()
  55.  
  56. while true do
  57.         term.clear()
  58.         term.setCursorPos(1,1)
  59.         print("Remote Control GUI v2.2")
  60. --Buttons- up, down
  61.         paintutils.drawFilledBox(1,2,6,4,colors.cyan)
  62.        
  63.         paintutils.drawFilledBox(1,7,6,9,colors.cyan)
  64.        
  65.         paintutils.drawFilledBox(10,2,19,4,colors.cyan)
  66.        
  67.         paintutils.drawFilledBox(7,5,13,7,colors.cyan)
  68.        
  69.         paintutils.drawFilledBox(16,5,22,7,colors.cyan)
  70.        
  71.         paintutils.drawFilledBox(10,8,19,10,colors.cyan)
  72.        
  73.         paintutils.drawFilledBox(1,12,6,13,colors.brown)
  74.        
  75.         paintutils.drawFilledBox(1,15,6,16,colors.brown)
  76.        
  77.         paintutils.drawFilledBox(1,18,6,19,colors.brown)
  78.        
  79.         paintutils.drawFilledBox(8,12,14,13,colors.green)
  80.        
  81.         paintutils.drawFilledBox(8,15,14,16,colors.green)
  82.        
  83.         paintutils.drawFilledBox(8,18,14,19,colors.green)
  84.        
  85.         paintutils.drawFilledBox(24,2,26,2,colors.blue)
  86.        
  87.         paintutils.drawFilledBox(25,3,26,18,colors.blue)
  88.        
  89.         paintutils.drawFilledBox(16,12,22,13,colors.red)
  90.        
  91.         paintutils.drawFilledBox(16,15,22,16,colors.red)
  92.        
  93.         paintutils.drawFilledBox(16,18,22,19,colors.red)
  94.  
  95.  
  96.         term.setCursorPos(3,3)
  97.         term.setBackgroundColor(colors.cyan)
  98.         print("UP")
  99.         term.setCursorPos(2,8)
  100.         print("DOWN")
  101.         term.setCursorPos(12,3)
  102.         print("FORWARD")
  103.         term.setCursorPos(9,6)
  104.         print("LEFT")
  105.         term.setCursorPos(17,6)
  106.         print("RIGHT")
  107.         term.setCursorPos(13,9)
  108.         print("BACK")
  109.  
  110.         term.setBackgroundColor(colors.brown)
  111.                 term.setCursorPos(2,12)
  112.                 print("DIG")
  113.                 term.setCursorPos(3,13)
  114.                 print("UP")
  115.         term.setCursorPos(2,16)
  116.         print("DIG")
  117.                 term.setCursorPos(2,18)
  118.                 print("DIG")
  119.                 term.setCursorPos(2,19)
  120.                 print("DOWN")
  121.  
  122.         term.setBackgroundColor(colors.green)
  123.                 term.setCursorPos(9,12)
  124.                 print("PLACE")
  125.                 term.setCursorPos(11,13)
  126.                 print("UP")
  127.         term.setCursorPos(9,16)
  128.         print("PLACE")
  129.                 term.setCursorPos(9,18)
  130.                 print("PLACE")
  131.                 term.setCursorPos(10,19)
  132.                 print("DOWN")
  133.  
  134.         term.setBackgroundColor(colors.blue)
  135.                 term.setCursorPos(24,2)
  136.                 print("INV")
  137.                 term.setCursorPos(26,3)
  138.                 print("1")
  139.                 term.setCursorPos(26,4)
  140.                 print("2")
  141.                 term.setCursorPos(26,5)
  142.                 print("3")
  143.                 term.setCursorPos(26,6)
  144.                 print("4")
  145.                 term.setCursorPos(26,7)
  146.                 print("5")
  147.                 term.setCursorPos(26,8)
  148.                 print("6")
  149.                 term.setCursorPos(26,9)
  150.                 print("7")
  151.                 term.setCursorPos(26,10)
  152.                 print("8")
  153.                 term.setCursorPos(26,11)
  154.                 print("9")
  155.                 term.setCursorPos(25,12)
  156.                 print("10")
  157.                 term.setCursorPos(25,13)
  158.                 print("11")
  159.                 term.setCursorPos(25,14)
  160.                 print("12")
  161.                 term.setCursorPos(25,15)
  162.                 print("13")
  163.                 term.setCursorPos(25,16)
  164.                 print("14")
  165.                 term.setCursorPos(25,17)
  166.                 print("15")
  167.                 term.setCursorPos(25,18)
  168.                 print("16")
  169.         term.setBackgroundColor(colors.red)
  170.                 term.setCursorPos(18,12)
  171.                 print("^^^")
  172.                 term.setCursorPos(18,13)
  173.                 print("|||")
  174.                 term.setCursorPos(18,15)
  175.                 print("RED")
  176.                 term.setCursorPos(17,16)
  177.                 print("STONE")
  178.                 term.setCursorPos(18,18)
  179.                 print("|||")
  180.                 term.setCursorPos(18,19)
  181.                 print("vvv")
  182.  
  183.         term.setBackgroundColor(colors.black)
  184.         term.setCursorPos(2,11)
  185.         print("Turtle ID: "..id)
  186.  
  187.         term.setBackgroundColor(colors.black)
  188.         term.setCursorPos(2,17)
  189.  
  190.         local evnt = { os.pullEvent("mouse_click") }
  191.         local x = evnt[3]
  192.         local y = evnt[4]
  193.         if y >= 1 and y <= 6 and x >= 2 and x <= 4 then
  194.                 rednet.send(id,"up")
  195.                 print("up")
  196.                 sleep(.5)
  197.         end
  198.  
  199.         if y >= 7 and y <= 9 and x >= 1 and x <= 6 then
  200.                 rednet.send(id,"down")
  201.                 print("down")
  202.                 sleep(.5)
  203.         end
  204.  
  205.         if y >= 2 and y <= 4 and x >= 10 and x <= 19 then
  206.                 rednet.send(id,"forward")
  207.                 print("forward")
  208.                 sleep(.5)
  209.         end
  210.  
  211.         if y >= 5 and y <= 7 and x >= 7 and x <= 13 then
  212.                 rednet.send(id,"left")
  213.                 print("left")
  214.                 sleep(.5)
  215.         end
  216.  
  217.         if y >= 5 and y <= 7 and x >= 16 and x <= 22 then
  218.                 rednet.send(id,"right")
  219.                 print("right")
  220.                 sleep(.5)
  221.         end
  222.  
  223.         if y >= 8 and y <= 10 and x >= 10 and x <= 19 then
  224.                 rednet.send(id,"back")
  225.                 print("back")
  226.                 sleep(.5)
  227.         end
  228.        
  229.         if y >= 12 and y <= 13 and x >= 1 and x <= 6 then
  230.                 rednet.send(id,"digup")
  231.                 print("digUp")
  232.                 sleep(.5)
  233.         end
  234.  
  235.         if y >= 15 and y <= 16 and x >= 1 and x <= 6 then
  236.                 rednet.send(id,"dig")
  237.                 print("dig")
  238.                 sleep(.5)
  239.         end
  240.  
  241.         if y >= 18 and y <= 19 and x >= 1 and x <= 6 then
  242.                 rednet.send(id,"digdown")
  243.                 print("DigDown")
  244.                 sleep(.5)
  245.         end
  246.  
  247.         if y >= 12 and y <= 13 and x >= 8 and x <= 14 then
  248.                 rednet.send(id,"placeup")
  249.                 print("placeUp")
  250.                 sleep(.5)
  251.         end
  252.  
  253.         if y >= 15 and y <= 16 and x >= 8 and x <= 14 then
  254.                 rednet.send(id,"place")
  255.                 print("place")
  256.                 sleep(.5)
  257.         end
  258.  
  259.         if y >= 18 and y <= 19 and x >= 8 and x <= 14 then
  260.                 rednet.send(id,"placedown")
  261.                 print("placeDown")
  262.                 sleep(.5)
  263.         end
  264.  
  265.         if y >= 3 and y <= 3 and x >= 25 and x <= 26 then
  266.                 rednet.send(id,"inv1")
  267.                 print("inv1")
  268.                 sleep(.5)
  269.         end
  270.  
  271.         if y >= 4 and y <= 4 and x >= 25 and x <= 26 then
  272.                 rednet.send(id,"inv2")
  273.                 print("inv2")
  274.                 sleep(.5)
  275.         end
  276.  
  277.         if y >= 5 and y <= 5 and x >= 25 and x <= 26 then
  278.                 rednet.send(id,"inv3")
  279.                 print("inv3")
  280.                 sleep(.5)
  281.         end
  282.  
  283.         if y >= 6 and y <= 6 and x >= 25 and x <= 26 then
  284.                 rednet.send(id,"inv4")
  285.                 print("inv4")
  286.                 sleep(.5)
  287.         end
  288.  
  289.         if y >= 7 and y <= 7 and x >= 25 and x <= 26 then
  290.                 rednet.send(id,"inv5")
  291.                 print("inv5")
  292.                 sleep(.5)
  293.         end
  294.  
  295.         if y >= 8 and y <= 8 and x >= 25 and x <= 26 then
  296.                 rednet.send(id,"inv6")
  297.                 print("inv6")
  298.                 sleep(.5)
  299.         end
  300.  
  301.         if y >= 9 and y <= 9 and x >= 25 and x <= 26 then
  302.                 rednet.send(id,"inv7")
  303.                 print("inv7")
  304.                 sleep(.5)
  305.         end
  306.  
  307.         if y >= 10 and y <= 10 and x >= 25 and x <= 26 then
  308.                 rednet.send(id,"inv8")
  309.                 print("inv8")
  310.                 sleep(.5)
  311.         end
  312.  
  313.         if y >= 11 and y <= 11 and x >= 25 and x <= 26 then
  314.                 rednet.send(id,"inv9")
  315.                 print("inv9")
  316.                 sleep(.5)
  317.         end
  318.  
  319.         if y >= 12 and y <= 12 and x >= 25 and x <= 26 then
  320.                 rednet.send(id,"inv10")
  321.                 print("inv10")
  322.                 sleep(.5)
  323.         end
  324.  
  325.         if y >= 13 and y <= 13 and x >= 25 and x <= 26 then
  326.                 rednet.send(id,"inv11")
  327.                 print("inv11")
  328.                 sleep(.5)
  329.         end
  330.  
  331.         if y >= 14 and y <= 14 and x >= 15 and x <= 26 then
  332.                 rednet.send(id,"inv12")
  333.                 print("inv12")
  334.                 sleep(.5)
  335.         end
  336.  
  337.         if y >= 15 and y <= 15 and x >= 25 and x <= 26 then
  338.                 rednet.send(id,"inv13")
  339.                 print("inv13")
  340.                 sleep(.5)
  341.         end
  342.  
  343.         if y >= 16 and y <= 16 and x >= 25 and x <= 26 then
  344.                 rednet.send(id,"inv14")
  345.                 print("inv14")
  346.                 sleep(.5)
  347.         end
  348.  
  349.         if y >= 17 and y <= 17 and x >= 25 and x <= 26 then
  350.                 rednet.send(id,"inv15")
  351.                 print("inv15")
  352.                 sleep(.5)
  353.         end
  354.  
  355.         if y >= 18 and y <= 18 and x >= 25 and x <= 26 then
  356.                 rednet.send(id,"inv16")
  357.                 print("inv16")
  358.                 sleep(.5)
  359.         end
  360.  
  361.         if y >= 12 and y <= 13 and x >= 16 and x <= 22 then
  362.                 rednet.send(id,"rsup")
  363.                 print("RedstoneUp")
  364.                 sleep(.5)
  365.         end
  366.  
  367.         if y >= 15 and y <= 16 and x >= 16 and x <= 22 then
  368.                 rednet.send(id,"rsfront")
  369.                 print("RedstoneFront")
  370.                 sleep(.5)
  371.         end
  372.  
  373.         if y >= 18 and y <= 19 and x >= 16 and x <= 22 then
  374.                 rednet.send(id,"rsdown")
  375.                 print("RedstoneDown")
  376.                 sleep(.5)
  377.         end
  378.  
  379. end
  380.  
  381. end
  382.  
  383.  
  384. while true do
  385.        
  386.         if id == 0 then
  387.                 setup()
  388.         else
  389.                 GUI()
  390.         end
  391. end
Advertisement
Add Comment
Please, Sign In to add comment