An_random_user

Untitled

Jun 29th, 2022 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. local headers = {
  2.   [ "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
  3.   }
  4. local dead = false
  5. local function main() -- Define the first function.
  6. while true do
  7.     if dead then
  8.     error("Exited.",0)
  9.         end
  10.         write("Website name: ")
  11.         local websitename = read()
  12.         local url = "http://"..websitename
  13.         if http.checkURL(url) then
  14.             local httpget = http.get(url, headers)
  15.         print(httpget.readAll())
  16.         end
  17. end
  18. end
  19.  
  20. local function scroller()  -- Define the second function.
  21. pcall(function()
  22. local methods = peripheral.getMethods("back")
  23. local scrollBuffer = {}
  24. local _,maxY = term.getSize() --# getting max screen size, so we only print to the screen
  25.  
  26. for k, v in pairs(methods) do
  27.   print(k .. " : " .. v)
  28.   table.insert(scrollBuffer,k.." : ".. v) --# storing all of the things printed to the screen into a table
  29. end
  30.  
  31. local y = 0
  32.  
  33. while true do
  34.   local _, direction = os.pullEvent("mouse_scroll") --# listening for mouse_scroll events
  35.   if direction == 1 then --# direction 1 is when you scroll the wheel one way
  36.         if  y < #scrollBuffer-maxY then --# don't want to be able to scroll outside of the range of the table
  37.           y=y+1
  38.         end
  39.         term.clear() --# clearing screen so we can print the new scrolled version
  40.         term.setCursorPos(1,1) --# setting to 1,1
  41.         for i = 1, maxY-1 do --# looping through the screen coords
  42.           if not scrollBuffer[i+y] then break end --# making sure the table location isnt nil
  43.           print(scrollBuffer[i+y]) --# printing the table entry, i+y is the table entry
  44.         end
  45.         term.write(scrollBuffer[i+y])
  46.   elseif direction == -1 then --# -1 is the only direction
  47.         if y~=0 then --# not going to explain anymore, as it all repeats from here
  48.           y=y-1
  49.         end
  50.         term.clear()
  51.         term.setCursorPos(1,1)
  52.         for i = 1, maxY-1 do
  53.           if not scrollBuffer[i+y] then break end
  54.           print(scrollBuffer[i+y])
  55.         end
  56.         term.write(scrollBuffer[i+y])
  57.   end
  58. end
  59. end)
  60. end
  61.  
  62.  
  63. parallel.waitForAll(main, scroller)  -- Run both functions in parallel and wait until both of them completes.
Add Comment
Please, Sign In to add comment