Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function box(startx, endx, starty, endy, col, _fillChar)
- local curry = starty
- term.setBackgroundColor(col)
- for u = starty, endy do
- term.setCursorPos(startx, curry)
- for i = 1, endx do
- term.write(" ")
- end
- curry = curry + 1
- end
- end
- local function progress(startX, startY, endX, bgcol, loadcol, progressmessage, percent)
- term.setCursorPos(startX, startY)
- term.setBackgroundColor(bgcol)
- for i = startX, endX do
- term.write(" ")
- end
- term.setCursorPos(startX, startY+1)
- term.setBackgroundColor(colors.green)
- term.write(" ")
- term.setCursorPos(startX, startY+1)
- term.write(progressmessage)
- term.setCursorPos(startX, startY)
- term.setBackgroundColor(loadcol)
- for i = 0, math.floor(percent), 10 do
- term.write(" ")
- end
- end
- local progresses = {
- [30] = "Creating Folders",
- [60] = "Creating Files",
- [90] = "Writing Files",
- [100] = "Done"
- }
- local buttons = {
- [1] = {7, 17, 19, 19, "BACK"},
- [2] = {35, 45, 19, 19, "INSTALL"}
- }
- local files = {
- ".D-Burn_Images/button.nfp",
- ".D-Burn_Images/rsod.nfp",
- ".D-Burn_Images/homeScreen.nfp",
- "D-Burn"
- }
- local folder = {".D-Burn_Images"}
- local fileContent = {
- [".D-Burn_Images/button.nfp"] = [[ddddddddddddd
- ddddddddddddd
- ddddddddddddd
- ]],
- [".D-Burn_Images/rsod.nfp"] = [[eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeeeeeee e ee e ee eeeeeeeeeeeeeeee
- eeeeeeeeeeeeeeeeee eeeeeeeeeeeeee
- eeeeeeeeeeeeeeee eeeeee
- ee eee e eeee
- ]],
- [".D-Burn_Images/homeScreen.nfp"] = [[888888888888888888888888888888888888888888888888888
- 8888888ffffff8888888ffff888888888888888888888888888
- 888888ff0000ff888888f888f8f888f8f8ff88ff88f88888888
- 888888ff0ff0ff8ffff8fffff8f888f8ff88f8fff8f88888888
- 888888ff0000ff888888f888f8f888f8f88888f8fff88888888
- 8888888ffffff8888888ffff888fff88f88888f88ff88888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888
- 8888888888888888888888888888888888888888888888888888
- 88888888888888888888888888888888888888888888888888888
- 888888888888888888888888888888888888888888888888888888
- 88888888888888888888888888888888888888888888888888888
- 8888888888888888888888888888888888888888888888888888
- 88888888888 8 88 88888 88888
- 888
- 8
- ]],
- ["D-Burn"] = [[oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- local programData = {
- Author = "Freack100",
- ProgramName = "D-Burn",
- Version = "0.1",
- path = shell.resolve("/")
- }
- local neededInformation = {
- noEditFilename = ".No_Files"
- }
- local images = {
- homeScreen = paintutils.loadImage(".D-Burn_Images/homeScreen.nfp"),
- button = paintutils.loadImage(".D-Burn_Images/button.nfp"),
- rsod = paintutils.loadImage(".D-Burn_Images/rsod.nfp")
- }
- term.setCursorBlink(false)
- local crashed = false
- local function printMenu(startX, startY, txtcol, options)
- local startX = startX
- local currY = startY
- local buttonPositions = {}
- for i = 1, #options do
- paintutils.drawImage(images.button, startX, currY)
- if string.len(options[i]) > 13 then
- error("Can't print out more than 13 characters!")
- end
- term.setCursorPos(((startX + 31)-string.len(options[i]))/2, currY+1)
- term.setTextColor(txtcol)
- term.write(options[i])
- table.insert(buttonPositions, {options[i], startX, startX+13, currY, currY+3})
- currY = currY + 4
- end
- while true do
- local sEvent, sButton, sX, sY = os.pullEvent()
- if sEvent == "mouse_click" and sButton == 1 then
- for i = 1, #buttonPositions do
- if sX >= buttonPositions[i][2] and sX <= buttonPositions[i][3] and sY >= buttonPositions[i][4] and sY <= buttonPositions[i][5] then
- return buttonPositions[i][1]
- end
- end
- end
- end
- end
- local function RSoD(message)
- local x,y = term.getSize()
- paintutils.drawImage(images.rsod, 1, 1)
- term.setCursorPos(19,2)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write("Oh no! A RSoD!")
- term.setCursorPos((x-string.len(message))/2,6)
- term.write(message)
- term.setCursorPos(14, 10)
- term.write("Press any Key to exit...")
- local clicked = false
- while not clicked do
- local sEvent = os.pullEvent()
- if sEvent == "key" then
- clicked = true
- end
- end
- crashed = true
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- local function success(Message, yOffset)
- local x,y = term.getSize()
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.lime)
- term.clear()
- term.setCursorPos((x-string.len(Message)-1)/2, yOffset)
- for i = 1, #Message do
- term.write(string.sub(Message, i,i))
- sleep(0.025)
- end
- sleep(1)
- end
- local function keyMenu(sX, sY, bgcol, txtcol, markcol, options)
- local sX = sX
- local currY = sY
- local options = options
- options[#options+1] = "Back"
- local selected = 1
- term.setBackgroundColor(bgcol)
- term.clear()
- term.setCursorPos(sX,currY)
- term.setTextColor(markcol)
- local function redraw()
- term.clear()
- for k,v in ipairs(options) do
- term.setCursorPos(sX, currY)
- if k == selected then
- term.setTextColor(markcol)
- term.write("[")
- term.setTextColor(txtcol)
- term.write(options[k])
- term.setTextColor(markcol)
- term.write("]")
- else
- term.setTextColor(txtcol)
- term.write(options[k])
- end
- currY = currY+1
- end
- currY = sY
- end
- redraw()
- while true do
- local sEvent, sKey = os.pullEvent()
- if sEvent == "key" then
- if sKey == keys.up then
- if selected > 1 then
- selected = selected - 1
- else
- selected = #options
- end
- redraw()
- elseif sKey == keys.down then
- if selected < #options then
- selected = selected + 1
- else
- selected = 1
- end
- redraw()
- elseif sKey == keys.enter then
- return options[selected]
- end
- end
- sleep(0)
- end
- end
- while true do
- paintutils.drawImage(images.homeScreen,1,1)
- local mainMenu = printMenu(18,8,colors.lime, {"Burn", "Clear", "Exit"})
- if mainMenu == "Exit" then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.yellow)
- term.setCursorPos(13, 2)
- term.write("Thx for using " .. programData.ProgramName .. " " .. programData.Version)
- term.setCursorPos(16, 4)
- term.write("Made by " .. programData.Author)
- term.setCursorPos(1, 6)
- term.setTextColor(colors.white)
- return
- elseif mainMenu == "Burn" then
- local burnMenu = printMenu(18,8,colors.lime, {"Non Edit Burn", "Edit Burn", "Exit"})
- if burnMenu == "Exit" then
- elseif burnMenu == "Non Edit Burn" then
- local drivers = {}
- for k,v in pairs(rs.getSides()) do
- if peripheral.isPresent(v) and peripheral.getType(v) == "drive" then
- table.insert(drivers, v)
- end
- end
- if drivers[1] == nil then
- RSoD(" Oh no! There is no driver attached to the Computer!")
- end
- if disk.isPresent(drivers[1]) ~= true then
- RSoD("Oh no! There is no floppy in your driver!")
- end
- local burnDriver = peripheral.wrap(drivers[1])
- if fs.exists(burnDriver.getMountPath() .. "/.No_Files") then
- RSoD("You cant Burn a season closed disk")
- end
- if crashed then
- break
- end
- local fileList = fs.list("/")
- for k,v in pairs(fileList) do
- if v == ("rom" or burnDriver.getMountPath()) then
- table.remove(fileList, k)
- end
- end
- fileList[#fileList+1] = "Whole computer"
- local fileMenu = keyMenu(20, 2, colors.lightGray, colors.gray, colors.lime, fileList)
- local uneditable = fs.open(burnDriver.getMountPath() .. "/" .. neededInformation.noEditFilename, "w")
- uneditable.close()
- if fileMenu == "Back" then
- elseif fileMenu == "Whole computer" then
- local function wholeCopy()
- for k,v in pairs(fileList) do
- fs.copy("/" .. v, burnDriver.getMountPath() .. "/" .. v)
- end
- success("successfuly burned " .. #fileList-1 .. " files onto the disk", 4)
- end
- local _,err = pcall(wholeCopy)
- elseif type(fileMenu) == "directory" then
- fs.makeDir(burnDriver.getMountPath() .. "/" .. fileMenu)
- for k,v in pairs(fs.list(fileMenu)) do
- fs.copy(fileMenu .. "/" .. v, burnDriver.getMountPath .. "/" .. fileMenu .. "/" .. v)
- end
- else
- fs.copy(fileMenu, burnDriver.getMountPath() .. "/" .. fileMenu)
- end
- elseif burnMenu == "Edit Burn" then
- local drivers = {}
- for k,v in pairs(rs.getSides()) do
- if peripheral.isPresent(v) and peripheral.getType(v) == "drive" then
- table.insert(drivers, v)
- end
- end
- if drivers[1] == nil then
- RSoD(" Oh no! There is no driver attached to the Computer!")
- end
- if disk.isPresent(drivers[1]) ~= true then
- RSoD("Oh no! There is no floppy in your driver!")
- end
- local burnDriver = peripheral.wrap(drivers[1])
- if fs.exists(burnDriver.getMountPath() .. "/.No_Files") then
- RSoD("You cant Burn a season closed disk")
- end
- if crashed then
- break
- end
- local fileList = fs.list("/")
- for k,v in pairs(fileList) do
- if v == ("rom" or burnDriver.getMountPath()) then
- table.remove(fileList, k)
- end
- end
- fileList[#fileList+1] = "Whole computer"
- local fileMenu = keyMenu(20, 2, colors.lightGray, colors.gray, colors.lime, fileList)
- if fileMenu == "Back" then
- elseif fileMenu == "Whole computer" then
- local function wholeCopy()
- for k,v in pairs(fileList) do
- fs.copy("/" .. v, burnDriver.getMountPath() .. "/" .. v)
- end
- end
- local _,err = pcall(wholeCopy)
- success("successfuly burned " .. #fileList-1 .. " files onto the disk", 4)
- elseif type(fileMenu) == "directory" then
- fs.makeDir(burnDriver.getMountPath() .. "/" .. fileMenu)
- for k,v in pairs(fs.list(fileMenu)) do
- fs.copy(fileMenu .. "/" .. v, burnDriver.getMountPath .. "/" .. fileMenu .. "/" .. v)
- end
- else
- fs.copy(fileMenu, burnDriver.getMountPath() .. "/" .. fileMenu)
- end
- end
- elseif mainMenu == "Clear" then
- local clearMenu = printMenu(18, 8, colors.lime, {"Delete File", "Delete Disk", "Back"})
- if clearMenu == "Back" then
- elseif clearMenu == "Delete Disk" then
- local drivers = {}
- for k,v in pairs(rs.getSides()) do
- if peripheral.isPresent(v) and peripheral.getType(v) == "drive" then
- table.insert(drivers, v)
- end
- end
- if drivers[1] == nil then
- RSoD(" Oh no! There is no driver attached to the Computer!")
- end
- if disk.isPresent(drivers[1]) ~= true then
- RSoD("Oh no! There is no floppy in your driver!")
- end
- local burnDriver = peripheral.wrap(drivers[1])
- if fs.exists(burnDriver.getMountPath() .. "/.No_Files") then
- RSoD("You cant delete a season closed disk")
- end
- if crashed then
- break
- end
- local fileList = fs.list(burnDriver.getMountPath() .."/")
- for k,v in pairs(fileList) do
- fs.delete(burnDriver.getMountPath() .. "/" .. v)
- end
- success("Successfuly cleared the floppy. Total Files:"..#fileList-1, 4)
- elseif clearMenu == "Delete File" then
- local drivers = {}
- for k,v in pairs(rs.getSides()) do
- if peripheral.isPresent(v) and peripheral.getType(v) == "drive" then
- table.insert(drivers, v)
- end
- end
- if drivers[1] == nil then
- RSoD(" Oh no! There is no driver attached to the Computer!")
- end
- if disk.isPresent(drivers[1]) ~= true then
- RSoD("Oh no! There is no floppy in your driver!")
- end
- local burnDriver = peripheral.wrap(drivers[1])
- if fs.exists(burnDriver.getMountPath() .. "/.No_Files") then
- RSoD("You cant delete a season closed disk")
- end
- if crashed then
- break
- end
- local fileList = fs.list(burnDriver.getMountPath() .."/")
- local deleteList = keyMenu(20,2,colors.lightGray, colors.gray,colors.lime,fileList)
- fs.delete(burnDriver.getMountPath() .. "/" .. deleteList)
- success("Successfuly deleted File: " .. deleteList,4)
- end
- end
- end]]
- }
- term.setCursorBlink(false)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.lime)
- term.clear()
- box(3, 51-4, 2, 19-2, colors.green)
- term.setCursorPos(35, 19)
- term.write(" Install ")
- term.setCursorPos(7, 19)
- term.write(" Back ")
- local function keypress()
- while true do
- local sEvent, nButton, nX, nY = os.pullEvent()
- if sEvent == "mouse_click" then
- for i = 1, #buttons do
- if nX >= buttons[i][1] and nX <= buttons[i][2] and nY == buttons[i][3] then
- return buttons[i][5]
- end
- end
- end
- end
- end
- local clicked = keypress()
- term.setCursorPos(1, 1)
- if clicked == "INSTALL" then
- local function install()
- os.queueEvent("next_progress")
- for i = 1, #folder do
- fs.makeDir(folder[i])
- end
- sleep(.75)
- os.queueEvent("next_progress")
- for i = 1, #files do
- local file = fs.open(files[i], "w")
- file.writeLine(fileContent[files[i]])
- file.close()
- end
- sleep(.75)
- os.queueEvent("next_progress")
- sleep(.75)
- os.queueEvent("next_progress")
- sleep(0.5)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- end
- local function waitForEvent()
- local count = 30
- while count < 100 do
- local sEvent = os.pullEvent()
- if sEvent == "next_progress" then
- progress(15, 10, 25, colors.gray, colors.red, progresses[count], count)
- count = count + 30
- end
- end
- end
- parallel.waitForAll(install, waitForEvent)
- shell.run("D-Burn")
- elseif clicked == "BACK" then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement