Advertisement
Guest User

ComputerCraft Help Line 91 Attempt to call Nil????

a guest
Aug 19th, 2013
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. --]] File: Manager [[--
  2. term.clear()
  3. term.setBackgroundColor(colors.blue)
  4. term.setTextColor(colors.white)
  5. term.clear()
  6. term.setCursorPos(1,1)
  7. write "File Command: "
  8. cmd = read()
  9. if cmd == "List" or cmd == "list" or cmd == "ls" or cmd == "edit" or cmd == "Edit" or cmd == "create" or cmd == "Create" or cmd == "exit()" then
  10. ----------------------------------------------------------
  11. if cmd == "List" or cmd == "list" or cmd == "ls" then
  12. print "Files: "
  13. local bAll = false
  14. local tArgs = { ... }
  15. if #tArgs > 0 and tArgs[1] == "all" then
  16. bAll = true
  17. end
  18.  
  19. local tPrograms = shell.programs( bAll )
  20. textutils.pagedTabulate( tPrograms )
  21. print "Press Any Key To Continue."
  22. event = os.pullEvent()
  23. shell.run("manager")  
  24. ---------------------------------------------------
  25. function ED()
  26. term.clear()
  27. term.setCursorPos(1,1)
  28. term.setBackgroundColor(colors.blue)
  29. term.setTextColor(colors.white)
  30. term.clear()
  31. write "Edit: "
  32. ed = read()
  33. if ed == "exit()" then
  34. shell.run("gui")
  35. elseif ed == "back" then
  36. shell.run("manager")
  37. elseif fs.exists(ed) then
  38. shell.run("edit",ed)
  39. edit()
  40. else
  41. print("File: "..ed.." Doesnt Exist")
  42. sleep(3)
  43. edit()
  44. end
  45. end
  46. end
  47. -------------------------------------------------
  48. function create()
  49. term.setBackgroundColor(colors.blue)
  50. term.setTextColor(colors.white)
  51. term.clear()
  52. term.setCursorPos(1,1)
  53. write "CreateFile:  "
  54. cr = read()
  55. if cr == "exit()"then
  56. shell.run("gui")
  57. elseif cr == "back" then
  58. shell.run("manager")
  59. elseif fs.exists(cr) then
  60. print("Error File:"..cr.." Already Exists")
  61. sleep(2)
  62. create()
  63. else
  64. print("Create File:"..cr.." ?")
  65. print " [YES] - [NO] "
  66. local event, button, X, Y = os.pullEventRaw()
  67. while true do
  68. if event == "mouse_click" then
  69.   --]] yes selected [[--
  70.   if X >=1 and X <=7 and Y == 3 and button == 1 then
  71.   print "Creating File..."
  72.   sleep(2)
  73.   file = fs.open(cr,"w")
  74.   file.write("--]] File: "..cr.." [[--")
  75.   file.close()
  76.   print "File Created"
  77.   sleep(2)
  78.   create()
  79.   --]] no selected [[--
  80.   elseif X >=9 and X <=14 and Y == 3 and button == 1 then
  81.   print "File Creation Canceled"
  82.   sleep(2)
  83.   create()
  84.   end
  85.   end
  86.   end
  87.   end
  88.   end
  89. ---------------------------------------------------
  90. if cmd == "edit" or cmd == "Edit" then
  91. ED()
  92. end
  93.  
  94. if(cmd == "create" or cmd == "Create") then
  95. create()
  96. end
  97. -----------------------------------------------------
  98. else
  99. print "Error Not A Command Commands are edit , create or list"
  100. sleep(2)
  101. shell.run("manager")
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement