petomka

Untitled

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