petomka

Untitled

Aug 10th, 2014
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 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.clear()
  16.  m.write(option1)
  17.  m.write("          ")
  18.  
  19.  m.setBackgroundColor(colors.green)
  20.  m.write(option2)
  21.  m.write("          ")
  22.  
  23.  m.setBackgroundColor(colors.yellow)
  24.  m.write(option3)
  25.  m.write("          ")
  26.  
  27.  m.setBackgroundColor(colors.orange)
  28.  m.write(option4)
  29.  m.write("          ")
  30.  
  31.  m.setBackgroundColor(colors.red)
  32.  m.write(option5)
  33.  m.write("          ")
  34. end
  35.  
  36. function SetTime()
  37.  if input == 1 then
  38.   time = option1
  39.  elseif input == 2 then
  40.   time = option2
  41.  elseif input == 3 then
  42.   time = option3
  43.  elseif input == 4 then
  44.   time = option4
  45.  elseif input == 5 then
  46.   time = option5
  47.  end
  48. end
  49.  
  50. function Timer()
  51.  while time >= 0.2 do
  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.  Layout()
  62.  redstone.setOutput("back",true)
  63.  SetTime()
  64.  Timer()
  65.  redstone.setOutput("back",false)
  66.  Layout()
  67. end
  68.  
  69. while true do
  70.  event,side,x,y = os.pullEvent()
  71.  if event == "monitor_touch" then
  72.   if x >= 1 and y == 1 then
  73.    input = 1
  74.    Toggle()
  75.   elseif x >= 1 and y == 2 then
  76.    input = 2
  77.    Toggle()
  78.   elseif x >= 1 and y == 3 then
  79.    input = 3
  80.    Toggle()
  81.   elseif x >= 1 and y == 4 then
  82.    input = 4
  83.    Toggle()
  84.   elseif x >= 1 and y == 5 then
  85.    input = 5
  86.    Toggle()
  87.   end
  88.  end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment