Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local component = require("component")
- local filesystem = require("filesystem")
- local event = require("event")
- local gpu = component.gpu
- local args = {...}
- local w, h = gpu.getResolution()
- directory = args[2]
- currentfile = 0
- tempload = 0
- 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"}
- function getfiles(dir)
- tempload = 0
- for file in filesystem.list(dir) do
- tempload = tempload + 1
- fileindex[tempload] = file
- end
- end
- function realoadlist()
- getfiles(directory)
- gpu.fill(1, 1, w, h, " ")
- for i = 1,24 do
- gpu.set(1, i, "█")
- gpu.set(2, i, fileindex[i])
- if filesystem.isDirectory(fileindex[i]) then
- gpu.setForeground(0xfdff00)
- gpu.set(1, i, "█")
- gpu.setForeground(0xffffff)
- end
- end
- end
- function realoadlist2()
- getfiles(directory)
- term.clear()
- for i = 24,38 do
- i = i - 23
- gpu.set(1, i, "█")
- gpu.set(2, i, fileindex[i])
- if filesystem.isDirectory(fileindex[i]) then
- gpu.setForeground(0xfdff00)
- gpu.set(1, i, "█")
- gpu.setForeground(0xffffff)
- end
- end
- end
- -- FOR DEBUG AFTER DELETE!!!
- if args[1] == "1" then
- realoadlist()
- getfiles(directory)
- end
- if args[1] == "2" then
- realoadlist2()
- getfiles(directory)
- end
- while true do
- local id, _, x, y = event.pull("touch")
- if id == "touch" then
- if filesystem.isDirectory(fileindex[y]) == true then
- gpu.fill(1, 1, w, h, " ")
- directory = fileindex[y]
- getfiles(directory)
- realoadlist()
- end
- if filesystem.isDirectory(fileindex[y]) == false then
- os.execute(fileindex[y])
- end
- if x == 1 and y == 25 then
- getfiles(directory)
- realoadlist()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement