petomka

Untitled

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