startup.lua

108 lines · 2.9 KB

Open raw

Turtle Manager Startup Script

Copy & run

wget https://perlytiara.github.io/turtles.tips/raw/programs/perlytiara/turtle-manager/startup.lua
1-- Turtle Manager Startup Script
2-- This runs automatically when the turtle starts up
3-- It provides quick access to turtle management tools
4
5local function printStartupBanner()
6 term.clear()
7 term.setCursorPos(1, 1)
8 print("========================================")
9 print(" TURTLE STARTUP MANAGER")
10 print("========================================")
11 print()
12
13 local label = os.getComputerLabel() or "Unlabeled"
14 local id = os.getComputerID()
15
16 print("Turtle: " .. label .. " (ID: " .. id .. ")")
17 print("Status: Ready for VS Code connection")
18 print()
19end
20
21local function showQuickMenu()
22 print("Quick Actions:")
23 print("1. Connect to VS Code")
24 print("2. File Sync Utility")
25 print("3. Program Deployer")
26 print("4. Run existing program")
27 print("5. Exit to shell")
28 print()
29end
30
31local function runExistingProgram()
32 print("Available Programs:")
33 print("==================")
34
35 local programs = {}
36
37 -- Check programs directory
38 if fs.exists("programs") then
39 for _, file in ipairs(fs.list("programs")) do
40 if not fs.isDir("programs/" .. file) and file:sub(-4) == ".lua" then
41 table.insert(programs, "programs/" .. file)
42 end
43 end
44 end
45
46 -- Check root directory for .lua files
47 for _, file in ipairs(fs.list("")) do
48 if not fs.isDir(file) and file:sub(-4) == ".lua" and file ~= "startup" then
49 table.insert(programs, file)
50 end
51 end
52
53 if #programs == 0 then
54 print("No programs found.")
55 return
56 end
57
58 for i, program in ipairs(programs) do
59 print(i .. ". " .. program)
60 end
61
62 print()
63 write("Select program to run (1-" .. #programs .. "): ")
64 local choice = tonumber(read())
65
66 if choice and choice >= 1 and choice <= #programs then
67 local selected = programs[choice]
68 print("Running: " .. selected)
69 print("===================")
70 shell.run(selected)
71 else
72 print("Invalid selection!")
73 end
74end
75
76local function main()
77 printStartupBanner()
78
79 while true do
80 showQuickMenu()
81 write("Select option (1-5): ")
82 local choice = read()
83
84 if choice == "1" then
85 shell.run("turtle-manager/turtle-connector")
86 elseif choice == "2" then
87 shell.run("turtle-manager/file-sync")
88 elseif choice == "3" then
89 shell.run("turtle-manager/program-deployer")
90 elseif choice == "4" then
91 runExistingProgram()
92 elseif choice == "5" then
93 print("Exiting to shell...")
94 break
95 else
96 print("Invalid option. Please try again.")
97 end
98
99 print()
100 print("Press any key to continue...")
101 os.pullEvent("key")
102 printStartupBanner()
103 end
104end
105
106-- Run the startup manager
107main()
108