Guest User

GoCraftOS

a guest
Jul 21st, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.70 KB | None | 0 0
  1. ---- By: Goodle
  2.  
  3. -- Variables
  4.  
  5. width, height = term.getSize()
  6.  
  7. CnWidth = width / 2
  8. CnHeight = height / 2
  9.  
  10. time = os.time()
  11. formattedTime = textutils.formatTime( time, false)
  12.  
  13. isMenu = false
  14. isDesktop = false
  15. isStartup = false
  16.          
  17. -- Functions
  18.  
  19. startup = function()
  20.   isStartup = true
  21.   term.clear()
  22.   term.setCursorPos(CnWidth-5,height-1)
  23.   term.setTextColour( colours.blue )
  24.   term.write("WaffgoOS by")
  25.   term.setCursorPos(CnWidth-20,height)
  26.   term.write("Goodle Software - In cooperation with CPGGC")
  27.   term.setCursorPos(CnWidth-3,CnHeight-1)
  28.   term.setTextColour( colours.lightBlue )
  29.   term.write("Loading")
  30.   term.setCursorPos(CnWidth-6,CnHeight)
  31.   term.write(";")
  32.   term.setCursorPos(CnWidth+6,CnHeight)
  33.   term.write(";")
  34.   term.setBackgroundColour( colours.black )
  35.   term.setCursorPos(CnWidth,CnHeight+1)
  36.   term.write('0%')
  37.   sleep(1)
  38.   paintutils.drawLine(CnWidth-5,CnHeight, CnWidth,CnHeight, colours.green )
  39.   term.setBackgroundColour( colours.black )
  40.   term.setCursorPos(CnWidth-1,CnHeight+1)
  41.   term.write("50%")
  42.   sleep(0.5)
  43.   paintutils.drawLine(CnWidth,CnHeight, CnWidth+4,CnHeight, colours.green )
  44.   term.setBackgroundColour( colours.black )
  45.   term.setCursorPos(CnWidth-1,CnHeight+1)
  46.   term.clearLine()
  47.   term.write("78%")
  48.   sleep(0.3)
  49.   term.setCursorPos(CnWidth-1,CnHeight+1)
  50.   term.clearLine()
  51.   term.write("80%")
  52.   sleep(0.5)
  53.   paintutils.drawLine(CnWidth+4,CnHeight, CnWidth+5,CnHeight, colours.green )
  54.   term.setBackgroundColour( colours.black )
  55.   term.setCursorPos(CnWidth-1,CnHeight+1)
  56.   term.clearLine()
  57.   term.write("100%")
  58.   term.setCursorPos(CnWidth-3,CnHeight-1)
  59.   term.clearLine()
  60.   term.setBackgroundColour( colours.black )
  61.   term.write("Welcome!")
  62.   sleep(3)
  63.   isStartup = false
  64.   desktop()
  65. end
  66.  
  67.  
  68. desktop = function()
  69.  
  70.   isDesktop = true
  71.   term.clear()
  72.   pixelsDown = 1
  73.   pixelsDownLimit = height
  74.   -- Desktop drawing
  75.  
  76.   while pixelsDown ~= height
  77.     do paintutils.drawLine(1,pixelsDown, width,pixelsDown, colours.white )
  78.     pixelsDown = pixelsDown + 1
  79.     end
  80.   paintutils.drawLine(1,height, width,height, colours.blue )
  81.   term.setCursorPos(1,height)
  82.   term.setTextColour( colours.white )
  83.   term.setBackgroundColour( colours.lime )
  84.   term.write(' @ menu ')
  85.  
  86.   -- Clock Drawing
  87.  
  88.   term.setCursorPos(width-6,height)
  89.   term.setTextColour( colours.white )
  90.   term.setBackgroundColour( colours.blue )
  91.   term.write(formattedTime)
  92.  
  93.   -- Text Input Impeder
  94.  
  95.   while isDesktop == true do
  96.     term.setBackgroundColour( colours.white )
  97.     term.setCursorPos(0,0)
  98.     term.setCursorBlink(false)
  99.     local event, click, x, y = os.pullEvent("mouse_click")
  100.     if x == 2 then
  101.       if y == height then
  102.       break
  103.       end
  104.     end
  105.   end
  106. end
  107.  
  108. drawWindow = function()
  109.   term.clear()
  110. end
  111.  
  112.  
  113. drawMenu = function()
  114.   isMenu = true
  115.   local menuPD = 2 -- Menu pixels down
  116.   local menuPDL = height-1 -- Menu pixels down limit
  117.   local menuPUL = height-10 -- Menu pixels up limit
  118.   -- Menu pixels right limit is = 15
  119.   while menuPD < menuPDL do
  120.     paintutils.drawLine(1, menuPUL, 15, menuPUL, 400 )
  121.     menuPUL = menuPUL + 1
  122.     menuPD = menuPD + 1
  123.     end -- Dimensions of menu: w-15 from left, h-9 from height - 1
  124.   term.setCursorPos(1,height)
  125.   term.setTextColour( colours.white )
  126.   term.setBackgroundColour( colours.green )
  127.   term.write(" @ menu ")
  128.  
  129.   paintutils.drawLine(9,height, 15,height, colours.blue )
  130.   term.setCursorPos(2,height-1)
  131.   term.setBackgroundColour( 400 )
  132.   term.setTextColour( colours.yellow )
  133.   term.write("@ Exit") -- Logoff button
  134.   term.setCursorPos(2,height-2)
  135.   term.setTextColour( colours.red )
  136.   term.write("@ Shutdown") -- Shutdown button
  137.  
  138.   term.setBackgroundColour( colours.white )
  139. --  menuButtons()
  140.  
  141.   while isMenu == true do
  142.     local event, click2, x, y = os.pullEvent("mouse_click")
  143.     if x ==  2 then
  144.       if y == height then
  145.         isMenu = false
  146.         desktop()
  147.         break
  148.       end
  149.     end
  150.   end  
  151. end
  152.  
  153. --menuButtons = function()
  154. --  while isMenu == true do
  155. --    local event, click3, x, y = os.pullEvent("mouse_click")
  156. --    if x == 2 then
  157. --      if y == height-1 then
  158. --        isMenu = false
  159. --        isDesktop = false
  160. --        isStartup = false
  161. --        exit()
  162. --   elseif x == 2 then
  163. --     if y == height-2 then
  164. --       term.clear()
  165. --        exit()
  166. --        os.shutdown()
  167. --    else
  168. --      break
  169. --    end  -- What the hell? Cannot find error in "end" syntax
  170. --end
  171.  
  172. exit = function()
  173.   term.clear()
  174.   term.setBackgroundColour(colours.black)
  175.   term.setTextColour(colours.white)
  176.   term.setCursorPos(1,1)
  177.   term.clear()
  178. end
  179. -- Program execution
  180.  
  181. startup()
  182.  
  183. drawMenu()
  184.  
  185. while isDesktop == true do
  186.   drawMenu()  
  187.   menuButtons()
  188. end
Advertisement
Add Comment
Please, Sign In to add comment