Advertisement
Guest User

opengate

a guest
Mar 26th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local bool = true
  2. local i = 0
  3. m = peripheral.wrap("left")
  4. function redback(y)
  5.     for i=1, y do
  6.          redstone.setOutput("back",true)
  7.          sleep(1)
  8.          redstone.setOutput("back",false)
  9.          sleep(1)
  10.     end
  11. end
  12. function redtop(y)
  13.     for i=1, y do
  14.          redstone.setOutput("top",true)
  15.          sleep(1)
  16.          redstone.setOutput("top",false)
  17.          sleep(1)
  18.     end
  19. end
  20. function showMonitorON(x, y)
  21.          m.clear()
  22.          m.setCursorPos(x, y)
  23.          m.setTextColor( colors.green )
  24.          m.setTextScale(1.5)
  25.          m.write("ON")
  26. end
  27. function showMonitorOFF(x, y)
  28.          m.clear()
  29.          m.setCursorPos(x, y)
  30.          m.setTextColor( colors.red )
  31.          m.setTextScale(1.5)
  32.          m.write("OFF")
  33. end
  34. while true do
  35.   event, param1, param2 = os.pullEvent("monitor_touch")
  36.   if (event == "monitor_touch") and bool then
  37.        redback(5)
  38.        bool = false
  39.        showMonitorON(1, 2)
  40.   else if (event == "monitor_touch") and not(bool) then
  41.           redtop(5)
  42.           bool = true
  43.           showMonitorOFF(3, 2)
  44.        end
  45.   end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement