Advertisement
Guest User

[Reactor]Startup

a guest
Nov 27th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("button")
  2. local m = peripheral.wrap("back")
  3. local mx, my = m.getSize()
  4. function getClick()
  5.   local event, side, x, y = os.pullEvent()
  6.   if event == "monitor_touch" then
  7.     button.checkxy(x, y)
  8.   end
  9. end
  10. function reactor()
  11.   button.toggleButton("Reactor")    
  12.   if button.active("Reactor 1") then
  13.    -- print("now on")
  14.     rs.setOutput("right", true)
  15.   else
  16.    -- print("now off")
  17.     rs.setOutput("right", false)
  18.   end
  19.   button.save()
  20.   addText()      
  21. end      
  22. function fillMainTable()
  23.   m.clear()
  24.   button.clearTable()
  25.   button.setTable("Reactor", reactor, "", 2, mx/2, 2, my-1)
  26.                                           --2,mx/2-1 -- mx/2+2, mx-1.0                    
  27.   button.screen()
  28. end
  29. function addText()
  30.   for i = 1,2 do
  31.     m.setTextColor(colors.white)
  32.     if i == 1 then
  33.       local textr = "Main Power"
  34.       if button.active("Reactor") then
  35.         m.setBackgroundColor(colors.lime)
  36.       else
  37.         m.setBackgroundColor(colors.red)
  38.       end
  39.       m.setCursorPos(mx/4-#textr/2+1.75, my/2+1)    
  40.       m.write(textr)
  41.     end
  42.   end  
  43. end  
  44. fillMainTable()
  45. button.load()
  46. addText()
  47. while true do
  48.   getClick()
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement