Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("SkyOS_set") then
- oTemp = fs.open("SkyOS_set", "w")
- oTemp.writeLine("startup = false")
- oTemp.writeLine("backgroundColor = 4")
- oTemp.writeLine("textColor = 1")
- oTemp.writeLine("backgroundColorSet = 12")
- oTemp.writeLine("textColorSet = 1")
- oTemp.close()
- end
- if not fs.exists("lick") then
- oTemp = fs.open("lick", "w")
- oTemp.writeLine("term.setBackgroundColor(colors.magenta)")
- oTemp.writeLine("term.setTextColor(colors.white)")
- oTemp.writeLine("print(\"slurp\")")
- oTemp.close()
- end
- local uInputPrev = {}
- local iColors = {}
- for i = 0, 15 do
- iColors[i + 1] = 2 ^ i
- end
- function clear(keepvars)
- os.loadAPI("SkyOS_set")
- if SkyOS_set.backimg then
- paintutils.drawImage(backimg[1], backimg[2], backimg[3]) -------background images(currently unsupported)
- end
- term.setCursorBlink(true)
- termW, termH = term.getSize()
- term.setBackgroundColor(iColors[SkyOS_set.backgroundColor])
- term.clear()
- words("Settings", termW - 7, 1, iColors[SkyOS_set.textColorSet], iColors[SkyOS_set.backgroundColorSet])
- words("SkyOS V0.7", 1, 1, iColors[SkyOS_set.textColor], iColors[SkyOS_set.backgroundColor])
- words(">", 1, 2)
- uInput = ""
- uInputNum = 0
- --uInputPrev = {}
- os.startTimer(.05)
- end
- function newline()
- words(">", _, _, iColors[SkyOS_set.textColor], iColors[SkyOS_set.backgroundColor])
- uInput = ""
- end
- function words(string, x, y, txtcol, bakcol)
- if x and y then
- term.setCursorPos(x, y)
- end
- if txtcol then
- term.setTextColor(txtcol)
- end
- if bakcol then
- term.setBackgroundColor(bakcol)
- end
- write(string)
- end
- function delete()
- uInput = string.sub(uInput, 1, #uInput - 1)
- if currentX <= 1 then
- words(" ", termW, currentY - 1)
- term.setCursorPos(termW, currentY - 1)
- currentY = currentY - 1
- currentX = termW
- else
- words(" ", currentX - 1, currentY)
- term.setCursorPos(currentX - 1, currentY)
- currentX = currentX - 1
- end
- end
- function tick()
- currentX, currentY = term.getCursorPos()
- words("Settings", termW - 7, 1, iColors[SkyOS_set.textColorSet], iColors[SkyOS_set.backgroundColorSet])
- term.setCursorPos(currentX, currentY)
- if currentX == termW + 1 then
- term.setCursorPos(1, currentY + 1)
- end
- if currentY == termH + 1 then
- term.scroll(1)
- end
- term.setBackgroundColor(iColors[SkyOS_set.backgroundColor])
- term.setTextColor(iColors[SkyOS_set.textColor])
- os.startTimer(.05)
- end
- function clickCheck(x, y, x2, y2, type)
- if type then
- if type == "left" then
- type = 1
- elseif type == "right" then
- type = 2
- end
- if events[2] == type and events[3] >= x and events[3] <= x2 and events[4] >= y and events[4] <= y2 then
- return true
- else
- return false
- end
- else
- if events[3] >= x and events[3] <= x2 and events[4] >= y and events[4] <= y2 then
- return true
- else
- return false
- end
- end
- end
- function enter()
- words("\n")
- if uInput ~= "" then
- table.insert(uInputPrev, 1, uInput)
- end
- if uInput == "exitOS()" then
- shell.exit()
- end
- if SkyOS_set.backgroundColor ~= 15 then
- term.setBackgroundColor(iColors[SkyOS_set.backgroundColor])
- else
- term.setBackgroundColor(colors.black)
- end
- runAttempt = shell.run(uInput)
- term.setBackgroundColor(iColors[SkyOS_set.backgroundColor])
- if string.sub(uInput, 1, 4) == "edit" then
- clear()
- else
- newline()
- end
- uInput = ""
- uInputNum = 0
- end
- function colorbar(y, var1, var2)
- for i = 1, 16 do
- term.setCursorPos(i, y)
- term.setBackgroundColor(iColors[i])
- if i == 1 then
- term.setTextColor(colors.black)
- else
- term.setTextColor(colors.white)
- end
- if var1 == i then
- term.write("O")
- elseif var2 == i then
- term.write(".")
- else
- term.write(" ")
- end
- end
- end
- function changeVars(changeBK, changeTC, changeST)
- shell.run("copy SkyOS_set temp")
- oTemp = fs.open("SkyOS_set", "w")
- for line in io.lines("temp") do
- if changeBK == "sky" and string.sub(line, 0, 16) == "backgroundColor " then
- oTemp.writeLine("backgroundColor = " .. events[3])
- elseif changeBK == "set" and string.sub(line, 0, 18) == "backgroundColorSet" then
- oTemp.writeLine("backgroundColorSet = " .. events[3])
- elseif changeTC == "sky" and string.sub(line, 0, 10) == "textColor " then
- oTemp.writeLine("textColor = " .. events[3])
- elseif changeTC == "set" and string.sub(line, 0, 12) == "textColorSet" then
- oTemp.writeLine("textColorSet = " .. events[3])
- elseif changeST and string.sub(line, 0, 7) == "startup" then
- oTempStartup = fs.open("startup", "w")
- if changeST == 1 then
- oTemp.writeLine("startup = true")
- oTempStartup.writeLine("shell.run(\"SkyOS\")")
- elseif changeST == 0 then
- oTemp.writeLine("startup = false")
- end
- oTempStartup.flush()
- oTempStartup.close()
- else
- oTemp.writeLine(line)
- end
- end
- oTemp.flush()
- oTemp.close()
- shell.run("delete temp")
- end
- function settings()
- term.setCursorBlink(false)
- term.setBackgroundColor(iColors[SkyOS_set.backgroundColorSet])
- term.clear()
- words("Settings", termW/2 - 3, 1, iColors[SkyOS_set.textColorSet], iColors[SkyOS_set.backgroundColorSet])
- words("Run SkyOS on Startup", 1, 3)
- words("SkyOS Colors", 1, 6)
- words("Settings Tab Colors", 1, 9)
- words("L Click = Background", 1, termH - 1)
- words("R Click = Text", 1, termH)
- words("Back", termW - 3, termH)
- while not donesettings do
- os.loadAPI("SkyOS_set")
- if SkyOS_set.startup == true then
- words(" No", 1, 4, iColors[SkyOS_set.textColorSet], iColors[SkyOS_set.backgroundColorSet])
- words("Yes", 1, 4, colors.yellow, colors.lightBlue)
- oTemp = fs.open("startup", "w")
- oTemp.writeLine("shell.run(\"" .. shell.getRunningProgram() .. "\")")
- oTemp.close()
- elseif SkyOS_set.startup == false then
- words(" No", 1, 4, colors.yellow, colors.lightBlue)
- words("Yes ", 1, 4, iColors[SkyOS_set.textColorSet], iColors[SkyOS_set.backgroundColorSet])
- if fs.exists("startup") then
- shell.run("delete startup")
- end
- end
- colorbar(7, SkyOS_set.backgroundColor, SkyOS_set.textColor)
- colorbar(10, SkyOS_set.backgroundColorSet, SkyOS_set.textColorSet)
- events = {os.pullEventRaw()}
- if events[1] == "mouse_click" then
- if clickCheck(1, 4, 3, 4, "left") and SkyOS_set.startup ~= true then
- changeVars(_, _, 1)
- elseif clickCheck(6, 4, 7, 4, "left") and SkyOS_set.startup ~= false then
- changeVars(_, _, 0)
- end
- if clickCheck(1, 7, 16, 7) then
- if events[2] == 1 and events[3] ~= SkyOS_set.textColor then
- changeVars("sky")
- elseif events[2] == 2 and events[3] ~= SkyOS_set.backgroundColor then
- changeVars(_, "sky")
- end
- end
- if clickCheck(1, 10, 16, 10) then
- if events[2] == 1 and events[3] ~= SkyOS_set.textColorSet then
- changeVars("set")
- elseif events[2] == 2 and events[3] ~= SkyOS_set.backgroundColorSet then
- changeVars(_, "set")
- end
- end
- if clickCheck(termW - 3, termH, termW, termH, "left") then
- words("Back", termW - 3, termH, _, colors.red)
- sleep(.2)
- donesettings = true
- end
- end
- end
- clear()
- end
- clear()
- while true do
- events = {}
- events = {os.pullEventRaw()}
- if events[1] == "timer" then
- tick()
- end
- if events[1] == "paste" then
- term.write(events[2])
- uInput = uInput .. events[2]
- elseif events[1] == "char" then
- term.write(events[2])
- uInput = uInput .. events[2]
- elseif events[1] == "key" then
- if events[2] == 14 and #uInput > 0 then
- delete()
- elseif events[2] == 28 then
- enter()
- elseif events[2] == 200 and uInputPrev then
- if #uInputPrev > uInputNum then
- for i = 1, #uInput do
- delete()
- end
- uInputNum = uInputNum + 1
- uInput = uInputPrev[uInputNum]
- words(uInput)
- end
- elseif events[2] == 208 then
- for i = 1, #uInput do
- delete()
- end
- if uInputNum > 1 then
- uInputNum = uInputNum - 1
- uInput = uInputPrev[uInputNum]
- else
- uInputNum = 0
- uInput = ""
- end
- words(uInput)
- end
- end
- if events[1] == "mouse_click" then
- if clickCheck(termW - 7, 1, termW, 1, "left") then
- words("Settings", termW - 7, 1, colors.white, colors.orange)
- sleep(.2)
- donesettings = false
- settings()
- end
- end
- if events[1] == "terminate" then
- words("\nTerminated", _, _, colors.red)
- words("\nRebooting", _, _, colors.yellow)
- shell.run("reboot")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement