Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- settings = {}
- colortab = {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768}
- function loadSettings()
- file = fs.open("/.settings", "r")
- settings = textutils.unserialize(file.readAll())
- file.close()
- end
- function pickColor()
- w, h = term.getSize()
- colreg = {}
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(colors.black)
- term.write("<")
- term.setCursorPos(2, 2)
- term.write("Scegli un colore: ")
- term.setCursorPos((w/2)-((#colortab*3)/2), 4)
- for i, k in pairs(colortab) do
- term.setBackgroundColor(k)
- x, y = term.getCursorPos()
- colreg[tostring(x).." "..tostring(y)] = k
- colreg[tostring(x+1).." "..tostring(y)] = k
- colreg[tostring(x+2).." "..tostring(y)] = k
- if k ~= colors.white then
- term.write(" ")
- else
- term.setTextColor(colors.gray)
- term.write("BIA")
- end
- end
- while true do
- _, bt, x, y = os.pullEvent("mouse_click")
- if bt == 1 and x == 1 and y == 1 then
- return nil
- elseif bt == 1 and colreg[tostring(x).." "..tostring(y)] ~= nil then
- return colreg[tostring(x).." "..tostring(y)]
- end
- end
- end
- function drawSettings()
- w, h = term.getSize()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setCursorPos(51, 1)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.black)
- term.write("X")
- term.setBackgroundColor(colors.white)
- term.setCursorPos((w/2)-(#"Impostazioni"/2), 1)
- term.write("Impostazioni")
- term.setCursorPos(2, 3)
- term.write("Colore di sfondo: ")
- term.setBackgroundColor(settings["background"])
- term.write(" ")
- term.setBackgroundColor(colors.white)
- term.setCursorPos(2, 5)
- term.write("Cancellare i file a sessione terminata: ")
- if settings["live"] then
- term.setBackgroundColor(colors.lime)
- term.write(" ")
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- else
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- term.setBackgroundColor(colors.red)
- term.write(" ")
- end
- end
- loadSettings()
- while true do
- drawSettings()
- _, bt, x, y = os.pullEvent("mouse_click")
- if bt == 1 and x == 51 and y == 1 then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- break
- elseif bt == 1 and x >= 20 and x <= 21 and y == 3 then
- color = pickColor()
- if color ~= nil then
- settings["background"] = color
- file = fs.open("/.settings", "w")
- file.write(textutils.serialize(settings))
- file.close()
- end
- elseif bt == 1 and x >= 42 and x <= 43 and y == 5 then
- settings["live"] = not settings["live"]
- file = fs.open("/.settings", "w")
- file.write(textutils.serialize(settings))
- file.close()
- end
- end
- return
Advertisement
Add Comment
Please, Sign In to add comment