Advertisement
Guest User

Timer

a guest
Jul 29th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. local x = 3  -- position text X
  2. local y = 1  -- position text Y
  3. local tArgs = {...} -- timer
  4. local t = tArgs[1]
  5.  
  6. local monitor = peripheral.wrap("back")
  7. local speaker = peripheral.wrap("top")
  8.  
  9. while true do
  10.   os.pullEvent("redstone")
  11.   if rs.getInput("bottom") then
  12.     -- start timer
  13.     for i = t,0,-1 do
  14.       monitor.clear()
  15.       monitor.setCursorPos(x,y)
  16.       monitor.setTextScale(4)
  17.       if i < t/5 then
  18.         monitor.setTextColor(colors.red)
  19.         speaker.speak(tostring(i),10,"fr")
  20.       elseif i < t/5*2 then
  21.         monitor.setTextColor(colors.orange)
  22.       elseif i < t/5*3 then
  23.         monitor.setTextColor(colors.yellow)
  24.       elseif i < t/5*4 then
  25.         monitor.setTextColor(colors.green)
  26.       else
  27.         monitor.setTextColor(colors.blue)
  28.       end
  29.       monitor.write(tostring(i))
  30.       sleep(1)
  31.     end
  32.     -- end of timer
  33.   end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement