Guest User

MobFarm

a guest
Nov 11th, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. os.loadAPI("Button")
  2. p = peripheral.wrap("back")
  3. m = peripheral.wrap("right")
  4. m.clear()
  5.  
  6. local lit = {["state"] = false}
  7. local wind = {["state"] = false}
  8.  
  9. function fillTable()
  10.   Button.setTable("Lights", lights, 4,14,3,5)
  11.   Button.setTable("Fans", fans, 4,14,7,9)
  12.   Button.screen()
  13. end
  14.  
  15. function getClick()
  16.   event,side,x,y = os.pullEvent("monitor_touch")
  17.   Button.checkxy(x,y)
  18. end
  19.  
  20. function lights()
  21.   Button.toggleButton("Lights")
  22.  
  23.   if not lit.state then
  24.     p.setBundledOutput(colors.combine(p.getBundledOutput()colors.purple))
  25.     lit.state = true
  26.     print("Lights on")
  27.   else
  28.     p.setBundledOutput(colors.subtract(p.getBundledOutput()colors.purple))
  29.     lit.state = false
  30.     print("Lights off")
  31.   end
  32. end
  33.  
  34. function fans()
  35.   Button.toggleButton("Fans")
  36.  
  37.   if not wind.state then
  38.     p.setBundledOutput(colors.combine(p.getBundledOutput()colors.white))
  39.     wind.state = true
  40.     print("Fans on")
  41.   else
  42.     p.setBundledOutput(colors.subtract(p.getBundledOutput()colors.white))
  43.     wind.state = false
  44.     print("Fans off")
  45.   end
  46. end
  47.  
  48. fillTable()
  49. Button.heading("MobFarm")
  50. while true do
  51.   getClick()
  52. end
Advertisement
Add Comment
Please, Sign In to add comment