CobraOs

Untitled

Oct 30th, 2016
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. username = ""
  2.  
  3. function limitRead(nLimit, replaceChar)
  4. term.setCursorPos(13,6)
  5. term.setBackgroundColor(colors.lightBlue)
  6. term.setCursorBlink(true)
  7. local cX, cY = term.getCursorPos()
  8. working = true
  9. if replaceChar == "" then replaceChar = nil end
  10. while working do
  11. local event, p1, p2, p3 = os.pullEvent()
  12. if event == "char" then
  13. -- Character event
  14. if #username + 1 <= nLimit then
  15. username = username .. p1
  16. write(replaceChar or p1)
  17. end
  18. elseif event == "key" and p1 == keys.backspace and #username >= 1 then
  19. -- Backspace
  20. username = string.sub(username, 1, #username-1)
  21. xPos, yPos = term.getCursorPos()
  22. term.setCursorPos(xPos-1, yPos)
  23. write(" ")
  24. term.setCursorPos(xPos-1, yPos)
  25. end
  26. if event == "key" and p1 == keys.enter then
  27. working = false
  28. elseif event == "mouse_click" then
  29. if p2 >= 13 and p2 <= 29 and p3 == 6 then
  30. os.sleep(0)
  31. else
  32. working = false
  33. return p2, p3
  34. end
  35. end
  36. end
  37. term.setCursorBlink(false)
  38. return 1,1
  39. end
  40.  
  41. function testmouse()
  42. if busy == false then
  43. return
  44. end
  45. if x>= 13 and x<= 34 and y>=9 and y<=14 then
  46. shell.run("textedit2", "order", "menu")
  47. x,y = 1
  48. elseif x >= 13 and x <= 29 and y == 6 then
  49. x,y = limitRead(16)
  50. if username == "dark" then
  51. shell.run("fg", "jobs2")
  52. end
  53. elseif y == 16 and x >= 32 and x <= 50 then
  54. busy = false
  55. end
  56. end
  57.  
  58. term.setBackgroundColor(colors.lime)
  59. term.clear()
  60. paintutils.drawImage(paintutils.loadImage("menupic"), 2, 1)
  61. for i=1, 51 do
  62. paintutils.drawLine(1, 19, i, 19,colors.green)
  63. os.sleep(0)
  64. end
  65. term.setBackgroundColor(colors.white)
  66. term.clear()
  67. paintutils.drawImage(paintutils.loadImage("menupic2"), 9, 4)
  68. term.setBackgroundColor(colors.white)
  69. term.setTextColor(colors.black)
  70. term.setCursorPos(13,5)
  71. term.write("Username")
  72. term.setCursorPos(13,8)
  73. term.write("order")
  74.  
  75. term.setCursorPos(13,6)
  76. term.setBackgroundColor(colors.lightBlue)
  77.  
  78. busy = true
  79. while busy do
  80. event, button, x, y = os.pullEvent( "mouse_click" )
  81. testmouse()
  82. testmouse()
  83. end
  84. file = fs.open("jobs", "a")
  85. file.writeLine(username)
  86. file.close()
  87. shell.run("copy", "order", username)
  88. file = fs.open(username, "a")
  89. file.writeLine(username)
  90. file.close()
  91. shell.run("delete", "order")
  92. os.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment