ComputerCraft Archive

DorOS - A CLI that does things

computer operating-system unknown forum

Description

Function Definitions--

Installation

Copy one of these commands into your ComputerCraft terminal:

Pastebin:pastebin get FBf8HadB doros_-_a_cli_that_does_things
wget:wget https://pastebin.com/raw/FBf8HadB doros_-_a_cli_that_does_things
Archive:wget https://cc.shobie.xyz/cc/get/pb-FBf8HadB doros_-_a_cli_that_does_things
Quick Install: wget https://cc.shobie.xyz/cc/get/pb-FBf8HadB DorOS - A CLI that does things

Usage

Run the program after downloading

Tags

forumoperating-systems

Source

View Original Source

Code Preview

--Function Definitions--
local function CenterText(text, y)
    local x,oy = term.getSize()
    term.setCursorPos(x/2-string.len(text)/2,y)
    write(text)
end

function CUI(m) --declare function
n=1 --declare selected option
while true do --start a loop for the 'go to step#2' part
term.setCursorPos(1,12) --clear the sceen and position the cursor
for i=1, #m, 1 do --traverse the table of options
if i==n then print(" ["..m[i].."]") else print(" ", m[i], " ") end --print them
end
a, b= os.pullEvent("key") --wait for keypress
if b==200 and n>1 then n=n-1 end --arrow up pressed, one option up
if b==208 then n=n+1 end --arrow down pressed, one option down
if b==28 then break end --enter pressed, break the loop
if n==4 then n=3 end
end
term.clear() term.setCursorPos(1,12) --clear screen
return n --return the value
end

local function getPastebin(ID, filename)
    shell.run("pastebin", "get", ID, filename)
end

--Variables--
local installTypes={
"CUI",
"Cancel"
}

--Start of Process--
term.clear()
CenterText("Setup Process Started", 7)
CenterText("Select Installation Type", 9)

local installSelect = CUI(installTypes)
if installSelect == 1 then
	if fs.exists("/System/Config/delete.txt") == true then
    	shell.run("rm", "/System")
    	shell.run("rm", "/startup.lua")
	end
    getPastebin("DbxThsns", "cuiInstall.lua")
    getPastebin("FWHY51af", "startcuiInstall.lua")
    shell.run("cuiInstall.lua")
else
    shell.run("shutdown") 
end