Advertisement
Dojnaz

CC MystPortal

Dec 3rd, 2020 (edited)
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. local mon = peripheral.wrap("monitor_67")
  2. local pistons = "left"
  3. local chest = "back"
  4. -- the direction of which the receptacle is going from the chest, not the computer
  5. local receptacle = "right"
  6. --local books = {}
  7. books = {}
  8. local page = 1
  9.  
  10. --Don't edit below here unless you know what you are doing :)
  11. local event
  12. local eventSide
  13. local eventX
  14. local eventY
  15. local skipRedstone = false
  16.  
  17. function lsleep()
  18.     sleep(2)
  19. end
  20.  
  21. function touchDraw()
  22.     event, eventSide, eventX, eventY = os.pullEvent("monitor_touch")
  23. end
  24.  
  25. function renderMonitor()
  26.     mon.clear()
  27.     mon.setCursorPos(1,1)
  28. end
  29.  
  30. function updateBooks()
  31.     books = {}
  32.     c = peripheral.wrap(chest)
  33.     for book in pairs(c.getAllStacks()) do
  34.         _book = {}
  35.         stack = c.getStackInSlot(book)
  36.         _book.name = stack.destination
  37.         _book.slot = book
  38.         books[#books + 1] = _book
  39.     end
  40. end
  41.  
  42. while (true) do
  43.     updateBooks()
  44.     if (skipRedstone == false) then
  45.         redstone.setOutput(pistons, false)
  46.     end
  47.     skipRedstone = false
  48.     returned = parallel.waitForAny(lsleep, touchDraw)
  49.     if (returned == 2) then
  50.         print("monitor touch")
  51.         redstone.setOutput(pistons, true)
  52.         skipRedstone = true
  53.     else
  54.        
  55.     end
  56. end
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement