Advertisement
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 backColor, appColor, textColor
- local iBackColor, iAppColor, iTextColor
- function GetData()
- if (fs.exists("SysData/options.txt")) then
- file = fs.open("SysData/options.txt", "r")
- backColor = tonumber(file.readLine()) --Background color
- appColor = tonumber(file.readLine()) --App color
- textColor = tonumber(file.readLine()) --Text color
- file.close()
- else
- backColor = colors.cyan --Background color
- appColor = colors.yellow --App color
- textColor = colors.white --Text color
- end
- for i=1,#lsColors,1 do
- if (backColor==lsColors[i]) then iBackColor = 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(backColor) --Background color
- file.writeLine(appColor) --App color
- file.writeLine(textColor) --Text color
- file.close()
- end
- function Gui()
- term.setBackgroundColor(backColor)
- term.clear()
- local win = window.create(term.current(),1,1,26,20)
- win.setBackgroundColor(backColor)
- win.clear()
- --Title
- paintutils.drawPixel(4,2,backColor)
- 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,backColor)
- term.setCursorPos(2,4)
- term.setTextColor(textColor)
- term.write("Background color")
- paintutils.drawPixel(iBackColor,6,backColor)
- term.setCursorPos(iBackColor,6)
- term.setTextColor(textColor)
- term.write("*")
- --App color Picker
- paintutils.drawPixel(2,8,backColor)
- term.setCursorPos(2,8)
- term.setTextColor(textColor)
- term.write("App color")
- paintutils.drawPixel(iAppColor,10,backColor)
- term.setCursorPos(iAppColor,10)
- term.setTextColor(textColor)
- term.write("*")
- --Text color Picker
- paintutils.drawPixel(2,12,backColor)
- term.setCursorPos(2,12)
- term.setTextColor(textColor)
- term.write("Text color")
- paintutils.drawPixel(iTextColor,14,backColor)
- term.setCursorPos(iTextColor,14)
- term.setTextColor(textColor)
- term.write("*")
- --Change peripheral Button
- paintutils.drawPixel(2,17,colors.yellow)
- term.setCursorPos(2,17)
- term.setTextColor(textColor)
- term.write("Change ")
- term.setCursorPos(2,18)
- term.write("Peripheral")
- --Change peripheral Button
- paintutils.drawPixel(13,17,colors.red)
- term.setCursorPos(13,17)
- term.setTextColor(textColor)
- term.write("Unequip ")
- term.setCursorPos(13,18)
- term.write("Peripheral")
- end
- function Buttons(x,y)
- local i = x-1
- if (x == 2 and y == 2) then
- SaveData()
- error("",0)
- elseif (y==5) then
- backColor = lsColors[i]
- iBackColor = x
- elseif (y==9) then
- appColor = lsColors[i]
- iAppColor = x
- elseif (y==13) then
- textColor = lsColors[i]
- iTextColor = x
- elseif (y>=17 and y<=18 and x>=2 and x<=11) then
- pocket.equipBack()
- elseif (y>=17 and y<=18 and x>=13 and x<=22) then
- pocket.unequipBack()
- 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
Advertisement