Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local headers = {
- [ "User-Agent" ] = "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko" -- Makes website think that Internet Explorer 11 is requesting information
- }
- local dead = false
- local function main() -- Define the first function.
- while true do
- if dead then
- error("Exited.",0)
- end
- write("Website name: ")
- local websitename = read()
- local url = "http://"..websitename
- if http.checkURL(url) then
- local httpget = http.get(url, headers)
- print(httpget.readAll())
- end
- end
- end
- local function scroller() -- Define the second function.
- pcall(function()
- local methods = peripheral.getMethods("back")
- 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 = 0
- 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[i+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[i+y])
- end
- end
- end)
- end
- parallel.waitForAll(main, scroller) -- Run both functions in parallel and wait until both of them completes.
Add Comment
Please, Sign In to add comment