Advertisement
Aruyas

Untitled

Oct 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. local methods = peripheral.getMethods("back")
  2. for i = 1, 100 do
  3. table.insert(methods,i)
  4. end
  5. local scrollBuffer = {}
  6. local _,maxY = term.getSize() --# getting max screen size, so we only print to the screen
  7.  
  8. for k, v in pairs(methods) do
  9. print(k .. " : " .. v)
  10. table.insert(scrollBuffer,k.." : ".. v) --# storing all of the things printed to the screen into a table
  11. end
  12.  
  13. local y = #scrollBuffer
  14.  
  15. while true do
  16. local _, direction = os.pullEvent("mouse_scroll") --# listening for mouse_scroll events
  17. if direction == 1 then --# direction 1 is when you scroll the wheel one way
  18. if y < #scrollBuffer-maxY then --# don't want to be able to scroll outside of the range of the table
  19. y=y+1
  20. end
  21. term.clear() --# clearing screen so we can print the new scrolled version
  22. term.setCursorPos(1,1) --# setting to 1,1
  23. for i = 1, maxY-1 do --# looping through the screen coords
  24. if not scrollBuffer[i+y] then break end --# making sure the table location isnt nil
  25. print(scrollBuffer[i+y]) --# printing the table entry, i+y is the table entry
  26. end
  27. term.write(scrollBuffer[maxY+y])
  28. elseif direction == -1 then --# -1 is the only direction
  29. if y~=0 then --# not going to explain anymore, as it all repeats from here
  30. y=y-1
  31. end
  32. term.clear()
  33. term.setCursorPos(1,1)
  34. for i = 1, maxY-1 do
  35. if not scrollBuffer[i+y] then break end
  36. print(scrollBuffer[i+y])
  37. end
  38. term.write(scrollBuffer[maxY+y])
  39. end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement