xXm0dzXx

ccTube v-1.0

Nov 10th, 2012
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. local x,y = term.getSize()
  2. local serverID = 426
  3.  
  4. if paintutils then
  5. if term.isColor() ~= true then
  6. print("Computer doesn't support colors.")
  7. return
  8. end
  9. else
  10. print("Outdated Computercraft, failed to run.")
  11. return
  12. end
  13.  
  14. local function cPrint(text)
  15. x2,y2 = term.getCursorPos()
  16. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  17. write(text.. "\n")
  18. end
  19.  
  20. local drawingBoard = {
  21. ["A"] = colors.white,
  22. ["B"] = colors.orange,
  23. ["C"] = colors.magenta,
  24. ["D"] = colors.lightBlue,
  25. ["E"] = colors.yellow,
  26. ["F"] = colors.lime,
  27. ["G"] = colors.pink,
  28. ["H"] = colors.gray,
  29. ["I"] = colors.lightGray,
  30. ["J"] = colors.cyan,
  31. ["K"] = colors.purple,
  32. ["L"] = colors.blue,
  33. ["M"] = colors.brown,
  34. ["N"] = colors.green,
  35. ["O"] = colors.red,
  36. ["P"] = colors.black,
  37. }
  38.  
  39. function advWrite( pos1, pos2, str )
  40. for i=1,#str do
  41. local symb = drawingBoard[ string.sub( str, i, i) ]
  42. term.setCursorPos( pos1 + (i-1) , pos2 )
  43. if symb then
  44. term.setBackgroundColour( symb )
  45. write(" ")
  46. end
  47. end
  48. end
  49.  
  50. function drawTop()
  51. term.setTextColour( colors.white )
  52. term.setBackgroundColour( colors.black )
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. write("cc")
  56. term.setBackgroundColour( colors.red )
  57. term.setTextColour( colors.black )
  58. write("Tube")
  59. term.setTextColour( colors.white )
  60. term.setBackgroundColour( colors.black )
  61. write(" | rednet.broadcast() yourself")
  62. for i=1,x do
  63. term.setCursorPos(i,2)
  64. write("-")
  65. end
  66. print()
  67. end
  68.  
  69. function drawThumbnail( thumbnail, title, views, description1, description2 )
  70. term.setTextColour( colors.white )
  71. term.setBackgroundColour( colors.black )
  72. local xz,yz = term.getCursorPos()
  73. print("XXXXXXXXXXX " ..title)
  74. print("XXXXXXXXXXX ")
  75. print("XXXXXXXXXXX " ..views.. " views")
  76. print("XXXXXXXXXXX " ..description1)
  77. print("XXXXXXXXXXX " ..description2)
  78. for i=1,5 do
  79. advWrite( 1, yz+(i-1), thumbnail[i] )
  80. end
  81.  
  82. print()
  83. local xz,yz = term.getCursorPos()
  84. term.setBackgroundColour( colors.black )
  85. for i=1,x do
  86. term.setCursorPos( i, yz )
  87. write("-")
  88. end
  89. print()
  90. end
  91.  
  92. drawTop()
  93. --[[
  94. testVideos = {
  95. [1] = {
  96. ["Thumbnail"] = { --11x5 = highest RES
  97. "JJJJMJJJJJJ",
  98. "JJJMMMJJJJJ",
  99. "JJJMMMJJJJJ",
  100. "NNNNNNNNNNN",
  101. "MMMMMMMMMMM",
  102. },
  103. ["Title"] = "screen_recorder_1",
  104. ["Views"] = 301,
  105. ["Desc"] = "Example video, made",
  106. ["Desc2"] = "with ccRec v2.0",
  107. },
  108. }
  109. for i=1,#testVideos do
  110. drawThumbnail( testVideos[i]["Thumbnail"], testVideos[i]["Title"], testVideos[i]["Views"], testVideos[i]["Desc"], testVideos[i]["Desc2"] )
  111. end
  112. ]]--
  113.  
  114. local videos = {}
  115. rednet.send( serverID, "request_videos" )
  116. repeat
  117. id, message = rednet.receive()
  118. until id == serverID
  119.  
  120. videos = textutils.unserialize( message )
  121.  
  122. for i=1,#videos do
  123. drawThumbnail( videos[i]["Thumbnail"], videos[i]["Title"], videos[i]["Views"], videos[i]["Desc"], videos[i]["Desc2"] )
  124. end
  125.  
  126. sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment