Advertisement
optimussnorr

code

Oct 1st, 2014
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.00 KB | None | 0 0
  1. --[[
  2.    Linear Operating System
  3.          Desktop
  4.   ]]
  5.  
  6. if fs.exists("linear/system/desktopConfig.ls") then
  7.  
  8.   --[[ load config ]]
  9.   local handle = assert(fs.open("linear/system/desktopConfig.ls", "r"), "Failed to load desktop configuration")
  10.   local input = handle.readAll()
  11.   handle.close()
  12.   local deskVar = textutils.unserialize(input)
  13.   deskVar.mBarC = menuBarC
  14.   deskVar.timeFormat = timeForm
  15.  
  16.   --[[ draw desktop ]]
  17.  
  18.   clear(1,1)
  19.   local backgroundImage = paintutils.loadImage("linear/system/imgs/defaultBg.lsg")
  20.   paintutils.drawImage(backgroundImage,1,2)
  21.   pos(1,1)
  22.   bCol(menuBarC)
  23.   cLine()
  24.  
  25.  
  26.  
  27.  else --if the config does NOT exist
  28.  
  29.   local makeConfig = fs.open("linear/system/desktopConfig.ls", "w")
  30.   makeConfig.close()
  31.  
  32.   local function step2()
  33.    clear(1,1)
  34.    centerPrint("Time Format")
  35.    print("")
  36.    centerPrint("Do you want the clock in 12hr or 24hrs?")
  37.    print("")
  38.    clear(1,1)
  39.  
  40.    bCol(colors.green)
  41.    pos(12,8)
  42.    print("          ")
  43.    pos(12,9)
  44.    print("   12hr   ")
  45.    pos(12,10)
  46.    print("          ")
  47.  
  48.    pos(11,10)
  49.    bCol(colors.gray)
  50.    print("?")
  51.    bCol(colors.white)
  52.  
  53.    bCol(colors.cyan)
  54.    pos(32,8)
  55.    print("          ")
  56.    pos(32,9)
  57.    print("   24hr   ")
  58.    pos(32,10)
  59.    print("          ")
  60.    
  61.    while true do
  62.    if event == "mouse_click" then
  63.     if x>12 and x<22 and y>7 and y<11 and button==1 then
  64.      local target = {}
  65.      target.timeFormat = twelveHR
  66.      local output = textutils.serialize(target)
  67.      target.close()
  68.      local handle = assert(fs.open("linear/system/desktopConfig.ls", "w"), "Failed to load desktop configuration")
  69.      handle.write(output)
  70.      handle.close()
  71.      shell.run("linear/system/desktop.ls")
  72.     elseif x>31 and x<42 and y>7 and y<11 and button ==1 then
  73.      local target = {}
  74.      target.timeFormat = twenty4HR
  75.      local output = textutils.serialize(target)
  76.      target.close()
  77.      local handle = assert(fs.open("linear/system/desktopConfig.ls", "w"), "Failed to load desktop configuration")
  78.      handle.write(output)
  79.      handle.close()
  80.      shell.run("linear/system/desktop.ls")
  81.     end
  82.    end
  83.    end
  84.   end
  85.    
  86.   clear(1,3)
  87.   centerPrint("Welcome to Linear OS")
  88.   print("")
  89.   print("")
  90.   centerPrint("Choose a Menu Bar color")
  91.   print("")
  92.   print("[BLUE] [RED] [GREEN] [CYAN] [ORANGE]")
  93.   while true do
  94.   local event, button, x, y = os.pullEventRaw()
  95.   if event == "mouse_click" then
  96.    if x>1 and x<6 and y==6 and button==1 then
  97.     local target = {}
  98.     target.mBarC = colors.blue
  99.     output = textutils.serialize(target)
  100.     target.close()
  101.     handle = assert(fs.open("linear/system/desktopConfig.ls", "w"), "Failed to load desktop configuration")
  102.     handle.write(output)
  103.     handle.close()
  104.     step2()
  105.    
  106.    elseif x>8 and x<12 and y==6 and button==1 then
  107.     local target = {}
  108.     target.mBarC = colors.red
  109.     local output = textutils.serialize(target)
  110.     target.close()
  111.     local handle = assert(fs.open("linear/system/desktopConfig.ls", "w"), "Failed to load desktop configuration")
  112.     handle.write(output)
  113.     handle.close()
  114.     step2()
  115.    
  116.    elseif x>14 and x<20 and y==6 and button==1 then
  117.     local target = {}
  118.     target.mBarC = colors.green
  119.     local output = textutils.serialize(target)
  120.     target.close()
  121.     local handle = assert(fs.open("linear/system/desktopConfig.ls", "w"), "Failed to load desktop configuration")
  122.     handle.write(output)
  123.     handle.close()
  124.     step2()
  125.    
  126.    elseif x>22 and x<27 and y==6 and button==1 then
  127.     local target = {}
  128.     target.mBarC = colors.cyan
  129.     local output = textutils.serialize(target)
  130.     target.close()
  131.     local handle = assert(fs.open("linear/system/desktopConfig.ls", "w"), "Failed to load desktop configuration")
  132.     handle.write(output)
  133.     handle.close()
  134.     step2()
  135.    
  136.    elseif x>29 and x<36 and y==6 and button==1 then
  137.     local target = {}
  138.     target.mBarC = colors.orange
  139.     local output = textutils.serialize(target)
  140.     target.close()
  141.     local handle = assert(fs.open("linear/system/desktopConfig.ls", "w"), "Failed to load desktop configuration")
  142.     handle.write(output)
  143.     handle.close()
  144.     step2()
  145.    end
  146.   end
  147.   end
  148. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement