RubixYT1

Square Area Testing v1.0.1 textwall

Dec 6th, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.94 KB | None | 0 0
  1. (async function() {
  2. const startX = -20;
  3. const startY = -10;
  4. const endX = 19;
  5. const endY = 9;
  6.  
  7. const typingCooldown = 10;
  8. let isRunning = true;
  9. let chatText = '';
  10. let chatX = 0;
  11. let chatY = 0;
  12. let chatTimeout = null;
  13.  
  14. // Helper function for cooldown
  15. function wait(ms) {
  16. return new Promise(resolve => setTimeout(resolve, ms));
  17. }
  18.  
  19. // Square position
  20. let squareX = 0;
  21. let squareY = 0;
  22.  
  23. // Input values for movement (default)
  24. const inputx = 1;
  25. const inputy = 1;
  26.  
  27. // Coordinate display position (top corner of area)
  28. const coordDisplayX = startX;
  29. const coordDisplayY = startY;
  30. const versionDisplayY = startY + 1;
  31.  
  32. const versionText = 'Square Area Testing 1.0.1';
  33.  
  34. // Previous coordinate text length for clearing
  35. let prevCoordTextLength = 0;
  36.  
  37. // Function to draw text at position
  38. async function drawText(x, y, text) {
  39. for (let i = 0; i < text.length; i++) {
  40. await w.tp(x + i, y);
  41. await w.typeChar(text[i], 1);
  42. await wait(typingCooldown);
  43. }
  44. }
  45.  
  46. // Function to clear text at position
  47. async function clearText(x, y, length) {
  48. for (let i = 0; i < length; i++) {
  49. await w.tp(x + i, y);
  50. await w.typeChar(' ', 1);
  51. await wait(typingCooldown);
  52. }
  53. }
  54.  
  55. // Function to update coordinate display
  56. async function updateCoordDisplay() {
  57. const coordText = 'square is at ' + squareX + ', ' + (-squareY);
  58.  
  59. // Clear previous text if longer
  60. if (prevCoordTextLength > coordText.length) {
  61. await clearText(coordDisplayX, coordDisplayY, prevCoordTextLength);
  62. }
  63.  
  64. await drawText(coordDisplayX, coordDisplayY, coordText);
  65. prevCoordTextLength = coordText.length;
  66. }
  67.  
  68. // Function to draw version text
  69. async function drawVersionText() {
  70. await drawText(coordDisplayX, versionDisplayY, versionText);
  71. }
  72.  
  73. // Function to draw the square
  74. async function drawSquare() {
  75. await w.tp(squareX, squareY);
  76. await w.typeChar('[', 1);
  77. await wait(typingCooldown);
  78. await w.typeChar(']', 1);
  79. await wait(typingCooldown);
  80. }
  81.  
  82. // Function to clear the square (replace with spaces)
  83. async function clearSquare() {
  84. await w.tp(squareX, squareY);
  85. await w.typeChar(' ', 1);
  86. await wait(typingCooldown);
  87. await w.typeChar(' ', 1);
  88. await wait(typingCooldown);
  89. }
  90.  
  91. // Function to clear chat text
  92. async function clearChatText() {
  93. if (chatText.length > 0) {
  94. let oldChatText = chatText;
  95. let oldChatX = chatX;
  96. let oldChatY = chatY;
  97. chatText = '';
  98. for (let i = 0; i < oldChatText.length; i++) {
  99. await w.tp(oldChatX + i, oldChatY);
  100. await w.typeChar(' ', 1);
  101. await wait(typingCooldown);
  102. }
  103. }
  104. }
  105.  
  106. // Function to draw chat text
  107. async function drawChatText() {
  108. if (chatText.length > 0) {
  109. // Calculate middle of square (square is 2 chars wide: [ and ])
  110. let squareMiddle = squareX + 0.5;
  111. let textHalfLength = Math.floor(chatText.length / 2);
  112. chatX = Math.round(squareMiddle - textHalfLength);
  113. chatY = squareY - 1; // -1 Y above square
  114.  
  115. for (let i = 0; i < chatText.length; i++) {
  116. await w.tp(chatX + i, chatY);
  117. await w.typeChar(chatText[i], 1);
  118. await wait(typingCooldown);
  119. }
  120. }
  121. }
  122.  
  123. // Check if position is part of UI elements
  124. function isUIPosition(x, y) {
  125. // Square position
  126. if (y === squareY && (x === squareX || x === squareX + 1)) {
  127. return true;
  128. }
  129.  
  130. // Chat text position
  131. if (chatText.length > 0 && y === chatY && x >= chatX && x < chatX + chatText.length) {
  132. return true;
  133. }
  134.  
  135. // Coordinate display position
  136. if (y === coordDisplayY && x >= coordDisplayX && x < coordDisplayX + prevCoordTextLength) {
  137. return true;
  138. }
  139.  
  140. // Version text position
  141. if (y === versionDisplayY && x >= coordDisplayX && x < coordDisplayX + versionText.length) {
  142. return true;
  143. }
  144.  
  145. return false;
  146. }
  147.  
  148. // Check if square brackets are missing and redraw if needed
  149. async function checkSquare() {
  150. if (!isRunning) return;
  151.  
  152. try {
  153. let leftBracket = await w.getCharInfoXY(squareX, squareY);
  154. let rightBracket = await w.getCharInfoXY(squareX + 1, squareY);
  155.  
  156. let needRedraw = false;
  157.  
  158. if (!leftBracket || leftBracket.char !== '[') {
  159. needRedraw = true;
  160. }
  161. if (!rightBracket || rightBracket.char !== ']') {
  162. needRedraw = true;
  163. }
  164.  
  165. if (needRedraw) {
  166. await drawSquare();
  167. console.log('Square restored at (' + squareX + ', ' + (-squareY) + ')');
  168. }
  169. } catch (e) {
  170. console.log('checkSquare error:', e);
  171. }
  172. }
  173.  
  174. // Check area for any non-space characters and replace with space
  175. async function checkArea() {
  176. if (!isRunning) return;
  177.  
  178. try {
  179. for (let y = startY; y <= endY; y++) {
  180. for (let x = startX; x <= endX; x++) {
  181. if (!isRunning) return;
  182.  
  183. // Skip UI elements
  184. if (isUIPosition(x, y)) {
  185. continue;
  186. }
  187.  
  188. let charInfo = await w.getCharInfoXY(x, y);
  189.  
  190. // Skip if already space or null
  191. if (!charInfo || charInfo.char === ' ') {
  192. continue;
  193. }
  194.  
  195. await w.tp(x, y);
  196. await w.typeChar(' ', 1);
  197. await wait(typingCooldown);
  198. console.log('Cleared foreign char at (' + x + ', ' + (-y) + ')');
  199. }
  200. }
  201. } catch (e) {
  202. console.log('checkArea error:', e);
  203. }
  204. }
  205.  
  206. // Clear the area and fill with spaces (skip if already space)
  207. console.log('Clearing area...');
  208. for (let y = startY; y <= endY; y++) {
  209. for (let x = startX; x <= endX; x++) {
  210. try {
  211. let charInfo = await w.getCharInfoXY(x, y);
  212. if (charInfo && charInfo.char === ' ') {
  213. continue; // Skip if already space
  214. }
  215. } catch (e) {
  216. // If error getting char info, just clear it
  217. }
  218. await w.tp(x, y);
  219. await w.typeChar(' ', 1);
  220. await wait(typingCooldown);
  221. }
  222. }
  223. console.log('Area cleared!');
  224.  
  225. // Draw version text first
  226. await drawVersionText();
  227. console.log('Version text drawn!');
  228.  
  229. // Initial coordinate display
  230. await updateCoordDisplay();
  231. console.log('Coord display drawn!');
  232.  
  233. // Initial draw
  234. await drawSquare();
  235. console.log('Square drawn!');
  236.  
  237. // Start monitoring loop
  238. async function monitorLoop() {
  239. while (isRunning) {
  240. await checkSquare();
  241. await checkArea();
  242. await wait(500); // Check every 500ms
  243. }
  244. }
  245.  
  246. // Start monitor in background
  247. setTimeout(function() {
  248. monitorLoop();
  249. }, 100);
  250.  
  251. // Move right (d)
  252. window.moved = async function(amount) {
  253. if (!isRunning) return;
  254. let moveAmount = (typeof amount === 'number') ? amount : inputx;
  255. await clearChatText();
  256. await clearSquare();
  257. squareX += moveAmount;
  258. // Boundary check
  259. if (squareX > endX - 1) squareX = endX - 1;
  260. await drawSquare();
  261. await drawChatText();
  262. await updateCoordDisplay();
  263. console.log('Square position: (' + squareX + ', ' + (-squareY) + ')');
  264. };
  265.  
  266. // Move left (a)
  267. window.movea = async function(amount) {
  268. if (!isRunning) return;
  269. let moveAmount = (typeof amount === 'number') ? amount : inputx;
  270. await clearChatText();
  271. await clearSquare();
  272. squareX -= moveAmount;
  273. // Boundary check
  274. if (squareX < startX) squareX = startX;
  275. await drawSquare();
  276. await drawChatText();
  277. await updateCoordDisplay();
  278. console.log('Square position: (' + squareX + ', ' + (-squareY) + ')');
  279. };
  280.  
  281. // Move up (w) - negated Y
  282. window.movew = async function(amount) {
  283. if (!isRunning) return;
  284. let moveAmount = (typeof amount === 'number') ? amount : inputy;
  285. await clearChatText();
  286. await clearSquare();
  287. squareY -= moveAmount; // Negated
  288. // Boundary check
  289. if (squareY < startY) squareY = startY;
  290. await drawSquare();
  291. await drawChatText();
  292. await updateCoordDisplay();
  293. console.log('Square position: (' + squareX + ', ' + (-squareY) + ')');
  294. };
  295.  
  296. // Move down (s) - negated Y
  297. window.moves = async function(amount) {
  298. if (!isRunning) return;
  299. let moveAmount = (typeof amount === 'number') ? amount : inputy;
  300. await clearChatText();
  301. await clearSquare();
  302. squareY += moveAmount; // Negated (so going down is positive)
  303. // Boundary check
  304. if (squareY > endY) squareY = endY;
  305. await drawSquare();
  306. await drawChatText();
  307. await updateCoordDisplay();
  308. console.log('Square position: (' + squareX + ', ' + (-squareY) + ')');
  309. };
  310.  
  311. // Chat function - puts text above square, clears after 6 seconds
  312. window.chat = async function(text) {
  313. if (!isRunning) return;
  314.  
  315. // Clear any existing timeout
  316. if (chatTimeout) {
  317. clearTimeout(chatTimeout);
  318. chatTimeout = null;
  319. }
  320.  
  321. // Clear old chat text first
  322. await clearChatText();
  323.  
  324. // Set new chat text
  325. chatText = text || '';
  326.  
  327. if (chatText.length > 0) {
  328. await drawChatText();
  329. console.log('Chat: "' + chatText + '" at (' + chatX + ', ' + (-chatY) + ')');
  330.  
  331. // Set timeout to clear chat after 6 seconds
  332. chatTimeout = setTimeout(async function() {
  333. if (isRunning) {
  334. await clearChatText();
  335. console.log('Chat cleared (timeout)');
  336. }
  337. }, 6000);
  338. } else {
  339. console.log('Chat cleared');
  340. }
  341. };
  342.  
  343. // Quit function - stops script and sends message
  344. window.quit = async function() {
  345. isRunning = false;
  346.  
  347. // Clear timeout if exists
  348. if (chatTimeout) {
  349. clearTimeout(chatTimeout);
  350. chatTimeout = null;
  351. }
  352.  
  353. await w.chat.send('Script Shutdown');
  354. console.log('Script Shutdown');
  355.  
  356. // Clean up window functions
  357. delete window.movew;
  358. delete window.movea;
  359. delete window.moves;
  360. delete window.moved;
  361. delete window.chat;
  362. delete window.quit;
  363. };
  364.  
  365. console.log('Controls ready!');
  366. console.log('Use: movew(n), movea(n), moves(n), moved(n) - n is optional move amount');
  367. console.log('Use: chat("your message") - displays text above square for 6 seconds');
  368. console.log('Use: quit() - stops script');
  369. console.log('Square starts at (' + squareX + ', ' + (-squareY) + ')');
  370. })();
Advertisement
Add Comment
Please, Sign In to add comment