Guest User

Untitled

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