petomka

Untitled

Aug 10th, 2014
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. m = peripheral.wrap("top")
  2. m.clear()
  3.  
  4. local option1 = 60   -- Zeit fuer Option1 in s
  5. local option2 = 120  -- Zeit fuer Option2 in s
  6. local option3 = 180  -- Zeit fuer Option3 in s
  7. local option4 = 300  -- Zeit fuer Option4 in s
  8. local option5 = 600  -- zeit fuer Option5 in s
  9.  
  10. local input = 0 -- Diesen Wert nicht veraendern
  11. local time = 0 -- Diesen Wert nicth veraendern
  12.  
  13. function Layout()
  14.  m.setBackgroundColor(colors.cyan)
  15.  m.write(option1)
  16.  m.write("          ")
  17.  
  18.  m.setBackgroundColor(colors.green)
  19.  m.write(option2)
  20.  m.write("          ")
  21.  
  22.  m.setBackgroundColor(colors.yellow)
  23.  m.write(option3)
  24.  m.write("          ")
  25.  
  26.  m.setBackgroundColor(colors.orange)
  27.  m.write(option4)
  28.  m.write("          ")
  29.  
  30.  m.setBackgroundColor(colors.red)
  31.  m.write(option5)
  32.  m.write("          ")
  33. end
  34.  
  35. function SetTime()
  36.  if input == 1 then
  37.   time = option1
  38.  elseif input == 2 then
  39.   time = option2
  40.  elseif input == 3 then
  41.   time = option3
  42.  elseif input == 4 then
  43.   time = option4
  44.  elseif input == 5 then
  45.   time = option5
  46.  end
  47. end
  48.  
  49. function Timer()
  50.  while time >= 0.2 do
  51.   m.setBackgroundColor(colors.red)
  52.   m.clear()
  53.   m.setCursorPos(1,3)
  54.   m.write(time)
  55.   time = time - 0.1
  56.   sleep(0.1)
  57.  end
  58. end
  59.  
  60. function Toggle()
  61.  redstone.setOutput("back",true)
  62.  SetTime()
  63.  Timer()
  64.  redstone.setOutput("back",false)
  65.  Layout()
  66. end
  67.  
  68. while true do
  69.  event,side,x,y = os.pullEvent()
  70.  if event == "monitor_touch" then
  71.   if x >= 1 and y == 1 then
  72.    input = 1
  73.    Toggle()
  74.   elseif x >= 1 and y == 2 then
  75.    input = 2
  76.    Toggle()
  77.   elseif x >= 1 and y == 3 then
  78.    input = 3
  79.    Toggle()
  80.   elseif x >= 1 and y == 4 then
  81.    input = 4
  82.    Toggle()
  83.   elseif x >= 1 and y == 5 then
  84.    input = 5
  85.    Toggle()
  86.   end
  87.  end
  88. end
Advertisement
Add Comment
Please, Sign In to add comment