Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local running = true
- local function exit ()
- running = false
- end
- local function clear ()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local func = {
- [1] = {"Wipe computer",
- function ()
- print("\nAre you sure? There is no way back! [y/N]\n")
- if ({os.pullEvent("key")})[2] == keys.y then
- clear()
- print("Deleting files:\n")
- for i, file in ipairs(fs.list("/")) do
- if not fs.isReadOnly(file) then
- print("Deleting '" .. file .. "'")
- pcall(function () fs.delete(file) end)
- if fs.exists(file) then
- print("Couldn't delete '" .. file .. "'")
- end
- end
- end
- print("\nDone!\nEject disk and shutdown? [y/N]\n")
- if ({os.pullEvent("key")})[2] == keys.y then
- for i, name in ipairs(peripheral.getNames()) do
- if disk.isPresent(name) then
- disk.eject(name)
- end
- end
- os.shutdown()
- end
- clear()
- end
- end},
- [2] = {"File list",
- function ()
- clear()
- shell.run("list")
- print("\nPress any key to go back")
- os.pullEvent("key")
- end},
- [3] = {"Shell",
- function ()
- exit()
- clear()
- end},
- [4] = {"Lua prompt",
- function ()
- clear()
- shell.run("rom/programs/lua")
- end},
- [5] = {"Reboot",
- os.reboot},
- [6] = {"Shutdown",
- os.shutdown},
- [7] = {"Eject disk and shutdown",
- function ()
- for i, name in ipairs(peripheral.getNames()) do
- if disk.isPresent(name) then
- disk.eject(name)
- end
- end
- os.shutdown()
- end},
- [keys.getName(keys.s)] = os.shutdown,
- [keys.getName(keys.r)] = os.reboot,
- }
- while running do
- clear()
- print("Computer manager by MKlegoman357\n")
- for i, t in ipairs(func) do
- print(i .. ". " .. t[1])
- end
- local e, b = os.pullEvent()
- if e == "char" then
- if func[tonumber(b)] then
- func[tonumber(b)][2]()
- end
- elseif e == "key" then
- b = keys.getName(b)
- if func[b] and type(func[b]) == "function" then
- func[b]()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment