cobra_tomtrein

job board

Aug 2nd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 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. term.clear()
  58. term.setCursorPos(10, 10)
  59. term.write("username: ")
  60. username = read()
  61. passfile = fs.open(username.."pass", "r")
  62. thepass = passfile.readLine()
  63. passfile.close()
  64. term.clear()
  65. term.setCursorPos(10, 10)
  66. term.write("password: ")
  67. password = read()
  68. os.loadAPI("crypt")
  69. password = crypt.run(password, password)
  70. if password == thepass then
  71. newfile.writeLine(username)
  72. newfile.close()
  73. end
  74. else
  75. break
  76. end
  77. end
  78. end
  79.  
  80. file = fs.open("job", "r")
  81. jobs = {}
  82. codes = {}
  83. while true do
  84. line = file.readLine()
  85. if line then
  86. table.insert(jobs, line:sub(11, #line))
  87. table.insert(codes, line:sub(1, 10))
  88. else
  89. break
  90. end
  91. end
  92.  
  93. jobsmin = #jobs-1
  94. while true do
  95. parallel.waitForAny(scroll, click)
  96. end
Advertisement
Add Comment
Please, Sign In to add comment