thislooksfun

Display

Oct 15th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. rednet.open("bottom")
  2. m = peripheral.wrap("top")
  3. m.clear()
  4. m.setTextScale(1.5)
  5.  
  6. width, height = m.getSize()
  7.  
  8. departingTime = 0
  9. untilDecrement = 0
  10.  
  11. timer = os.startTimer(0.05)
  12.  
  13. while true do
  14.   event = {os.pullEvent()}
  15.  
  16.   if event[1] == "timer" then
  17.     m.clear()
  18.    
  19.     if departingTime > 0 then
  20.       if untilDecrement <= 0 then
  21.         departingTime = departingTime - 1
  22.         untilDecrement = 20
  23.       else
  24.         untilDecrement = untilDecrement - 1
  25.       end
  26.     end
  27.    
  28.     displayText = "Departing in:"
  29.     m.setCursorPos(math.floor((width-#displayText)/2), (height/2)-1)
  30.     m.write(displayText)
  31.    
  32.     displayText = departingTime.." seconds"
  33.     m.setCursorPos(math.ceil((width-#displayText)/2), (height/2)+1)
  34.     m.write(displayText)
  35.    
  36.     timer = os.startTimer(0.05)
  37.   elseif event[1] == "rednet_message" then
  38.     departingTime = tonumber(event[3]) or 0
  39.     untilDecrement = 20
  40.   end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment