infiniteblock

Untitled

Aug 28th, 2020 (edited)
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. local function loop1 ()
  2. while true do
  3.  
  4.     local _, direction = os.pullEvent("mouse_scroll") --# listening for mouse_scroll events
  5.     if direction == -1 then --# direction 1 is when you scroll the wheel one way
  6.         if  y < #scrollBuffer-maxY then --# don't want to be able to scroll outside of the range of the table
  7.             y=y+1
  8.     end
  9.     term.clear() --# clearing screen so we can print the new scrolled version
  10.     drawHeader()
  11.     drawButton(4, "Post Message")
  12.     drawButton(8, "Return")
  13.     term.setCursorPos(1,5) --# setting to 1,1
  14.     for i = 1, maxY-1 do --# looping through the screen coords
  15.         if not scrollBuffer[i+y] then break end --# making sure the table location isnt nil
  16.         print(scrollBuffer[i+y]) --# printing the table entry, i+y is the table entry
  17.     end
  18.     elseif direction == 1 then --# -1 is the only direction
  19.         if y~=0 then --# not going to explain anymore, as it all repeats from here
  20.             y=y-1
  21.             end
  22.     term.clear()
  23.     drawHeader()
  24.     drawButton(4, "Post Message")
  25.     drawButton(8, "Return")
  26.     term.setCursorPos(1,5)
  27.     for i = 1, maxY-1 do
  28.         if not scrollBuffer[i+y] then break end
  29.         print(scrollBuffer[i+y])
  30.     end
  31. end
  32. end
  33. end
  34.  local function loop2 ()
  35.         local button = waitForButton()
  36.         if button == 4 then
  37.             post(acc, pin)
  38.         elseif button == 8 then
  39.             bank(acc, ping)
  40.         end
  41.     end
  42. -- MessageBoard
  43. function message(acc, pin)
  44.     while true do
  45.         term.clear()
  46.         drawHeader()
  47.         drawButton(4, "Post Message")
  48.         drawButton(8, "Return")
  49. local methods = {}
  50. for i = 1, 10 do
  51.     table.insert(methods,i)
  52. end
  53. local a = http.get("http://infaknox.space/messages")
  54. for line in a.readLine do
  55.     local location = (line:find(":", 1))
  56.     if location then
  57.         usr = line:sub(1, location - 1)
  58.         msg = line:sub(location + 1)
  59.         table.insert(scrollBuffer," Message: "..usr.." \n ".."By: "..msg) --# storing all of the things printed to the screen into a table.concat(
  60.         end
  61. end
  62. term.setCursorPos(1, 5)
  63. for i = 1, 5 do
  64. print(scrollBuffer[i])
  65. end
  66.     parallel.waitForAny(loop1, loop2)
  67. end
  68. end
Add Comment
Please, Sign In to add comment