xXm0dzXx

CraftOS 2.0 Color Support Render Test

Nov 3rd, 2012
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. local x,y = term.getSize()
  2. local startMenu = false
  3. function clickStart()
  4. if startMenu == true then
  5. startMenu = false
  6. else
  7. startMenu = true
  8. end
  9.  
  10. drawGUI()
  11. end
  12.  
  13. local drawingBoard = {
  14. ["A"] = colors.white,
  15. ["B"] = colors.orange,
  16. ["C"] = colors.magenta,
  17. ["D"] = colors.lightBlue,
  18. ["E"] = colors.yellow,
  19. ["F"] = colors.lime,
  20. ["G"] = colors.pink,
  21. ["H"] = colors.gray,
  22. ["I"] = colors.lightGray,
  23. ["J"] = colors.cyan,
  24. ["K"] = colors.purple,
  25. ["L"] = colors.blue,
  26. ["M"] = colors.brown,
  27. ["N"] = colors.green,
  28. ["O"] = colors.red,
  29. ["P"] = colors.black,
  30. }
  31.  
  32. local startMenuObjects = {
  33. [8] = "Programs >",
  34. [7] = "Documents >",
  35. [6] = "Settings >",
  36. [5] = "Find >",
  37. [4] = "Help",
  38. [3] = "Run...",
  39. [1] = "Shut Down...",
  40. }
  41.  
  42. function pixelatedDrawing( pos1, pos2, str )
  43. for i=1,#str do
  44. term.setCursorPos( pos1 + (i-1) , pos2 )
  45. term.setBackgroundColour( drawingBoard[ string.sub( str, i, i) ] )
  46. write(" ")
  47. end
  48. end
  49.  
  50. function drawGUI()
  51. term.setBackgroundColour( colors.cyan )
  52. term.clear()
  53. term.setCursorPos(1,y)
  54. term.setBackgroundColour( colors.lightGray )
  55. term.clearLine()
  56. term.setBackgroundColour( colors.gray )
  57. term.setTextColour( colors.black )
  58. write("Start")
  59.  
  60. if startMenu then
  61. for i=y-8,y-1 do
  62. if i == y-2 then
  63. pixelatedDrawing(1,i,"HHHHHHHHHHHHH") --Hi :D
  64. else
  65. pixelatedDrawing(1,i,"HIIIIIIIIIIII") --Hi :D
  66. local theValue = ((i-y)*-1)
  67.  
  68. term.setCursorPos(2, i)
  69. write( startMenuObjects[ theValue ] )
  70. end
  71. end
  72. end
  73. end
  74.  
  75. function wasBetween( xz, x1, y1, vr1, vr2 )
  76. if xz > x1 and xz < y1 and vr1 == vr2 then
  77. return true
  78. end
  79. return false
  80. end
  81.  
  82. drawGUI()
  83.  
  84. while true do
  85. local event, key, xz, yz = os.pullEvent()
  86. if event == "mouse_click" then
  87. if key == 1 then
  88. if wasBetween(xz, 0, 6, yz, y) then
  89. clickStart()
  90. elseif wasBetween(xz, 2, 14, yz, y-1) then
  91. os.shutdown()
  92. end
  93. elseif key == 2 then
  94. dropdown()
  95. end
  96. end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment