Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lsColors = {colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime, colors.pink, colors.gray, colors.lightGray, colors.cyan, colors.purple, colors.blue, colors.brown, colors.green, colors.red, colors.black}
- local barColor, appColor, textColor
- local iBarColor, iAppColor, iTextColor
- function GetData()
- if (fs.exists("SysData/options.txt")) then
- file = fs.open("SysData/options.txt", "r")
- barColor = tonumber(file.readLine()) --Background color
- appColor = tonumber(file.readLine()) --App color
- textColor = tonumber(file.readLine()) --Text color
- file.close()
- else
- barColor = colors.blue --Background color
- appColor = colors.yellow --App color
- textColor = colors.black --Text color
- end
- for i=1,#lsColors,1 do
- if (barColor==lsColors[i]) then iBarColor = i+1 end
- if (appColor==lsColors[i]) then iAppColor = i+1 end
- if (textColor==lsColors[i]) then iTextColor = i+1 end
- end
- end
- function SaveData()
- file = fs.open("SysData/options.txt", "w")
- file.writeLine(barColor) --Bar color
- file.writeLine(appColor) --App color
- file.writeLine(textColor) --Text color
- file.close()
- end
- function Gui()
- term.setBackgroundColor(colors.white)
- term.clear()
- local win = window.create(term.current(),1,1,26,20)
- win.setBackgroundColor(colors.white)
- win.clear()
- --Title
- paintutils.drawPixel(4,2,barColor)
- term.setCursorPos(4,2)
- term.setTextColor(textColor)
- term.write("-Design Options-")
- --Return button
- paintutils.drawPixel(2,2,colors.red)
- term.setCursorPos(2,2)
- term.setTextColor(textColor)
- term.write("x")
- --Color pickers
- for i=1,#lsColors,1 do
- paintutils.drawPixel(i+1,5,lsColors[i])
- paintutils.drawPixel(i+1,9,lsColors[i])
- paintutils.drawPixel(i+1,13,lsColors[i])
- end
- --Background color Picker
- paintutils.drawPixel(2,4,barColor)
- term.setCursorPos(2,4)
- term.setTextColor(textColor)
- term.write("Bar color")
- paintutils.drawPixel(iBarColor,6,barColor)
- term.setCursorPos(iBarColor,6)
- term.setTextColor(textColor)
- term.write("*")
- --App color Picker
- paintutils.drawPixel(2,8,barColor)
- term.setCursorPos(2,8)
- term.setTextColor(textColor)
- term.write("App color")
- paintutils.drawPixel(iAppColor,10,barColor)
- term.setCursorPos(iAppColor,10)
- term.setTextColor(textColor)
- term.write("*")
- --Text color Picker
- paintutils.drawPixel(2,12,barColor)
- term.setCursorPos(2,12)
- term.setTextColor(textColor)
- term.write("Text color")
- paintutils.drawPixel(iTextColor,14,barColor)
- term.setCursorPos(iTextColor,14)
- term.setTextColor(textColor)
- term.write("*")
- end
- function Buttons(x,y)
- local i = x-1
- if (x == 2 and y == 2) then
- SaveData()
- error("",0)
- elseif (y==5) then
- barColor = lsColors[i]
- iBarColor = x
- elseif (y==9) then
- appColor = lsColors[i]
- iAppColor = x
- elseif (y==13) then
- textColor = lsColors[i]
- iTextColor = x
- end
- end
- -- Main --
- local click=false
- GetData()
- while(true) do
- local e,b,x,y
- parallel.waitForAny(
- function()
- Gui()
- sleep(2)
- end,
- function()
- e,b,x,y = os.pullEvent("mouse_click")
- click = true
- end)
- if (click == true) then
- click = false
- Buttons(x,y)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment