Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ DHD/Gate Installer ]]--
- --[[ version 1.1.00 ]]--
- --[[ by HydrantHunter ]]--
- --[[ aka Dog ]]--
- --[[ pastebin A6uxKyCy ]]--
- local iVer = "1.1"
- --[[
- Tested with/Requires:
- - Minecraft 1.6.4
- - HTTP API enabled (for this installer only)
- - LanteaCraft (snapshot 82+ and RC1_15+)
- - ComputerCraft 1.57+ for MC 1.6.4
- - ccDHD: Advanced Computer (color, mouse), 4 optional Advanced Monitors (color, touch), optional Biolock
- - gateLiaison: Advanced Computer (color, mouse), 3 optional Advanced Monitors (color)
- ]]--
- local startup = 0
- local function downloadFile(fileToken, fileName)
- local fileURL = http.get("http://pastebin.com/raw.php?i=" .. textutils.urlEncode(fileToken))
- if fileURL then
- local fileContents = fileURL.readAll()
- fileURL.close()
- local newFile = fs.open(fileName, "w")
- newFile.write(fileContents)
- newFile.close()
- end
- end
- local function drawHeader()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(2,1)
- term.write(string.rep(" ",19))
- term.setCursorPos(2,2)
- term.write(" DHD Installer " .. iVer .. " ")
- term.setCursorPos(2,3)
- term.write(string.rep(" ",19))
- end
- local function drawCLI()
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,6)
- if startup == 1 or startup == 2 then
- term.setTextColor(colors.lime)
- term.write(" [ ] ")
- term.setCursorPos(4,6)
- term.setTextColor(colors.lightGray)
- term.write("ccDHD Installed")
- else
- term.setTextColor(colors.white)
- term.write(" [ Install ccDHD ] ")
- end
- term.setCursorPos(1,8)
- if startup == 3 or startup == 4 then
- term.setTextColor(colors.lime)
- term.write(" [ ] ")
- term.setCursorPos(4,8)
- term.setTextColor(colors.lightGray)
- term.write("Gate Installed")
- else
- term.setTextColor(colors.white)
- term.write(" [ Install Gate ] ")
- end
- term.setTextColor(colors.orange)
- term.setCursorPos(1,10)
- term.write(" [ ] ")
- term.setTextColor(colors.white)
- term.setCursorPos(9,10)
- term.write("Reboot")
- term.setTextColor(colors.red)
- term.setCursorPos(1,12)
- term.write(" [ ] ")
- term.setTextColor(colors.white)
- term.setCursorPos(10,12)
- term.write("Quit")
- end
- local function setCCLabel(whichType)
- local currentCCLabel = os.getComputerLabel()
- if tostring(currentCCLabel) == "" or currentCCLabel == nil then
- os.setComputerLabel(whichType)
- end
- end
- local function cleanUp()
- if fs.exists("/logs/DHDlast") then
- fs.move("/logs/DHDlast","/data/DHDlast")
- end
- if fs.exists("/logs/DHDhistory") then
- fs.move("/logs/DHDhistory","/data/DHDhistory")
- end
- if fs.exists("/logs") then fs.delete("/logs") end
- end
- if fs.exists("/data/gateSettings") then startup = 4 end -- gateLiaison installed?
- if fs.exists("/gateLiaison") then startup = 3 end -- gateLiaison installed as gateLiason (otherwise installed as startup)
- if fs.exists("/data/DHDconfig") then startup = 2 end -- ccDHD installed?
- if fs.exists("/DHD") then startup = 1 end -- ccDHD installed as DHD (otherwise installed as startup)
- if startup == 0 then -- neither is installed
- if fs.exists("/startup") then startup = 5 end -- startup exists, install by name (otherwise install as startup)
- end
- drawHeader()
- drawCLI()
- while true do
- userInput = { os.pullEvent("mouse_click") }
- if userInput[3] > 1 and userInput[3] < 21 then
- if userInput[4] == 6 then
- setCCLabel("DHD")
- if fs.exists("/logs") and fs.exists("/data/DHDSettings") then fs.delete("/data/DHDsettings") end
- if fs.exists("/data/DHDSettings") then fs.delete("/data/DHDsettings") end
- if not fs.exists("/data") then
- fs.makeDir("/data")
- end
- cleanUp()
- if startup == 1 or startup == 5 then
- if fs.exists("/DHD") then fs.delete("/DHD") end
- downloadFile("vMtcSz2e","/DHD")
- startup = 1
- elseif startup == 0 or startup == 2 then
- if fs.exists("/startup") then fs.delete("/startup") end
- downloadFile("vMtcSz2e","/startup")
- startup = 2
- end
- drawCLI()
- elseif userInput[4] == 8 then
- setCCLabel("Gate")
- if fs.exists("/logs") and fs.exists("/data/gateSettings") then fs.delete("/data/gateSettings") end
- if not fs.exists("/data") then
- fs.makeDir("/data")
- end
- cleanUp()
- if startup == 3 or startup == 5 then
- if fs.exists("/gateLiaison") then fs.delete("/gateLiaison") end
- downloadFile("xSHHqL0h","/gateLiaison")
- startup = 3
- elseif startup == 0 or startup == 4 then
- if fs.exists("/startup") then fs.delete("/startup") end
- downloadFile("xSHHqL0h","/startup")
- startup = 4
- end
- drawCLI()
- elseif userInput[4] == 10 then
- os.reboot()
- elseif userInput[4] == 12 then
- term.clear()
- term.setCursorPos(1,1)
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement