petomka

Mobfarm Experimental v0.1.2

Aug 11th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.63 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. local execute = 0 -- Diesen Wert nicht veraendern
  13.  
  14. m = peripheral.wrap(monside)
  15. m.clear()
  16.  
  17. redstone.setOutput(redside,false)
  18.  
  19. function Layout()
  20.  m.setBackgroundColor(colors.cyan)
  21.  m.clear()
  22.  m.setCursorPos(1,1)
  23.  m.write(option1)
  24.  m.write("          ")
  25.  
  26.  m.setBackgroundColor(colors.green)
  27.  m.setCursorPos(1,2)
  28.  m.write(option2)
  29.  m.write("          ")
  30.  
  31.  m.setBackgroundColor(colors.yellow)
  32.  m.setCursorPos(1,3)
  33.  m.write(option3)
  34.  m.write("          ")
  35.  
  36.  m.setBackgroundColor(colors.orange)
  37.  m.setCursorPos(1,4)
  38.  m.write(option4)
  39.  m.write("          ")
  40.  
  41.  m.setBackgroundColor(colors.red)
  42.  m.setCursorPos(1,5)
  43.  m.write(option5)
  44.  m.write("          ")
  45. end
  46.  
  47. Layout()
  48.  
  49. function SetTime()
  50.  if input == 1 then
  51.   time = option1
  52.  elseif input == 2 then
  53.   time = option2
  54.  elseif input == 3 then
  55.   time = option3
  56.  elseif input == 4 then
  57.   time = option4
  58.  elseif input == 5 then
  59.   time = option5
  60.  end
  61. end
  62.  
  63. function CancelButton()
  64.  m.setBackgroundColor(colors.green)
  65.  m.setTextColor(colors.red)
  66.  m.setCursorPos(1,5)
  67.  m.write("Cancel ")
  68.  m.setTextColor(colors.white)
  69.  m.setBackgroundColor(colors.red)
  70.  event,side,x,y = os.pullEvent
  71.  if event == "monitor_touch" then
  72.   if x >= 1 and y == 5 then
  73.    time = 0
  74.    execute = 0
  75.   else
  76.   end
  77.  else
  78.  end
  79. end
  80.  
  81. function Timer()
  82.  while time >= 0.2 do
  83.   m.clear()
  84.   m.setCursorPos(1,3)
  85.   m.write(time)
  86.   time = time - 0.1
  87.   CancelButton()
  88.   sleep(0.1)
  89.  end
  90. end
  91.  
  92. function Toggle()
  93.  Layout()
  94.  redstone.setOutput(redside,true)
  95.  SetTime()
  96.  Timer()
  97.  redstone.setOutput(redside,false)
  98.  Layout()
  99. end
  100.  
  101. function TimerToggleParallel()
  102.  while execute = 1 do
  103.   parallel.waitForAny(Timer, Toggle)
  104.  end
  105. end
  106.  
  107. while true do
  108.  event,side,x,y = os.pullEvent()
  109.  if event == "monitor_touch" then
  110.   if x >= 1 and y == 1 then
  111.    input = 1
  112.    execute = 1
  113.    TimerToggleParallel()
  114.   elseif x >= 1 and y == 2 then
  115.    input = 2
  116.    execute = 1
  117.    TimerToggleParallel()
  118.   elseif x >= 1 and y == 3 then
  119.    input = 3
  120.    execute = 1
  121.    TimerToggleParallel()
  122.   elseif x >= 1 and y == 4 then
  123.    input = 4
  124.    execute = 1
  125.    TimerToggleParallel()
  126.   elseif x >= 1 and y == 5 then
  127.    input = 5
  128.    execute = 1
  129.    TimerToggleParallel()
  130.   end
  131.  end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment