Advertisement
XxZajoZzO

ComputerCraft program for controlling mob spawners

Jun 18th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. os.loadAPI("button")
  2. mon = peripheral.wrap("left")
  3. mon.clear()
  4.  
  5. function createButtons()
  6.   --Creates Buttons
  7.   --Doors
  8.   button.setTable("Door", openDoor, 2,17,2,4)
  9.   --Lights
  10.   button.setTable("Lights", lightsOn, 2,17,8,10)
  11.   button.screen()
  12.   lightsOn()
  13. end
  14.  
  15. function getClick()
  16.   --Wait for click
  17.   event,side,x,y = os.pullEvent("monitor_touch")
  18.   --Read click position
  19.   button.checkxy(x,y)
  20. end
  21.  
  22. function lightsOn()
  23.   --Lights
  24.   button.toggleButton("Lights")
  25.   if redstone.getOutput("top") then
  26.     redstone.setOutput("top", false)
  27.   else
  28.     redstone.setOutput("top", true)
  29.   end
  30. end
  31.  
  32. function openDoor()
  33.   --Door
  34.   button.toggleButton("Door")
  35.   if redstone.getOutput("right") then
  36.     redstone.setOutput("right", false)
  37.   else
  38.     redstone.setOutput("right", true)
  39.   end
  40. end
  41.  
  42. createButtons()
  43.  
  44. while true do
  45.   getClick()
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement