Advertisement
kremnev8

rscon

Mar 3rd, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. com = {"front","back","left","right","top","bottom"}
  2. m = peripheral.wrap("back")
  3.  
  4. if fs.exists("GUI") then
  5. print("loading 1Ridav's GUI lib")
  6. os.loadAPI("GUI")
  7. else
  8. shell.run("pastebin","get","XcbJj1n4","GUI")
  9. print("loading 1Ridav's GUI lib")
  10. os.loadAPI("GUI")
  11. end
  12.  
  13. write("enter channel(number, from 1 to 65000)")
  14. inp = read()
  15.  
  16. act ={}
  17.  
  18.  
  19. if type(tonumber(inp)) == "number" then
  20. channel = tonumber(inp)
  21. m.open(channel)
  22. else
  23. error("not value")
  24. end
  25.  
  26.  
  27. function fw()
  28. side = com[1]
  29. SIDET:setText(side.." ")
  30. end
  31.  
  32.  
  33. function bc()
  34. side = com[2]
  35. SIDET:setText(side.."  ")
  36.  end
  37.  
  38. function rh()
  39. side = com[4]
  40. SIDET:setText(side.."  ")
  41.  end
  42.  
  43. function lt()
  44. side = com[3]
  45. SIDET:setText(side.." ")
  46.  end
  47.  
  48. function up()
  49. side = com[5]
  50. SIDET:setText(side.."   ")
  51.  end
  52.  
  53. function down()
  54. side = com[6]
  55. SIDET:setText(side)
  56.  end
  57.  
  58.  
  59. function send()
  60. if recc then
  61. table.insert(act,"set"..side)
  62. else
  63. m.transmit(channel,channel,"set"..side)
  64. end
  65. end
  66.  
  67.  
  68. function rm()
  69. if recc then
  70. table.insert(act,"rm"..side)
  71. else
  72. m.transmit(channel,channel,"rm"..side)
  73. end
  74. end
  75.  
  76.  
  77.  
  78.  function record(s)
  79. if s.check then
  80.  recc = true
  81.  else
  82.  recc = false
  83.  end
  84. end
  85.  
  86.  function execute()
  87.  if type(act) == "table" then
  88.       for i=1,#act do
  89.          if type(act[i]) == "string" then
  90.          if string.sub(act[i],1,5) == "sleep" then
  91.          sleep(tonumber(string.sub(act[i],7,9)))
  92.          else
  93.            m.transmit(200,200,act[i])
  94.            end
  95.          elseif type(act[i]) == "table" then
  96.          tab = act[i]
  97.             for o=1,tab[#tab] do
  98.                for j=1,#tab-1 do
  99.                   m.transmit(200,200,tab[j])
  100.                end
  101.             end
  102.          end
  103.          sleep(0.5)
  104.       end
  105.    end
  106. end
  107.  
  108. function clear()
  109. act = {}
  110. end
  111.  
  112. function sleep()
  113. nsl = 1
  114. if last == "sleep" then
  115. nsl = sl + 1
  116. end
  117. if recc then
  118. table.insert(act,"sleep "..nsl)
  119. end
  120. end
  121.  
  122.  
  123.  
  124. term.clear()
  125. term.setCursorPos(1,1)
  126. FB = GUI.NewButton(nil, 7, 6, 8, 3, "FRONT", fw)
  127. BB = GUI.NewButton(nil, 7, 16, 8, 3, "BACK", bc)
  128. LB = GUI.NewButton(nil, 3, 10, 3, 5, "LEFT", lt)
  129. RB = GUI.NewButton(nil, 16, 10, 3, 5, "RIGHT", rh)
  130. UB = GUI.NewButton(nil, 7, 10, 8, 2, "TOP", up,colors.red)
  131. DB = GUI.NewButton(nil, 7, 13, 8, 2, "BOTTOM",down,colors.red)
  132. SETB = GUI.NewButton(nil, 3, 6 ,3,3,"SET",send,colors.green)
  133. RMB = GUI.NewButton(nil ,16 ,6 , 3,3, "REMOVE",rm,colors.green)
  134. REC = GUI.NewCheckBox(nil, 22 , 6 ,2 ,1 ,nil ,record , colors.orange)
  135. EXECUTE = GUI.NewButton(nil, 17, 2, 8, 1, "EXECUTE",execute,colors.red)
  136. CLEAR = GUI.NewButton(nil, 17, 3, 8, 1, "CLEAR",clear,colors.green)
  137. SLEEP = GUI.NewButton(nil, 17, 4, 8, 1, "SLEEP",sleep,colors.blue)
  138. SIDET = GUI.NewLabel(nil, 9,2,"none  ")
  139. GUI.MainPanel:addCHILD(FB,BB,UB,DB,LB,RB,SETB,RMB,REC,EXECUTE,CLEAR,SLEEP,SIDET)
  140. GUI.MainPanel:draw()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement