Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Input data
- let atxt = "WASD";
- let acol = [9,13,10,4];
- let bx = [0,-1,0,1]; // relative x offsets
- let by = [5,6,7,6]; // relative y offsets
- let shiftAmount = 1; // how much to move right each loop
- let maxLoops = 10; // number of times to repeat the text
- let loopDelay = 700; // delay between loops in milliseconds
- let currentLoop = 0; // completed loops counter
- // Calculate absolute positions based on cursor
- let absBx = bx.map(x => x + cursor.x);
- let absBy = by.map(y => y + cursor.y);
- // Character check function
- function ct(x, y, t, c) {
- if (!Tile.exists(Math.floor(x/20)*20, Math.floor(y/10)*10)) return false;
- let tile = Tile.get(Math.floor(x/20)*20, Math.floor(y/10)*10);
- if (!tile.done) return false;
- let info = getCharInfoXY(x, y);
- let sum = info.color + info.deco*248 + info.deco.italic*124 + info.deco.underline*62 + info.deco.strike*31;
- return info.char === t && sum === c;
- }
- // Paste a run of the text, skipping existing characters
- function pasteRun(index = 0) {
- if (index >= atxt.length) {
- currentLoop++;
- if (currentLoop < maxLoops) {
- // Shift all x positions for the next run
- for (let i = 0; i < absBx.length; i++) absBx[i] += shiftAmount;
- // Schedule next run after a delay
- setTimeout(() => pasteRun(0), loopDelay);
- }
- return;
- }
- // Only write if the character is not already correct
- if (!ct(absBx[index], absBy[index], atxt[index], acol[index])) {
- writeCharAt(atxt[index], acol[index], absBx[index], absBy[index]);
- }
- // Next character in the run
- requestAnimationFrame(() => pasteRun(index + 1));
- }
- // Start looping autopaste
- pasteRun();
Advertisement
Add Comment
Please, Sign In to add comment