Advertisement
Guest User

lock

a guest
Feb 19th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. local txt = "Lockdown"
  2.  
  3. monitor_side = "back"
  4. modem_side = "left"
  5.  
  6. mon = peripheral.wrap(monitor_side)
  7. mon.setTextScale(3)
  8. x, y = mon.getSize()
  9.  
  10. function writeCenter(text)
  11.   return (x-string.len(text))/2 + 1
  12. end
  13. function m_write(text,color)
  14.   mon.setBackgroundColor(color)
  15.   mon.clear()
  16.   mon.setCursorPos(writeCenter(text),2)
  17.   mon.write(text)
  18. end
  19. local run = true
  20. local currentColor = colors.green
  21. m_write(txt,currentColor)
  22.  
  23. while(run) do
  24.   side, monX, monY = os.pullEvent("monitor_touch")
  25.   if(currentColor == colors.green) then
  26.      currentColor = colors.red
  27.   else
  28.     currentColor = colors.green
  29.   end
  30.   m_write(txt,currentColor)
  31.  
  32.  
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement