Advertisement
xXm0dzXx

NoPunTendo Lii

Oct 26th, 2012
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.85 KB | None | 0 0
  1. local x,y = term.getSize()
  2. local uicul = colors.red
  3. local bootPath = false
  4. local gameName = ""
  5.  
  6. function cPrint(str)
  7.     _, ypos = term.getCursorPos()
  8.     term.setCursorPos(x/2-#str/2, ypos)
  9.     write(str.. "\n")
  10. end
  11.  
  12. function clearScreen( colua )
  13.     term.setBackgroundColour( colua )
  14.     term.clear()
  15. end
  16.  
  17. clearScreen( colors.black )
  18. term.setCursorPos(1, 3)
  19. cPrint("WARINING-HEALTH AND SAFETY")
  20. print()
  21. cPrint("BEFORE PLAYING, PLEASE NOT THAT THIS")
  22. cPrint("GAME MIGHT BE TOO EPIC FOR")
  23. cPrint("A NORMAL MINECRAFTIAN.")
  24. print()
  25. cPrint("Also online at")
  26. cPrint("www.computercraft.info/forums2/")
  27. sleep(1)
  28. print()
  29. cPrint("Press (A) to continue.")
  30. repeat
  31.     local event, key = os.pullEvent("char")
  32. until key == "a" or key == "A"
  33. sleep(0.5)
  34. if fs.exists(".lii") then
  35.     file = fs.open(".lii/settings", "r")
  36.     uicul = textutils.unserialize(file.readLine())
  37.     file.close()
  38. else
  39.     fs.makeDir(".lii")
  40.     file = fs.open(".lii/settings", "w")
  41.     file.write( textutils.serialize( colors.red ) )
  42.     file.close()
  43. end
  44.  
  45. function updateTime()
  46.     term.setBackgroundColour( colors.white )
  47.     term.setTextColour( uicul )
  48.     term.setCursorPos(1,y-4)
  49.     cPrint( textutils.formatTime( os.time() ) )
  50.     timer = os.startTimer(0.5)
  51. end
  52.    
  53. function drawSquare( posX, posY, colah )
  54.     term.setBackgroundColour( colah )
  55.     for i=1,7 do
  56.         term.setCursorPos(posX,posY)
  57.         write(" ")
  58.         term.setCursorPos(posX,posY+i)
  59.         write(" ")
  60.         term.setCursorPos(posX+7,posY+i)
  61.         write(" ")
  62.         term.setCursorPos(posX+i,posY)
  63.         write(" ")
  64.         term.setCursorPos(posX+i, posY+7)
  65.         write(" ")
  66.     end
  67. end
  68.    
  69. function drawUI()
  70.     clearScreen( colors.white )
  71.     term.setBackgroundColour( colors.lightBlue )
  72.     for i=0,10 do
  73.         term.setCursorPos(i,y-5)
  74.         write(" ")
  75.         term.setCursorPos(x-i,y-5)
  76.         write(" ")
  77.     end
  78.    
  79.     term.setCursorPos(x-11, y-4)
  80.     write(" ")
  81.    
  82.     term.setCursorPos(x-12, y-3)
  83.     write(" ")
  84.    
  85.     term.setCursorPos(11, y-4)
  86.     write(" ")
  87.    
  88.     term.setCursorPos(12, y-3)
  89.     write(" ")
  90.    
  91.     for i=13, x-13 do
  92.         write(" ")
  93.     end
  94.    
  95.     term.setBackgroundColour( uicul )
  96.     for i=0,10 do
  97.         term.setCursorPos(i, y-4)
  98.         write(" ")
  99.         term.setCursorPos(x-i, y-4)
  100.         write(" ")
  101.     end
  102.     for i=0,11 do
  103.         term.setCursorPos(i, y-3)
  104.         write(" ")
  105.         term.setCursorPos(x-i, y-3)
  106.         write(" ")
  107.     end
  108.     for i=0,x do
  109.         term.setCursorPos(i, y-2)
  110.         write(" ")
  111.         term.setCursorPos(i, y-1)
  112.         write(" ")
  113.         term.setCursorPos(i, y)
  114.         write(" ")
  115.     end
  116.     term.setBackgroundColour( colors.lightGray )
  117.     term.setCursorPos(3,y-1)
  118.     write("   ")
  119.     term.setCursorPos(2,y-2)
  120.     write(" Lii ")
  121.     term.setCursorPos(3,y-3)
  122.     write("   ")
  123.    
  124.     term.setCursorPos(x-4,y-1)
  125.     write("   ")
  126.     term.setCursorPos(x-5,y-2)
  127.     write(" LRM ")
  128.     term.setCursorPos(x-4,y-3)
  129.     write("   ")
  130.    
  131.     drawSquare( 2,2,uicul )
  132.     term.setCursorPos(2,2)
  133.     write("1) ...")
  134.     drawSquare( 11,2,colors.lightGray )
  135.     term.setCursorPos(11,2)
  136.     write("2) None")
  137.    
  138.     drawSquare( x-8,2,colors.lightGray )
  139.     term.setCursorPos(x-8,2)
  140.     write("3) None")
  141.     drawSquare( x-17,2,colors.lightGray )
  142.     term.setCursorPos(x-17,2)
  143.     write("4) None")
  144.    
  145.     term.setCursorPos(3,4)
  146.     term.setBackgroundColour( colors.white )
  147.     term.setTextColour( colors.black )
  148.     write("Insert")
  149.     term.setCursorPos(3,5)
  150.     term.setBackgroundColour( colors.white )
  151.     term.setTextColour( colors.black )
  152.     write("Floppy")
  153.     term.setCursorPos(3,6)
  154.     term.setBackgroundColour( colors.white )
  155.     term.setTextColour( colors.black )
  156.     write("<!--!>")
  157. end
  158.  
  159. drawUI()
  160. updateTime()
  161. while true do
  162.     local event, key = os.pullEvent()
  163.     if event == "timer" and key == timer then
  164.         updateTime()
  165.         for k,v in pairs( rs.getSides() ) do
  166.             if disk.isPresent(v) then
  167.                 local side = v
  168.                 local disks = disk.getMountPath( side )
  169.                 if fs.exists( disks.. "/gameInfo" ) then
  170.                     file = fs.open( disks.. "/gameInfo", "r" )
  171.                     bootPath = disks.. "/" ..file.readLine()
  172.                     gameName = file.readLine()
  173.                     file.close()
  174.                     break
  175.                 elseif fs.exists( disks.. "/startup" ) then
  176.                     bootPath = disks.. "/startup"
  177.                     gameName = "Error!"
  178.                     break
  179.                 end
  180.             end
  181.            
  182.             bootPath = false
  183.             gameName = ""
  184.         end
  185.        
  186.         if bootPath then
  187.             term.setCursorPos(3,4)
  188.             term.setBackgroundColour( colors.white )
  189.             term.setTextColour( colors.black )
  190.             write( gameName )
  191.             term.setCursorPos(3,5)
  192.             write( "      " )
  193.             term.setCursorPos(3,6)
  194.             write( "      " )
  195.         else
  196.             term.setCursorPos(3,4)
  197.             term.setBackgroundColour( colors.white )
  198.             term.setTextColour( colors.black )
  199.             write("Insert")
  200.             term.setCursorPos(3,5)
  201.             term.setBackgroundColour( colors.white )
  202.             term.setTextColour( colors.black )
  203.             write("Floppy")
  204.             term.setCursorPos(3,6)
  205.             term.setBackgroundColour( colors.white )
  206.             term.setTextColour( colors.black )
  207.             write("<!--!>")
  208.         end
  209.     elseif event == "key" and key > 1 and key < 6 then
  210.         local keyNum = key -1
  211.         if keyNum == 1 and bootPath then
  212.             shell.run( bootPath )
  213.             drawUI()
  214.             updateTime()
  215.         end
  216.     end
  217. end
  218. sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement