Advertisement
Biowepen

ME-System Lua

Sep 2nd, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  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 schutz()
  11.       addText()
  12.       --button.toggleButton("Schutz")    
  13.       if button.active("Schutz") then
  14.        -- print("now on")
  15.         rs.setOutput("left", false)
  16.         button.standby()
  17.         button.setName("Schutz", "ME-System Aus!")
  18.       else
  19.        -- print("now off")
  20.         rs.setOutput("left", true)
  21.         button.standby()
  22.         button.setName("Schutz", "ME-System An!")
  23.       end
  24.       button.toggleButton("Schutz")
  25.       button.save()
  26.       addText()      
  27.     end      
  28.     function fillMainTable()
  29.       m.clear()
  30.       addText()
  31.       button.clearTable()
  32.       button.setTable("Schutz", schutz, "", 2, mx-1, 2, my-1, "ME-System Aus!")    
  33.       button.screen()
  34.     end
  35.     function addText()
  36.       local text = "ME-System"
  37.       local mx, my = m.getSize()
  38.       m.setBackgroundColor(colors.black)
  39.       m.setCursorPos((mx/2-#text/2)+1 , 1)
  40.       m.write(text)
  41.     end  
  42.     addText()
  43.     fillMainTable()
  44.     button.load()
  45.     while true do
  46.       getClick()
  47.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement