paramus

Options

Aug 19th, 2025 (edited)
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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}
  2.  
  3. local barColor, appColor, textColor
  4. local iBarColor, iAppColor, iTextColor
  5.  
  6. function GetData()
  7.     if (fs.exists("SysData/options.txt")) then
  8.         file = fs.open("SysData/options.txt", "r")
  9.         barColor = tonumber(file.readLine()) --Background color
  10.         appColor = tonumber(file.readLine()) --App color
  11.         textColor = tonumber(file.readLine()) --Text color
  12.         file.close()
  13.     else
  14.         barColor = colors.blue --Background color
  15.         appColor = colors.yellow --App color
  16.         textColor = colors.black --Text color
  17.     end
  18.    
  19.     for i=1,#lsColors,1 do
  20.         if (barColor==lsColors[i]) then iBarColor = i+1 end
  21.         if (appColor==lsColors[i]) then iAppColor = i+1 end
  22.         if (textColor==lsColors[i]) then iTextColor = i+1 end
  23.     end
  24. end
  25.  
  26. function SaveData()
  27.     file = fs.open("SysData/options.txt", "w")
  28.     file.writeLine(barColor) --Bar color
  29.     file.writeLine(appColor) --App color
  30.     file.writeLine(textColor) --Text color
  31.     file.close()
  32. end
  33.  
  34. function Gui()
  35.     term.setBackgroundColor(colors.white)
  36.     term.clear()
  37.     local win = window.create(term.current(),1,1,26,20)
  38.     win.setBackgroundColor(colors.white)
  39.     win.clear()
  40.  
  41.     --Title
  42.     paintutils.drawPixel(4,2,barColor)
  43.     term.setCursorPos(4,2)
  44.     term.setTextColor(textColor)
  45.     term.write("-Design Options-")
  46.    
  47.     --Return button
  48.     paintutils.drawPixel(2,2,colors.red)
  49.     term.setCursorPos(2,2)
  50.     term.setTextColor(textColor)
  51.     term.write("x")
  52.    
  53.     --Color pickers
  54.     for i=1,#lsColors,1 do
  55.         paintutils.drawPixel(i+1,5,lsColors[i])
  56.         paintutils.drawPixel(i+1,9,lsColors[i])
  57.         paintutils.drawPixel(i+1,13,lsColors[i])
  58.     end
  59.    
  60.     --Background color Picker
  61.     paintutils.drawPixel(2,4,barColor)
  62.     term.setCursorPos(2,4)
  63.     term.setTextColor(textColor)
  64.     term.write("Bar color")
  65.     paintutils.drawPixel(iBarColor,6,barColor)
  66.     term.setCursorPos(iBarColor,6)
  67.     term.setTextColor(textColor)
  68.     term.write("*")
  69.    
  70.     --App color Picker
  71.     paintutils.drawPixel(2,8,barColor)
  72.     term.setCursorPos(2,8)
  73.     term.setTextColor(textColor)
  74.     term.write("App color")
  75.     paintutils.drawPixel(iAppColor,10,barColor)
  76.     term.setCursorPos(iAppColor,10)
  77.     term.setTextColor(textColor)
  78.     term.write("*")
  79.    
  80.     --Text color Picker
  81.     paintutils.drawPixel(2,12,barColor)
  82.     term.setCursorPos(2,12)
  83.     term.setTextColor(textColor)
  84.     term.write("Text color")
  85.     paintutils.drawPixel(iTextColor,14,barColor)
  86.     term.setCursorPos(iTextColor,14)
  87.     term.setTextColor(textColor)
  88.     term.write("*")
  89. end
  90.  
  91. function Buttons(x,y)
  92.     local i = x-1
  93.    
  94.     if (x == 2 and y == 2) then
  95.         SaveData()
  96.         error("",0)
  97.     elseif (y==5) then
  98.         barColor = lsColors[i]
  99.         iBarColor = x
  100.     elseif (y==9) then
  101.         appColor = lsColors[i]
  102.         iAppColor = x
  103.     elseif (y==13) then
  104.         textColor = lsColors[i]
  105.         iTextColor = x
  106.     end
  107. end
  108.  
  109. -- Main --
  110. local click=false
  111. GetData()
  112. while(true) do
  113.     local e,b,x,y
  114.     parallel.waitForAny(
  115.         function()
  116.             Gui()
  117.             sleep(2)
  118.         end,
  119.         function()
  120.             e,b,x,y = os.pullEvent("mouse_click")
  121.             click = true
  122.         end)
  123.    
  124.     if (click == true) then
  125.         click = false
  126.         Buttons(x,y)
  127.     end
  128. end
Advertisement
Add Comment
Please, Sign In to add comment