Advertisement
Guest User

lock

a guest
Sep 21st, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. print("Touch screen door made by Rin")
  4.  
  5. local mon = peripheral.wrap("top")
  6. local function initial()
  7.   mon.clear()
  8.   mon.setCursorPos(1,1)
  9.   mon.setTextScale(2)
  10.   mon.setBackgroundColor(colors.lime)
  11.   mon.write("open")
  12.   mon.setCursorPos(1,2)
  13.   mon.write("    ")
  14. end
  15.  
  16. local maxcount = 3
  17.  
  18. local function count()
  19.   for x = maxcount, 1, -1 do
  20.     mon.setCursorPos(2,2)
  21.     mon.clearLine()
  22.     mon.write(x.."s")
  23.     sleep(1)
  24.   end
  25.   mon.clearLine()
  26. end
  27.  
  28. local mw = 0
  29. local mh = 0
  30.  
  31. local function clickSpace()
  32.   if mw > 0 and 5 and mh > 0 and mh < 3 then
  33.     mon.setCursorPos(1,1)
  34.     mon.setBackgroundColor(colors.red)
  35.     mon.write("open")
  36.     rs.setOutput("left", true)
  37.     count()
  38.     rs.setOutput("left", false)
  39.   end
  40.   initial()
  41. end
  42.  
  43. initial()
  44. while true do
  45.   local event, side, xPos, yPos = os.pullEvent("monitor_touch")
  46.   mw = xPos
  47.   mh = yPos
  48.   clickSpace()
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement