kremnev8

control

Mar 2nd, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.41 KB | None | 0 0
  1. com = {"forward","back","left","right","up","down"}
  2. side = "cen"
  3. m = peripheral.wrap("back")
  4.  
  5. if fs.exists("GUI") then
  6. print("loading 1Ridav's GUI lib")
  7. os.loadAPI("GUI")
  8. else
  9. shell.run("pastebin","get","XcbJj1n4","GUI")
  10. print("loading 1Ridav's GUI lib")
  11. os.loadAPI("GUI")
  12. end
  13.  
  14. if fs.exists("AF") then
  15. print("loading Zer0Galaxy festel crypt lib")
  16. os.loadAPI("AF")
  17. key = AF.getkey("123456789")
  18. else
  19. shell.run("pastebin","get","KC7uE6ZP","AF")
  20. print("loading Zer0Galaxy festel crypt lib")
  21. os.loadAPI("AF")
  22. key = AF.getkey("123456789")
  23. end
  24.  
  25. write("enter channel(number, from 1 to 65000)")
  26. inp = read()
  27.  
  28. act ={}
  29.  
  30.  
  31. if type(tonumber(inp)) == "number" then
  32. m.open(tonumber(inp))
  33. else
  34. error("not value")
  35. end
  36.  
  37.  
  38. function fw()
  39. if recc then
  40. table.insert(act,com[1])
  41. else
  42. m.transmit(200,200,com[1])
  43. end
  44. end
  45.  
  46.  
  47. function bc()
  48. if recc then
  49. table.insert(act,com[2])
  50. else
  51. m.transmit(200,200,com[2])
  52. end
  53.  end
  54.  
  55. function rh()
  56. if recc then
  57. table.insert(act,com[4])
  58. else
  59. m.transmit(200,200,com[4])
  60. end
  61.  end
  62.  
  63. function lt()
  64. if recc then
  65. table.insert(act,com[3])
  66. else
  67. m.transmit(200,200,com[3])
  68. end
  69.  end
  70.  
  71. function up()
  72. if recc then
  73. table.insert(act,com[5])
  74. else
  75. m.transmit(200,200,com[5])
  76. --side = "cen"
  77. end
  78.  end
  79.  
  80. function down()
  81. if recc then
  82. table.insert(act,com[6])
  83. else
  84. m.transmit(200,200,com[6])
  85. end
  86.  end
  87.  
  88.  
  89. function dig()
  90. if side == "up" then
  91. if recc then
  92. table.insert(act,"digUP")
  93. else
  94. m.transmit(200,200,"digUP")
  95. end
  96. elseif side == "down" then
  97. if recc then
  98. table.insert(act,"digDN")
  99. else
  100. m.transmit(200,200,"digDN")
  101. end
  102. elseif side == "cen" then
  103. if recc then
  104. table.insert(act,"dig")
  105. else
  106. m.transmit(200,200,"dig")
  107. end
  108. end
  109. end
  110.  
  111. function place()
  112. if side == "up" then
  113. if recc then
  114. table.insert(act,"placeUP")
  115. else
  116. m.transmit(200,200,"placeUP")
  117. end
  118. elseif side == "down" then
  119. if recc then
  120. table.insert(act,"placeDN")
  121. else
  122. m.transmit(200,200,"placeDN")
  123. end
  124. elseif side == "cen" then
  125. if recc then
  126. table.insert(act,"place")
  127. else
  128. m.transmit(200,200,"place")
  129. end
  130. end
  131. end
  132.  
  133. function upp(s)
  134. s.check = true
  135. DOWNM.check = false
  136. CENM.check = false
  137. GUI.MainPanel:draw()
  138. if side == "up" then
  139. --s.check = true
  140. side = "cen"
  141. s.check = false
  142. DOWNM.check = false
  143. CENM.check = false
  144. GUI.MainPanel:draw()
  145. elseif side == "down" then
  146. side = "up"
  147.  
  148. elseif side == "cen" then
  149. side = "up"
  150. end
  151. end
  152.  
  153. function downn(s)
  154. s.check = true
  155. UPM.check = false
  156. CENM.check = false
  157. GUI.MainPanel:draw()
  158. if side == "down" then
  159. side = "cen"
  160. s.check = false
  161. UPM.check = false
  162. GUI.MainPanel:draw()
  163. elseif side == "up" then
  164. side = "down"
  165. elseif side == "cen" then
  166. side = "down"
  167. end
  168. end
  169.  
  170.  function cen(s)
  171. s.check = true
  172. UPM.check = false
  173. DOWNM.check = false
  174. GUI.MainPanel:draw()
  175. if side == "up" then
  176. side = "cen"
  177. elseif side == "down" then
  178. side = "cen"
  179. elseif side == "cen" then
  180. side = "cen"
  181. end
  182. end
  183.  
  184.  
  185.  function record(s)
  186. if s.check then
  187.  recc = true
  188.  else
  189.  recc = false
  190.  end
  191. end
  192.  
  193.  function execute()
  194.  if type(act) == "table" then
  195.       for i=1,#act do
  196.          if type(act[i]) == "string" then
  197.            m.transmit(200,200,act[i])
  198.          elseif type(act[i]) == "table" then
  199.             tab = act[i]
  200.             for o=1,tab[#tab] do
  201.                for j=1,#tab-1 do
  202.                   m.transmit(200,200,tab[j])
  203.                end
  204.             end
  205.          end
  206.          sleep(0.5)
  207.       end
  208.    end
  209. end
  210.  
  211. function clear()
  212. act = {}
  213. end
  214.  
  215.  
  216.  
  217.  
  218. term.clear()
  219. term.setCursorPos(1,1)
  220. FB = GUI.NewButton(nil, 8, 4, 8, 3, "FORWARD", fw)
  221. BB = GUI.NewButton(nil, 8, 14, 8, 3, "BACK", bc)
  222. LB = GUI.NewButton(nil, 4, 8, 3, 5, "LEFT", lt)
  223. RB = GUI.NewButton(nil, 17, 8, 3, 5, "RIGHT", rh)
  224. UB = GUI.NewButton(nil, 8, 8, 8, 2, "UP", up,colors.red)
  225. DB = GUI.NewButton(nil, 8, 11, 8, 2, "DOWN",down,colors.red)
  226. DIGB = GUI.NewButton(nil, 4, 4 ,3,3,"DIG",dig,colors.green)
  227. PLACEB = GUI.NewButton(nil ,17 ,4 , 3,3, "PLACE",place,colors.green)
  228. UPM = GUI.NewCheckBox(nil, 23, 4,2,1,nil,upp,colors.green)  
  229. DOWNM = GUI.NewCheckBox(nil,23,6 ,2,1,nil,downn,colors.green)  
  230. CENM = GUI.NewCheckBox(nil, 23 , 5 ,2 ,1 ,nil ,cen , colors.red)  
  231. REC = GUI.NewCheckBox(nil, 23 , 8 ,2 ,1 ,nil ,record , colors.orange)
  232. EXECUTE = GUI.NewButton(nil, 1, 17, 8, 1, "EXECUTE",execute,colors.red)
  233. CLEAR = GUI.NewButton(nil, 2, 17, 8, 1, "CLEAR",clear,colors.green)
  234. CENM.check = true
  235. GUI.MainPanel:addCHILD(FB,BB,UB,DB,LB,RB,DIGB,PLACEB,UPM,DOWNM,CENM,REC,EXECUTE,CLEAR)
  236. GUI.MainPanel:draw()
Advertisement
Add Comment
Please, Sign In to add comment