Advertisement
Biowepen

ME-System Lua 2.0

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