Guest User

GoCraftOS

a guest
Jul 20th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.51 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("GoCraftOS by")
  25.   term.setCursorPos(CnWidth-7,height)
  26.   term.write("Goodle Software")
  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(1,1)
  98.     term.setTextColour( colours.white )
  99.     read(" ")
  100.     local event, keyPressed = os.pullEvent('key')
  101.     if keyPressed == 15 then
  102.       break
  103.       end
  104.   end
  105. end
  106.  
  107.  
  108. drawWindow = function()
  109.   term.clear()
  110. end
  111.  
  112.  
  113. drawMenu = function()
  114.   isMenu = true
  115.   local menuPD = 1 -- Menu pixels down
  116.   local menuPDL = height -- 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, colors.blue )
  121.     menuPUL = menuPUL + 1
  122.     menuPD = menuPD + 1
  123.     end
  124.   term.setCursorPos(1,height)
  125.   term.setTextColour( colours.white )
  126.   term.setBackgroundColour( colours.green )
  127.   term.write(" menu ")
  128.  
  129.   while isMenu == true do
  130.     local event, keyPressed2 = os.pullEvent("key")
  131.     if keyPressed2 == 15 then
  132.       isMenu = false
  133.       desktop()
  134.       break
  135.     end
  136.   end
  137.  
  138. end
  139. -- Program execution
  140.  
  141. startup()
  142.  
  143. drawMenu()
  144.  
  145. while desktop == true do
  146.   drawMenu()
  147. end
Advertisement
Add Comment
Please, Sign In to add comment