tomtrein

Untitled

Aug 1st, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. i=0
  2. jobsmin = 0
  3. scroll = function()
  4. local event, scrollDirection, x, y = os.pullEvent("mouse_scroll")
  5. term.clear()
  6. i = i+scrollDirection
  7. if i==-1 then
  8. i=0
  9. elseif i>jobsmin then
  10. i=jobsmin
  11. end
  12. for Py = 1, 19 do
  13. term.setCursorPos(1, Py)
  14. towriteid = i + Py
  15. if towriteid > #jobs then
  16. break
  17. end
  18. towrite = jobs[towriteid]
  19. term.write(towrite)
  20. end
  21. end
  22.  
  23. click = function()
  24. local event, button, x, y = os.pullEvent( "mouse_click" )
  25. thejobcodeid = y + i
  26. thejobcode = codes[thejobcodeid]
  27. print(thejobcode)
  28. print(thejobcodeid)
  29. seejob(thejobcode)
  30. end
  31.  
  32. seejob = function(thecodeid)
  33. local http1 = http.get("http://www.hastebin.com/raw/"..thecodeid)
  34. local http2 = http1.readAll()
  35. shell.run("delete", "message")
  36. local file = fs.open("message", "w")
  37. file.write(http2)
  38. file.close()
  39. local file = fs.open("message", "r")
  40. filename = file.readLine()
  41. term.clear()
  42. for i=1, 19 do
  43. line = file.readLine()
  44. term.setCursorPos(1, i)
  45. if line then
  46. term.write(line)
  47. end
  48. end
  49. end
  50.  
  51. file = fs.open("job", "r")
  52. jobs = {}
  53. codes = {}
  54. while true do
  55. line = file.readLine()
  56. if line then
  57. table.insert(jobs, line:sub(11, #line))
  58. table.insert(codes, line:sub(1, 10))
  59. else
  60. break
  61. end
  62. end
  63.  
  64. jobsmin = #jobs-1
  65. while true do
  66. parallel.waitForAny(scroll, click)
  67. end
Advertisement
Add Comment
Please, Sign In to add comment