RubixYT1

newsticker textwall

Nov 28th, 2025
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. (async () => {
  2. let endpoint = { x: -18, y: -1 };
  3. let startpoint = { x: 15, y: -1 };
  4. let nt = [];
  5. let isRunning = false;
  6. let shouldStop = false;
  7.  
  8. // Print title FIRST at -19, 0
  9. await w.tp(-19, 0);
  10. let title = 'The Newsticker!';
  11. for (let i = 0; i < title.length; i++) {
  12. w.typeChar(title[i], 1);
  13. }
  14. await new Promise(resolve => setTimeout(resolve, 500));
  15.  
  16. // Function to print brackets at y: -1
  17. async function printBrackets() {
  18. await w.tp(-19, -1);
  19. w.typeChar('[', 1);
  20. await w.tp(startpoint.x, -1);
  21. w.typeChar(']', 1);
  22. }
  23.  
  24. // Print brackets on start
  25. await printBrackets();
  26.  
  27. // Parse styled text with CID=idx{text}
  28. function parseStyledText(text) {
  29. let chars = [];
  30. let regex = /CID=(\d+)\{([^}]*)\}/g;
  31. let lastIndex = 0;
  32. let match;
  33.  
  34. while ((match = regex.exec(text)) !== null) {
  35. // Add characters before the match (no color)
  36. for (let i = lastIndex; i < match.index; i++) {
  37. chars.push({ char: text[i], color: null });
  38. }
  39.  
  40. // Add colored characters
  41. let coloredText = match[2];
  42. let colorIdx = parseInt(match[1]);
  43. for (let char of coloredText) {
  44. chars.push({ char: char, color: colorIdx });
  45. }
  46.  
  47. lastIndex = regex.lastIndex;
  48. }
  49.  
  50. // Add remaining characters (no color)
  51. for (let i = lastIndex; i < text.length; i++) {
  52. chars.push({ char: text[i], color: null });
  53. }
  54.  
  55. return chars;
  56. }
  57.  
  58. // Newsticker function
  59. async function runNewsTicker() {
  60. if (isRunning) return;
  61. isRunning = true;
  62. shouldStop = false;
  63.  
  64. while (nt.length > 0 && !shouldStop) {
  65. for (let item of nt) {
  66. if (shouldStop) break;
  67.  
  68. // Calculate ticker width
  69. let tickerWidth = Math.abs(startpoint.x - endpoint.x);
  70.  
  71. // Parse text into characters with colors
  72. let chars = item.styled ? parseStyledText(item.text) :
  73. item.text.split('').map(c => ({ char: c, color: null }));
  74.  
  75. // Add padding spaces
  76. let paddedChars = [];
  77. for (let i = 0; i < tickerWidth; i++) {
  78. paddedChars.push({ char: ' ', color: null });
  79. }
  80. paddedChars.push(...chars);
  81. for (let i = 0; i < tickerWidth; i++) {
  82. paddedChars.push({ char: ' ', color: null });
  83. }
  84.  
  85. // Scroll through the text
  86. for (let i = 0; i <= paddedChars.length - tickerWidth; i++) {
  87. if (shouldStop) break;
  88.  
  89. // Teleport back to start position
  90. await w.tp(endpoint.x, endpoint.y);
  91.  
  92. // Get visible window
  93. let visibleChars = paddedChars.slice(i, i + tickerWidth);
  94.  
  95. // Type each character with color - only change when CID is detected
  96. for (let charObj of visibleChars) {
  97. // Only change color if CID color is specified
  98. if (charObj.color !== null) {
  99. w.changeColor(charObj.color);
  100. }
  101.  
  102. w.typeChar(charObj.char, 1);
  103. }
  104.  
  105. // 0.4s cooldown between frames
  106. await new Promise(resolve => setTimeout(resolve, 400));
  107. }
  108. }
  109. }
  110.  
  111. isRunning = false;
  112. }
  113.  
  114. // Register console command
  115. window.newsticker = (message) => {
  116. if (message) {
  117. nt.push({ text: message, styled: false });
  118. runNewsTicker();
  119. }
  120. };
  121.  
  122. // Register styled newsticker command
  123. window.ntstyled = (message) => {
  124. if (message) {
  125. nt.push({ text: message, styled: true });
  126. runNewsTicker();
  127. }
  128. };
  129.  
  130. // Generate brackets and run newsticker
  131. window.ntgen = async () => {
  132. await printBrackets();
  133. runNewsTicker();
  134. };
  135.  
  136. // Stop command
  137. window.stop = async () => {
  138. shouldStop = true;
  139. nt = [];
  140.  
  141. // Clear the ticker area
  142. let tickerWidth = Math.abs(startpoint.x - endpoint.x);
  143. await w.tp(endpoint.x, endpoint.y);
  144. for (let i = 0; i < tickerWidth; i++) {
  145. w.typeChar(' ', 1);
  146. }
  147.  
  148. // Reprint brackets
  149. await printBrackets();
  150. };
  151. })();
Advertisement
Add Comment
Please, Sign In to add comment