Advertisement
DakinUA

Station control

Oct 13th, 2022 (edited)
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.67 KB | None | 0 0
  1. --Import lib
  2. local component = require("component")
  3. local sides = require("sides")
  4. local colors = require("colors")
  5. local os = require("os")
  6. local term = require("term")
  7. local event = require("event")
  8. --Import components
  9. local rs = component.redstone
  10. local gpu = component.gpu
  11.  
  12. local posSwitchOne = true
  13. local posSwitchTwo = true
  14.  
  15. while true do
  16. --Get occupancy railway
  17. secondWay = rs.getBundledInput(sides.east, colors.lightblue)
  18. firstWay = rs.getBundledInput(sides.east, colors.yellow)
  19.  
  20. secondStationWay = rs.getBundledInput(sides.east, colors.orange)
  21. firstStationWay = rs.getBundledInput(sides.east, colors.white)
  22.  
  23. switchonetwo = rs.getBundledInput(sides.east, colors.magenta)
  24.  
  25. getPosSwitchOne = rs.getBundledInput(sides.east, colors.lime)
  26. getPosSwitchTwo = rs.getBundledInput(sides.east, colors.pink)
  27.  
  28. --Paint on the screen
  29. term.clear()
  30. gpu.setForeground(0xffffff)
  31. gpu.set(1, 3, "]")
  32. gpu.set(1, 6, "]")
  33.  
  34.  
  35. if secondStationWay == 0 then
  36.   gpu.setForeground(0x00ff00)
  37.   gpu.set(2, 3, "═══════")    
  38. else
  39.   gpu.setForeground(0xff0000)
  40.   gpu.set(2, 3, "═══════")
  41. end
  42.  
  43. if firstStationWay == 0 then
  44.   gpu.setForeground(0x00ff00)
  45.   gpu.set(2, 6, "═══════")    
  46. else
  47.   gpu.setForeground(0xff0000)
  48.   gpu.set(2, 6, "═══════")
  49. end
  50.  
  51. if switchonetwo == 0 then
  52.   gpu.setForeground(0x00ff00)  
  53. else
  54.   gpu.setForeground(0xff0000)
  55. end
  56.  
  57. if getPosSwitchTwo ~= 0 then
  58.     gpu.set(10, 3, "═════")
  59. else
  60.     gpu.set(10, 3, "  ╔══")
  61.     gpu.set(10, 4, "  ║")
  62. end
  63.  
  64. if getPosSwitchOne ~= 0 then
  65.     gpu.set(10, 6, "═════")
  66. else
  67.     gpu.set(10, 5, "  ║")
  68.     gpu.set(10, 6, "══╝")
  69. end
  70.  
  71. if secondWay == 0 then
  72.   gpu.setForeground(0x00ff00)
  73.   gpu.set(16, 3, "═══════")    
  74. else
  75.   gpu.setForeground(0xff0000)
  76.   gpu.set(16, 3, "═══════")
  77. end
  78.  
  79. if firstWay == 0 then
  80.   gpu.setForeground(0x00ff00)
  81.   gpu.set(16, 6, "═══════")    
  82. else
  83.   gpu.setForeground(0xff0000)
  84.   gpu.set(16, 6, "═══════")
  85. end
  86.  
  87. local _,_,x,y= event.pull(1, "touch")
  88.  
  89. if x ~= nil then
  90.   if (x>9) and (x<16) then
  91.     if (y==3) or (y==4) then
  92.       if posSwitchTwo == true then
  93.         rs.setBundledOutput(sides.north, colors.white)
  94.         posSwitchTwo = false
  95.       else
  96.         rs.setBundledOutput(sides.north, colors.white)
  97.         posSwitchTwo = true
  98.       end
  99.     elseif (y==5) or (y==6) then   
  100.       if posSwitchOne == true then
  101.         rs.setBundledOutput(sides.north, colors.orange)
  102.         posSwitchOne = false
  103.       else
  104.         rs.setBundledOutput(sides.north, colors.orange)
  105.         posSwitchOne = true
  106.       end
  107.     end    
  108.   end
  109. end
  110.  
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement