Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function list(directory)
- local a
- local b = {}
- a = fs.list(directory)
- for i=1, #a do
- if fs.isDir(a[i]) then
- b[i] = "true"
- else
- b[i] = "false"
- end
- end
- return a, b
- end
- function drawFolderIcon(x, y, text)
- paintutils.drawPixel(x, y, colors.yellow)
- paintutils.drawPixel(x, y-1, colors.yellow)
- paintutils.drawPixel(x-1, y, colors.yellow)
- paintutils.drawPixel(x-1, y-1, colors.yellow)
- term.setCursorPos(x-1, y+1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(text)
- local Out = {}
- Out[1] = {}
- Out[1].x = x
- Out[1].y = y
- Out[1].Name = text
- return Out
- end
- function drawProgramIcon(x, y, text)
- paintutils.drawPixel(x, y, colors.gray)
- paintutils.drawPixel(x-1, y, colors.gray)
- paintutils.drawPixel(x, y-1, colors.blue)
- paintutils.drawPixel(x-1, y-1, colors.blue)
- term.setCursorPos(x-1, y+1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(text)
- local Out = {}
- Out[1] = {}
- Out[1].x = x
- Out[1].y = y
- Out[1].Name = text
- return Out
- end
- function drawDriveIcon(x, y, text)
- paintutils.drawPixel(x, y, colors.black)
- paintutils.drawPixel(x-1, y, colors.gray)
- paintutils.drawPixel(x, y-1, colors.black)
- paintutils.drawPixel(x-1, y-1, colors.gray)
- term.setCursorPos(x-1, y+1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(text)
- local Out = {}
- Out[1] = {}
- Out[1].x = x
- Out[1].y = y
- Out[1].Name = text
- return Out
- end
- function bufferBackground()
- term.clear()
- paintutils.drawLine(1, 1, 51, 1, colors.lightBlue)
- paintutils.drawFilledBox(1, 2, 100, 100, colors.white)
- end
- function drawFileList(y, directory)
- local xPos = 1
- local yPos = 1
- local a = 1
- local b = {}
- local z = 0
- local s = 1
- local list2 = {}
- local bigList = {}
- b, c = list(directory)
- for i=1, #b do
- if b[s] == "rom" then
- if a % 5 == 0 then
- z = z + 1
- a = 1
- end
- list2 = drawDriveIcon(y+(z*10), a*4, b[s])
- bigList[s] = {}
- bigList[s].x = list2[1].x
- bigList[s].y = list2[1].y
- bigList[s].Name = list2[1].Name
- elseif c[s] == "false" then
- if a % 5 == 0 then
- z = z + 1
- a = 1
- end
- list2 = drawProgramIcon(y+(z*10), a*4, b[s])
- bigList[s] = {}
- bigList[s].x = list2[1].x
- bigList[s].y = list2[1].y
- bigList[s].Name = list2[1].Name
- else
- if a % 5 == 0 then
- z = z + 1
- a = 1
- end
- list2 = drawFolderIcon(y+(z*10), a*4, b[s])
- bigList[s] = {}
- bigList[s].x = list2[1].x
- bigList[s].y = list2[1].y
- bigList[s].Name = list2[1].Name
- end
- a=a+1
- s=s+1
- end
- return bigList
- end
- function clickIcon(list, x, y, button, directory)
- if button == 1 then
- for i=1, #list do
- if x == list[i].x or x == list[i].x - 1 then
- if y == list[i].y or y == list[i].y - 1 then
- if fs.isDir(list[i].Name) then
- Update(list[i].Name)
- else
- print(list[i].Name)
- shell.run(directory.."/"..Exlist[i].Name)
- end
- end
- end
- end
- elseif button == 2 then
- for i=1, #list do
- if x == list[i].x or x == list[i].x + 1 then
- if y == list[i].y or y == list[i].y - 1 then
- end
- end
- end
- end
- end
- function Update(Name)
- local XYList = {}
- bufferBackground()
- XYList = drawFileList(3, Name)
- while true do
- event, button, xPos, yPos = os.pullEvent("mouse_click")
- clickIcon(XYList, xPos, yPos, button, Name)
- end
- end
- Update("")
Advertisement
Add Comment
Please, Sign In to add comment