Pentacore

Computer Main

Jul 18th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.00 KB | None | 0 0
  1. os.loadAPI("button")
  2.  
  3. m = peripheral.wrap("left")
  4. m.clear()
  5.  
  6. f = false
  7. H = false
  8. T = false
  9. FH = false
  10.  
  11. M1 = false
  12.  
  13. isCoal = true
  14. isTorch = true
  15.  
  16. Turtleid = 0
  17.  
  18. MID1 = 53 --First turtle
  19. MID2 = 0 --Second turtle
  20. MID3 = 0 --Third turtle
  21. MID4 = 0 --Fourth turtle
  22.  
  23. function fillTable()
  24.    button.setTable("Miner1", 1, 3,5,3,5)
  25.    button.setTable("Miner2", 2, 7,9,3,5)
  26.    button.setTable("Miner3", 3, 11,13,3,5)
  27.    button.setTable("Miner4", 4, 15,17,3,5)
  28.    
  29.    button.screen()
  30. end
  31.  
  32. function Check()
  33.   if f == true then
  34.     button.toggleButton("50")
  35.     f = false
  36.     rednet.send(Turtleid,"mine50")
  37.   elseif H == true then
  38.     button.toggleButton("100")
  39.     H = false
  40.     rednet.send(Turtleid,"mine100")
  41.   elseif T == true then
  42.     button.toggleButton("200")
  43.     T= false
  44.     rednet.send(Turtleid,"mine200")
  45.   elseif FH == true then
  46.     button.toggleButton("500")
  47.     FH = false
  48.     rednet.send(Turtleid,"mine500")
  49.   end
  50. end
  51.  
  52. function MoveCheck()
  53.   if M1 == true then
  54.     button.toggleButton("Move")
  55.     M1 = false
  56.     rednet.send(Turtleid, "move")
  57.   end
  58. end  
  59.  
  60. function Miner1()
  61.    button.toggleButton("Miner1")
  62.    Turtleid = MID1
  63.    Check()
  64.    MoveCheck()
  65. end
  66.  
  67. function Miner2()
  68.   button.toggleButton("Miner2")
  69.   Turtleid = MID2
  70.   Check()
  71.   MoveCheck()
  72. end
  73.  
  74. function Miner3()
  75.   button.toggleButton("Miner3")
  76.   Turtleid = MID3
  77.   Check()
  78.   MoveCheck()
  79. end
  80.  
  81. function Miner4()
  82.   button.toggleButton("Miner4")
  83.   Turtleid = MID4
  84.   Check()
  85.   MoveCheck()
  86. end
  87.  
  88. function Fifty()
  89.    button.toggleButton("50")
  90.    f = true
  91. end
  92.  
  93. function Hundred()
  94.    button.toggleButton("100")
  95.    H = true
  96. end
  97.  
  98. function TwoHund()
  99.   button.toggleButton("200")
  100.   T = true
  101. end
  102.  
  103. function FiveHund()
  104.   button.toggleButton("500")
  105.   FH = true
  106. end
  107.  
  108. function Reset()
  109.   button.flash("Reset")
  110.   if f == true then
  111.     button.toggleButton("50")
  112.     f = false
  113.   elseif H == true then
  114.     button.toggleButton("100")
  115.     H = false
  116.   elseif T == true then
  117.     button.toggleButton("200")
  118.     T = false
  119.   elseif FH == true then
  120.     button.toggleButton("500")
  121.     FH = false
  122.   end
  123. end
  124.  
  125. function Coal()
  126.   print("Don't touch!")
  127. end
  128.  
  129. function Torch()
  130.   print("Don't touch!")
  131. end
  132.  
  133. function Move1()
  134.   button.toggleButton("Move")
  135.   M1 = true
  136. end
  137.  
  138. function MoveReset()
  139.   button.flash("Move Reset")
  140.   if M1 == true then
  141.     button.toggleButton("Move")
  142.     M1 = false
  143.   end
  144. end
  145.  
  146. rednet.open("right")
  147. fillTable()
  148. button.heading("Miner Controller")
  149.  
  150. while true do
  151.   local event, Turtleid, par2, par3 = os.pullEvent()
  152.  
  153.   if event == "rednet_message" and par2 == "done" then
  154.     if Turtleid == MID1 then
  155.       button.toggleButton("Miner1")
  156.     elseif Turtleid == MID2 then
  157.       button.toggleButton("Miner2")
  158.     elseif Turtleid == MID3 then
  159.       button.toggleButton("Miner3")
  160.     elseif Turtleid == MID4 then
  161.       button.toggleButton("Miner4")
  162.     end
  163.   elseif event == "rednet_message" and par2 == "cFalse" then
  164.     if Turtleid == MID1 or MID2 or MID3 or MID4 then
  165.       if isCoal == true then
  166.         button.toggleButton("C")
  167.         isCoal = false
  168.       elseif isCoal == false then
  169.       end
  170.     end
  171.   elseif event == "rednet_message" and par2 == "cTrue" then
  172.     if Turtleid == MID1 or MID2 or MID3 or MID4 then
  173.       if isCoal == false then
  174.         button.toggleButton("C")
  175.         isCoal = true
  176.       elseif isCoal == true then
  177.       end
  178.     end
  179.   elseif event == "rednet_message" and par2 == "tFalse" then
  180.     if Turtleid == MID1 or MID2 or MID3 or MID4 then
  181.       if isTorch == true then
  182.         button.toggleButton("T")
  183.         isTorch = false
  184.       elseif isTorch == false then
  185.       end
  186.     end
  187.   elseif event == "rednet_message" and par2 == "tTrue" then
  188.     if Turtleid == MID1 or MID2 or MID3 or MID4 then
  189.       if isTorch == false then
  190.         button.toggleButton("T")
  191.         isTorch = true
  192.       elseif isTorch == true then
  193.       end
  194.     end
  195.   elseif event == "monitor_touch" then
  196.     button.checkxy(par2,par3)
  197.   end  
  198. end
Advertisement
Add Comment
Please, Sign In to add comment