Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function filePicker(path)
- local y = 1
- local list = fs.list(path)
- local maxX, maxY = term.getSize()
- term.clear()
- for i = y, y + maxY - 1 do
- if not list[i] then break end
- term.setCursorPos(1, i - y + 1)
- term.write(i .. " : " .. list[i])
- end
- while true do
- local myEvent = {os.pullEvent()}
- if myEvent[1] == "mouse_scroll" then
- if myEvent[2] == 1 and y < #list - maxY + 1 then
- y = y + 1
- elseif myEvent[2] == -1 and y ~= 0 then
- y = y - 1
- end
- term.clear()
- for i = y, y + maxY - 1 do
- if not list[i] then break end
- term.setCursorPos(1, i - y + 1)
- term.write(i .. " : " .. list[i])
- end
- elseif myEvent[1] == "mouse_click" then
- return list[myEvent[4] + y - 1]
- end
- end
- end
- local result = filePicker("Items/")
- shell.run(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement