Advertisement
ecco7777

cc bundled cable monitor control

Apr 24th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. color={2^0,2^1,2^2,2^3,2^4,2^5,2^6,2^7,2^8,2^9,2^10,2^11,2^12,2^13,2^14,2^15}
  2. side="left" -- Seite fuer die Kabel
  3. m=peripheral.wrap("back") -- Seite fuer den Monitor
  4. names={"redstone 1","redstone 2","redstone 3","redstone 4","redstone 5","redstone 6","redstone 7","redstone 8","redstone 9","redstone 10","redstone 11","redstone 12","redstone 13","redstone 14","redstone 15","redstone 16",}
  5.  
  6. print("edit startup   eingeben um Monitor und Kabel seiten zu aendern")
  7. if fs.exists("status")==false then
  8. fp=fs.open("status","w")
  9. fp.writeLine("0")
  10. fp.close()
  11. end
  12.  
  13. function saveBundled()
  14. fp=fs.open("status","w")
  15. fp.writeLine(tostring(rs.getBundledOutput(side)))
  16. fp.close()
  17. end
  18.  
  19. function setBundled()
  20. fp=fs.open("status","r")
  21. rs.setBundledOutput(side,tonumber(fp.readLine()))
  22. fp.close()
  23. end
  24.  
  25. function toggleBundledOutput()
  26. if color[yPos]~=nil then
  27. if rs.testBundledInput(side,color[yPos]) == true then
  28. rs.setBundledOutput(side,colors.subtract(rs.getBundledOutput(side),color[yPos]))
  29. else
  30. rs.setBundledOutput(side,colors.combine(rs.getBundledOutput(side),color[yPos]))
  31. end
  32. end
  33. if yPos==i then
  34. rs.setBundledOutput(side,4095)
  35. saveBundled()
  36. end
  37. if yPos==i+1 then
  38. rs.setBundledOutput(side,0)
  39. saveBundled()
  40. end
  41. end
  42.  
  43.  
  44. setBundled()
  45.  
  46. while true do
  47. i=1
  48. m.clear()
  49. while color[i]~=nil do
  50.  
  51. m.setCursorPos(1,i)
  52. if redstone.testBundledInput(side,color[i])  then
  53. m.setBackgroundColor(colors.green) else m.setBackgroundColor(colors.red)
  54. end
  55.  
  56. m.write(" ")
  57. m.setBackgroundColor(colors.black)
  58. m.setCursorPos(2,i)
  59. m.setTextColor(color[i])
  60. m.write(names[i])
  61. i=i+1
  62. end
  63.  
  64. m.setTextColor(colors.green)
  65. m.setCursorPos(2,i)
  66. m.write("Redstone All On")
  67. m.setTextColor(colors.red)
  68. m.setCursorPos(2,i+1)
  69. m.write("Redstone All Off")
  70.  
  71. event, monSide, xPos, yPos = os.pullEvent("monitor_touch")
  72. toggleBundledOutput()
  73.  
  74. sleep(0.2)
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement