Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local buttons = {
- { name = "Command", x = 2, y = 3, width = 15, height = 1, color = colors.gray, command = "/disk/os/home.lua" },
- { name = "Programs", x = 2, y = 5, width = 15, height = 1, color = colors.gray, command = "/disk/os/programs" },
- { name = "All Programs", x = 2, y = 9, width = 15, height = 1, color = colors.gray, command = "showAllPrograms" },
- { name = "Power Menu", x = 2, y = 11, width = 15, height = 1, color = colors.gray, command = "showPowerMenu" }
- }
- local function drawAllPrograms()
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- term.write("All Programs:")
- local programPath = "/disk/packages/"
- local programs = fs.list(programPath)
- local y = 3
- for _, program in ipairs(programs) do
- term.setCursorPos(2, y)
- term.clearLine()
- term.write(" " .. program .. " ")
- y = y + 1
- end
- end
- -- ... (rest of the code remains unchanged)
- local function handleButtonClick(command)
- if command == "showAllPrograms" then
- drawAllPrograms()
- os.pullEvent("key") -- Wait for a key press to return to the homescreen
- else
- launchApp(command)
- end
- end
- -- ... (rest of the code remains unchanged)
- local function homescreen()
- while true do
- drawHomescreen()
- local event, _, x, y = os.pullEvent("mouse_click")
- if event == "mouse_click" then
- local appCommand = handleAppClick(x, y)
- if appCommand then
- handleButtonClick(appCommand)
- return -- Terminate the program after launching the app or showing power menu
- end
- end
- end
- end
- homescreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement