Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local isTurtle = os.version():match("TurtleOS") ~= nil
- local isAdvanced = term.isColor()
- local flags = tArgs[1]
- local availableFlags = "OTot"
- local startupFile
- local tabSpan
- local str
- local function printProgress(message, color)
- if isAdvanced then
- term.setTextColor(color)
- end
- print(message)
- if isAdvanced then
- term.setTextColor(colors.white)
- end
- end
- local function isFlagSet(flag)
- return flags:match(flag) ~= nil
- end
- if not flags then
- flags = isTurtle and "-t" or "-T"
- end
- if flags == "help" then
- printProgress("Usage: install [-{flags}]", colors.white)
- printProgress("Available flags: "..availableFlags)
- end
- if flags and string.sub(flags, 1, 1) ~= "-" then
- printProgress("Invalid flags", colors.red)
- printProgress("Usage: install [-{flags}]", colors.white)
- printProgress("Available flags: "..availableFlags)
- end
- printProgress("Cakejoke Edition is being installed over "..(isTurtle and
- "TurtleOS" or "CraftOS"), colors.yellow)
- if fs.exists("cos-cje") and fs.isDir("cos-cje") then
- printProgress("System files already there, overriding", colors.blue)
- fs.delete("/cos-cje")
- elseif fs.exists("/cos-cje") and not fs.isDir("/cos-cje") then
- if isFlagSet("O") then
- printProgress("/cos-cje exists, canceling")
- return
- end
- if not isFlagSet("o") then
- printProgress("File exists: /cos-cje; override or cancel? {o|c}", colors.red)
- local input = read()
- if input == "o" then
- fs.delete("/cos-cje")
- elseif input == "c" then
- return
- else
- printProgress("Invalid input, 'o' or 'c'", colors.red)
- end
- end
- end
- printProgress("Copying Files", colors.blue)
- fs.copy("/disk/cos-cje", "/cos-cje")
- printProgress("Done", colors.lime)
- printProgress("Setting up startup file", colors.blue)
- if fs.exists("/startup") then
- if isFlagSet("O") then
- printProgress("startup exists, canceling")
- return
- end
- if not isFlagSet("o") then
- printProgress("startup exists, override or cancel? {o|c}", colors.orange)
- local input
- while true do
- input = read()
- if input == "o" then
- break
- elseif input == "c" then
- return
- else
- printProgress("Invalid input, 'o' or 'c'", colors.red)
- end
- end
- end
- end
- fs.delete("/startup")
- fs.move("/cos-cje/startup.lua", "/startup")
- printProgress("Done", colors.lime)
- printProgress("Renaming APIs and programs", colors.blue)
- fs.move("/cos-cje/apis/common/iox.lua", "/cos-cje/apis/common/iox")
- fs.move("/cos-cje/apis/common/fsx.lua", "/cos-cje/apis/common/fsx")
- fs.move("/cos-cje/apis/common/property.lua", "/cos-cje/apis/common/property")
- fs.move("/cos-cje/programs/common/cjedisk.lua", "/cos-cje/programs/common/cjedisk")
- if isFlagSet("T") then
- printProgress("Deleting navigate API and turtle programs", colors.blue)
- fs.delete("/cos-cje/apis/turtle/navigate.lua")
- fs.delete("/cos-cje/programs/turtle/go.lua")
- fs.delete("/cos-cje/programs/turtle/turn.lua")
- fs.delete("/cos-cje/programs/turtle/writepos.lua")
- else
- fs.move("/cos-cje/apis/turtle/navigate.lua", "/cos-cje/apis/turtle/navigate")
- fs.move("/cos-cje/programs/turtle/go.lua", "/cos-cje/programs/turtle/go")
- fs.move("/cos-cje/programs/turtle/turn.lua", "/cos-cje/programs/turtle/turn")
- fs.move("/cos-cje/programs/turtle/writepos.lua", "/cos-cje/programs/turtle/writepos")
- end
- printProgress("Done", colors.lime)
- printProgress("Creating filelinks", colors.blue)
- os.loadAPI("/cos-cje/apis/common/iox")
- os.loadAPI("/cos-cje/apis/common/fsx")
- if isFlagSet("t") then
- fsx.createLink("/cos-cje/programs/turtle/go")
- fsx.createLink("/cos-cje/programs/turtle/turn")
- end
- printProgress("Done", colors.lime)
- printProgress("Cakejoke Edition installation completed", colors.yellow)
Advertisement
Add Comment
Please, Sign In to add comment