Advertisement
maumagro

Fair control

Oct 26th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. API = require("buttonAPI")
  2. local event = require("event")
  3. local computer = require("computer")
  4. local term = require("term")
  5. local component = require("component")
  6. local gpu = component.gpu
  7.  
  8. local rs = component.redstone
  9. local colors = require("colors")
  10. local sides = require("sides")
  11.  
  12. function API.fillTable()
  13.   API.setTable("Hall", test1, 10,30,3,5)  
  14.   API.setTable("Entrance", test2, 32,52,3,5)
  15.   API.setTable("Stall lights", test3, 10,30,8,10)
  16.   API.setTable("Stall power", test4, 32,52,8,10)
  17.   API.screen()
  18. end
  19.  
  20. function getClick()
  21.   local _, _, x, y = event.pull(1,touch)
  22.   if x == nil or y == nil then
  23.     local h, w = gpu.getResolution()
  24.     gpu.set(h, w, ".")
  25.     gpu.set(h, w, " ")
  26.   else
  27.     API.checkxy(x,y)
  28.   end
  29. end
  30.  
  31. function test1()
  32.   API.toggleButton("Hall")
  33.   if buttonStatus == true then
  34.     term.setCursor(1,25)
  35.     term.write("Working...                         ")
  36.     rs.setOutput(sides.left,15)
  37.     os.sleep(1)
  38.     term.setCursor(1,25)
  39.     term.write("System ready                         ")
  40.   else
  41.     term.setCursor(1,25)
  42.     term.write("Working...                        ")
  43.     rs.setOutput(sides.left,0)
  44.     os.sleep(1)
  45.     term.setCursor(1,25)
  46.     term.write("System ready                        ")
  47.   end
  48. end
  49.  
  50.  
  51. function test2()
  52.   API.toggleButton("Entrance")
  53.   if buttonStatus == true then
  54.     term.setCursor(1,25)
  55.     term.write("Working...                         ")
  56.     rs.setOutput(sides.up,15)
  57.     os.sleep(1)
  58.     term.setCursor(1,25)
  59.     term.write("System ready                         ")
  60.   else
  61.     term.setCursor(1,25)
  62.     term.write("Working...                        ")
  63.     rs.setOutput(sides.up,0)
  64.     os.sleep(1)
  65.     term.setCursor(1,25)
  66.     term.write("System ready                        ")
  67.   end
  68. end
  69.  
  70. function test3()
  71.   API.toggleButton("Stall lights")
  72.   if buttonStatus == true then
  73.     term.setCursor(1,25)
  74.     term.write("Working...                         ")
  75.     rs.setOutput(sides.right,15)
  76.     os.sleep(1)
  77.     term.setCursor(1,25)
  78.     term.write("System ready                         ")
  79.   else
  80.     term.setCursor(1,25)
  81.     term.write("Working...                        ")
  82.     rs.setOutput(sides.right,0)
  83.     os.sleep(1)
  84.     term.setCursor(1,25)
  85.     term.write("System ready                        ")
  86.   end
  87. end
  88.  
  89. function test4()
  90.   API.toggleButton("Stall power")
  91.   if buttonStatus == true then
  92.     term.setCursor(1,25)
  93.     term.write("Working...                         ")
  94.     rs.setOutput(sides.back,15)
  95.     os.sleep(1)
  96.     term.setCursor(1,25)
  97.     term.write("System ready                         ")
  98.   else
  99.     term.setCursor(1,25)
  100.     term.write("Working...                        ")
  101.     rs.setOutput(sides.back,0)
  102.     os.sleep(1)
  103.     term.setCursor(1,25)
  104.     term.write("System ready                        ")
  105.   end
  106. end
  107.  
  108. term.setCursorBlink(false)
  109. gpu.setResolution(80, 25)
  110. API.clear()
  111. API.fillTable()
  112. API.heading("Power control - by maumagro")
  113. API.label(1,24,"Buenos Aires, Argentina.")
  114.  
  115. while true do
  116.   getClick()
  117. end
  118.  
  119.  
  120.  
  121. --eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement