smoothretro82

fixed code

Dec 21st, 2025 (edited)
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. // Input data
  2. let atxt = "WASD";
  3. let acol = [9,13,10,4];
  4. let bx = [0,-1,0,1]; // relative x offsets
  5. let by = [5,6,7,6]; // relative y offsets
  6. let shiftAmount = 1; // how much to move right each loop
  7. let maxLoops = 10; // number of times to repeat the text
  8. let loopDelay = 700; // delay between loops in milliseconds
  9.  
  10. let currentLoop = 0; // completed loops counter
  11.  
  12. // Calculate absolute positions based on cursor
  13. let absBx = bx.map(x => x + cursor.x);
  14. let absBy = by.map(y => y + cursor.y);
  15.  
  16. // Character check function
  17. function ct(x, y, t, c) {
  18. if (!Tile.exists(Math.floor(x/20)*20, Math.floor(y/10)*10)) return false;
  19. let tile = Tile.get(Math.floor(x/20)*20, Math.floor(y/10)*10);
  20. if (!tile.done) return false;
  21. let info = getCharInfoXY(x, y);
  22. let sum = info.color + info.deco*248 + info.deco.italic*124 + info.deco.underline*62 + info.deco.strike*31;
  23. return info.char === t && sum === c;
  24. }
  25.  
  26. // Paste a run of the text, skipping existing characters
  27. function pasteRun(index = 0) {
  28. if (index >= atxt.length) {
  29. currentLoop++;
  30. if (currentLoop < maxLoops) {
  31. // Shift all x positions for the next run
  32. for (let i = 0; i < absBx.length; i++) absBx[i] += shiftAmount;
  33. // Schedule next run after a delay
  34. setTimeout(() => pasteRun(0), loopDelay);
  35. }
  36. return;
  37. }
  38.  
  39. // Only write if the character is not already correct
  40. if (!ct(absBx[index], absBy[index], atxt[index], acol[index])) {
  41. writeCharAt(atxt[index], acol[index], absBx[index], absBy[index]);
  42. }
  43.  
  44. // Next character in the run
  45. requestAnimationFrame(() => pasteRun(index + 1));
  46. }
  47.  
  48. // Start looping autopaste
  49. pasteRun();
  50.  
Advertisement
Add Comment
Please, Sign In to add comment