tomtrein

job network

Aug 1st, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. i=0
  2. jobsmin = 0
  3. scroll = function()
  4. for Py = 1, 19 do
  5. term.setCursorPos(1, Py)
  6. towriteid = i + Py
  7. if towriteid > #jobs then
  8. break
  9. end
  10. towrite = jobs[towriteid]
  11. term.write(towrite)
  12. end
  13. local event, scrollDirection, x, y = os.pullEvent("mouse_scroll")
  14. term.clear()
  15. i = i+scrollDirection
  16. if i==-1 then
  17. i=0
  18. elseif i>jobsmin then
  19. i=jobsmin
  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, jobs[thejobcodeid])
  30. end
  31.  
  32. seejob = function(thecodeid, jobname)
  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. while true do
  50. local event, button, x, y = os.pullEvent( "mouse_click" )
  51. if y == 19 then
  52. newfile = fs.open(filename, "a")
  53. newfile.writeLine(jobname)
  54. term.clear()
  55. term.setCursorPos(10, 10)
  56. term.write("Your name: ")
  57. newfile.writeLine(read())
  58. newfile.close()
  59. else
  60. break
  61. end
  62. end
  63. end
  64.  
  65. file = fs.open("job", "r")
  66. jobs = {}
  67. codes = {}
  68. while true do
  69. line = file.readLine()
  70. if line then
  71. table.insert(jobs, line:sub(11, #line))
  72. table.insert(codes, line:sub(1, 10))
  73. else
  74. break
  75. end
  76. end
  77.  
  78. jobsmin = #jobs-1
  79. while true do
  80. parallel.waitForAny(scroll, click)
  81. end
Advertisement
Add Comment
Please, Sign In to add comment