Advertisement
Guest User

Test

a guest
Apr 23rd, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. local term = require("term")
  2. local component = require("component")
  3. local filesystem = require("filesystem")
  4. local event = require("event")
  5. local gpu = component.gpu
  6. local args = {...}
  7. local w, h = gpu.getResolution()
  8. directory = args[2]
  9. currentfile = 0
  10. tempload = 0
  11. fileindex = {"none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none","none"}
  12. function getfiles(dir)
  13. tempload = 0
  14. for file in filesystem.list(dir) do
  15. tempload = tempload + 1
  16. fileindex[tempload] = file
  17. end
  18. end
  19. function realoadlist()
  20. getfiles(directory)
  21. gpu.fill(1, 1, w, h, " ")
  22. for i = 1,24 do
  23. gpu.set(1, i, "█")
  24. gpu.set(2, i, fileindex[i])
  25. if filesystem.isDirectory(fileindex[i]) then
  26. gpu.setForeground(0xfdff00)
  27. gpu.set(1, i, "█")
  28. gpu.setForeground(0xffffff)
  29. end
  30. end
  31. end
  32. function realoadlist2()
  33. getfiles(directory)
  34. term.clear()
  35. for i = 24,38 do
  36. i = i - 23
  37. gpu.set(1, i, "█")
  38. gpu.set(2, i, fileindex[i])
  39. if filesystem.isDirectory(fileindex[i]) then
  40. gpu.setForeground(0xfdff00)
  41. gpu.set(1, i, "█")
  42. gpu.setForeground(0xffffff)
  43. end
  44. end
  45. end
  46. -- FOR DEBUG AFTER DELETE!!!
  47. if args[1] == "1" then
  48. realoadlist()
  49. getfiles(directory)
  50. end
  51. if args[1] == "2" then
  52. realoadlist2()
  53. getfiles(directory)
  54. end
  55. while true do
  56. local id, _, x, y = event.pull("touch")
  57. if id == "touch" then
  58. if filesystem.isDirectory(fileindex[y]) == true then
  59. gpu.fill(1, 1, w, h, " ")
  60. directory = fileindex[y]
  61. getfiles(directory)
  62. realoadlist()
  63. end
  64. if filesystem.isDirectory(fileindex[y]) == false then
  65. os.execute(fileindex[y])
  66. end
  67. if x == 1 and y == 25 then
  68. getfiles(directory)
  69. realoadlist()
  70. end
  71. end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement