Advertisement
Muzze77

RequestPipeConfig

May 27th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.07 KB | None | 0 0
  1.  
  2. shell.run("clear")
  3. buttons = {}
  4. buttons["LV"] = {X = 3, Y = 3,BCol = colors.white,TCol = colors.green, BtnName = "LV Solar Panel"}
  5. buttons["MV"] = {X = 3, Y = 4,BCol = colors.white,TCol = colors.red, BtnName = "MV Solar Panel"}
  6. buttons["HV"] = {X = 3, Y = 5,BCol = colors.white,TCol = colors.blue, BtnName = "HV Solar Panel"}
  7. btnNone = colors.orange
  8.  
  9.  
  10. i = 0
  11.  
  12. function cBut(cx,cy,tcol, bcol, bName)
  13. term.setCursorPos(cx,cy)
  14. term.setBackgroundColor(bcol)
  15. term.setTextColor(tcol)
  16. term.write(bName)
  17. term.setBackgroundColor(colors.black)
  18. term.setTextColor(colors.white)
  19. end
  20.  
  21. p = peripheral.wrap("bottom")
  22.  
  23. lv = p.getItemIdentifierIDFor(183,0)
  24. mv = p.getItemIdentifierIDFor(183,1)
  25. hv = p.getItemIdentifierIDFor(183,2)
  26. print(lv)
  27. print(mv)
  28. print(hv)
  29. function setButs()
  30. cBut(buttons.LV.X,buttons.LV.Y,buttons.LV.TCol, buttons.LV.BCol,buttons.LV.BtnName)
  31. cBut(buttons.MV.X,buttons.MV.Y,buttons.MV.TCol, buttons.MV.BCol,buttons.MV.BtnName)
  32. cBut(buttons.HV.X,buttons.HV.Y,buttons.HV.TCol, buttons.HV.BCol,buttons.HV.BtnName)
  33. cBut(20,7,colors.white,colors.black,"Anzahl Request")
  34. cBut(26,8,colors.white,colors.black,tostring(i))
  35. cBut(25,8,colors.white,colors.black,"<")
  36. cBut(25 + string.len(i) + 1,8,colors.white,colors.black,">")
  37. cBut(20,9,colors.green,colors.black,"Start Request")
  38. cBut(3,10,colors.black,btnNone,"Nichts")
  39. end
  40.  
  41.  
  42.  
  43. while true do
  44. req = 0
  45. shell.run("clear")
  46. setButs()
  47.  
  48. evt,btn, x, y = os.pullEvent("mouse_click")
  49. if x == 25 and y == 8 then
  50.   if i == 0 then
  51.   i = 0
  52.   else
  53.   i = i - 1
  54.   end
  55. elseif x == (25 + string.len(i) + 1) and y == 8 then
  56.   i = i + 1
  57. elseif y == 9 then
  58.    
  59. if x < string.len("Start Request") + 1 or x > 19 then
  60.   if i == 0 then
  61.  
  62.  
  63.   else
  64.     if req == 0 then
  65.    
  66.     elseif req == 1 then
  67.      l =  p.makeRequest(lv,i)
  68.     elseif req == 2 then
  69.      l =  p.makeRequest(mv,i)
  70.     elseif req == 3 then
  71.      l =  p.makeRequest(hv,i)
  72.     end
  73.    
  74.     term.setCursorPos(16,10)  
  75.     term.write("Request gestartet")
  76.     term.setCursorPos(16,11)
  77.     term.write(l)
  78.     sleep(1)
  79.   end
  80.   end
  81. elseif y == buttons.LV.Y then
  82.   if x > (buttons.LV.X -1) or x < (string.len(buttons.LV.BtnName) + 1) then
  83.    buttons.LV.BCol = colors.orange
  84.    buttons.MV.BCol = colors.white
  85.    buttons.HV.BCol = colors.white
  86.    btnNone = colors.white
  87.    req = 1
  88.   end
  89. elseif y == buttons.MV.Y then
  90.   if x > (buttons.MV.X -1) or x < (string.len(buttons.MV.BtnName) + 1) then
  91.     buttons.LV.BCol = colors.white
  92.     buttons.MV.BCol = colors.orange
  93.     buttons.HV.BCol = colors.white
  94.     btnNone = colors.white
  95.     req = 2
  96.   end
  97. elseif y == buttons.HV.Y then
  98.   if x > (buttons.HV.X - 1) or x < (string.len(buttons.HV.BtnName) + 1) then
  99.     buttons.LV.BCol = colors.white
  100.     buttons.MV.BCol = colors.white
  101.     buttons.HV.BCol = colors.orange
  102.     btnNone = colors.white
  103.     req = 3
  104.    
  105.  
  106.   end
  107. elseif y == 10 then
  108.   if x > 2 or x < string.len("nichts") + 1 then
  109.     buttons.LV.BCol = colors.white
  110.     buttons.MV.BCol = colors.white
  111.     buttons.HV.BCol = colors.white
  112.     btnNone = colors.orange
  113.     req = 0
  114.  
  115.   end
  116. end
  117. sleep(0.5)
  118.  
  119. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement