Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local methods = peripheral.getMethods("back")
- for i = 1, 100 do
- table.insert(methods,i)
- end
- local scrollBuffer = {}
- local _,maxY = term.getSize() --# getting max screen size, so we only print to the screen
- for k, v in pairs(methods) do
- print(k .. " : " .. v)
- table.insert(scrollBuffer,k.." : ".. v) --# storing all of the things printed to the screen into a table
- end
- local y = #scrollBuffer
- while true do
- local _, direction = os.pullEvent("mouse_scroll") --# listening for mouse_scroll events
- if direction == 1 then --# direction 1 is when you scroll the wheel one way
- if y < #scrollBuffer-maxY then --# don't want to be able to scroll outside of the range of the table
- y=y+1
- end
- term.clear() --# clearing screen so we can print the new scrolled version
- term.setCursorPos(1,1) --# setting to 1,1
- for i = 1, maxY-1 do --# looping through the screen coords
- if not scrollBuffer[i+y] then break end --# making sure the table location isnt nil
- print(scrollBuffer[i+y]) --# printing the table entry, i+y is the table entry
- end
- term.write(scrollBuffer[maxY+y])
- elseif direction == -1 then --# -1 is the only direction
- if y~=0 then --# not going to explain anymore, as it all repeats from here
- y=y-1
- end
- term.clear()
- term.setCursorPos(1,1)
- for i = 1, maxY-1 do
- if not scrollBuffer[i+y] then break end
- print(scrollBuffer[i+y])
- end
- term.write(scrollBuffer[maxY+y])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement