Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- w, h = term.getSize()
- os.loadAPI("iosvars")
- function initialize()
- term.setBackgroundColor(colors.lightGray)
- term.clear()
- iosutils.centerAlign("System Settings", 1, colors.gray, colors.lightGray)
- iosutils.leftAlign("Background Color", 3)
- iosutils.leftAlign("Wi-Fi", 6)
- iosutils.leftAlign("Computer Label", 9)
- iosutils.leftAlign("Run IOS on Startup", 12)
- for i = 1, 16 do
- term.setCursorPos(i, 4)
- term.setBackgroundColor(iosutils.colors[i])
- term.write(" ")
- end
- iosutils.leftAlign(">", 10, colors.gray, colors.lightGray)
- function clickDetect(x, y, x2, y2)
- if select[3] >= x and select[3] <= x2 and select[4] >= y and select[4] <= y2 then
- return true
- else
- return false
- end
- end
- end
- function changeVars(changeBK, changeWF, changeST)
- oTemp = fs.open("temp", "w")
- for line in io.lines("iosvars") do
- --print(string.sub(line, 0, 16))
- --print(string.sub(line, 0, 5))
- if changeBK and string.sub(line, 0, 15) == "backgroundColor" then
- oTemp.writeLine("backgroundColor = iosutils.colors[" .. tostring(select[3]) .. "]")
- elseif changeWF and string.sub(line, 0, 4) == "wifi" then
- if changeWF == 1 then
- oTemp.writeLine("wifi = true")
- else
- oTemp.writeLine("wifi = false")
- end
- elseif changeST and string.sub(line, 0, 7) == "startup" then
- oTempStartup = fs.open("startuptemp", "w")
- if fs.exists("startup") then
- for ln in io.lines("startup") do
- if string.sub(ln, 0, 16) ~= "shell.run(\"ios\")" then
- oTempStartup.writeLine(ln)
- end
- end
- end
- if changeST == 1 then
- oTemp.writeLine("startup = true")
- oTempStartup.writeLine("shell.run(\"ios\")")
- else
- oTemp.writeLine("startup = false")
- end
- oTempStartup.flush()
- oTempStartup.close()
- if fs.exists("startup") then
- shell.run("delete startup")
- end
- shell.run("copy startuptemp startup")
- shell.run("delete startuptemp")
- else
- oTemp.writeLine(line)
- end
- end
- oTemp.flush()
- oTemp.close()
- shell.run("delete iosvars")
- shell.run("copy temp iosvars")
- shell.run("delete temp")
- end
- select = {}
- select[1] = "mouse_click"
- select[2] = 1
- select[3] = 1
- select[4] = 1
- initialize()
- while true do
- --detect clicks and change vars--
- if clickDetect(1, 4, 16, 4) then
- changeVars(true, false, false)
- end
- if clickDetect(1, 7, 2, 7) then
- --open iosvars and write true
- changeVars(false, 1, false)
- end
- if clickDetect(5, 7, 7, 7) then
- changeVars(false, 0, false)
- end
- if clickDetect(1, 10, 10, 10) then
- term.setCursorPos(2, 10)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.gray)
- local label = read()
- --label = string.gsub(label, "\"", "\\\"")
- label = "\"" .. label .. "\""
- shell.run("label set " .. tostring(label))
- initialize()
- end
- if clickDetect(1, 13, 3, 13) then
- changeVars(false, false, 1)
- end
- if clickDetect(6, 13, 7, 13) then
- changeVars(false, false, 0)
- end
- --write page based on vars--
- os.loadAPI("iosvars")
- if iosvars.wifi then
- iosutils.leftAlign(" Off", 7, colors.red, colors.lightGray)
- iosutils.leftAlign("On", 7, colors.green, colors.white)
- rednet.open("back")
- else
- iosutils.leftAlign(" Off", 7, colors.red, colors.white)
- iosutils.leftAlign("On ", 7, colors.green, colors.lightGray)
- rednet.close("back")
- end
- if iosvars.startup then
- iosutils.leftAlign(" No", 13, colors.red, colors.lightGray)
- iosutils.leftAlign("Yes", 13, colors.green, colors.white)
- else
- iosutils.leftAlign(" No", 13, colors.red, colors.white)
- iosutils.leftAlign("Yes ", 13, colors.green, colors.lightGray)
- end
- term.setCursorPos(1, 5)
- term.setBackgroundColor(iosvars.backgroundColor)
- for i = 1, 16 do
- term.write(" ")
- end
- select = {os.pullEvent("mouse_click")}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement