Advertisement
Guest User

startup

a guest
Apr 3rd, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. local input = nil
  2. local rOut = "back"
  3. local rOn = true
  4. local mon = peripheral.wrap("right")
  5. local launching = false
  6. local mX, mY = mon.getSize()
  7.  
  8. function centerText(monitor, userString)
  9.   y = mY/2
  10.   x =  math.floor(mX/2) - math.floor(string.len(userString)/2)
  11.   monitor.setCursorPos(x, y)
  12.   monitor.write(UserString)
  13. end
  14.  
  15. function redstoneChange()
  16.   if rOn then
  17.    -- print("Redstone on")
  18.     rs.setOutput(rOut, true)
  19.   else
  20.    -- print("Redstone off")
  21.     rs.setOutput(rOut, false)
  22.   end
  23. end
  24.  
  25. function monitorTimer()
  26.   --mon.clear()
  27.   --mon.setTextScale(2)
  28.   --print("working")
  29.  -- print("Monitor Timer")
  30.   for i = 0, 25 do
  31.     if (i == 5) or (i < 5) then
  32.       mon.clear()
  33.       mon.setTextColor(colors.green)
  34.       print(25 - i)
  35.       centerText(mon, 25 - i)
  36.     elseif (i == 15) or (i < 15) then
  37.       mon.clear()
  38.       mon.setTextColor(colors.orange)
  39.       print(25 -i)
  40.       centerText(mon, 25 - i)
  41.     elseif (i == 25) or (i < 25) then
  42.       mon.clear()
  43.       mon.setTextColor(colors.red)
  44.       print(25 - i)
  45.       centerText(mon, 25 - i)
  46.     else
  47.       mon.clear()
  48.       mon.setTextColor(colors.white)
  49.       print(15 - i)
  50.       centerText(mon, 15 - i)
  51.     end
  52.     i= i + 1
  53.     sleep(1)
  54.   end
  55. end
  56.  
  57. redstoneChange()
  58.  
  59. while true do
  60.  -- input = read()
  61.  -- if input ~= nil or input ~= "" then
  62.    -- if input == "open" then
  63.    os.pullEvent("redstone")
  64.    launching = rs.getInput("left")
  65.    
  66.    if launching then
  67.       mon.clear()
  68.       rOn = false
  69.       redstoneChange()
  70.       monitorTimer()
  71.       rOn = true
  72.       redstoneChange()
  73.    end    
  74.   --  end
  75. --  end
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement