Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // --- CONFIGURATION ---
- const IS_WORD_MODE = true; // Set to true for words, false for single characters
- const RADIUS = 58;
- // Character Mode Settings
- const charsToFind = ['6', '7'];
- const charToReplaceWith = ' ';
- // Word Mode Settings
- const wordsToFind = ['test']; // Words to target (case-insensitive)
- const wordToReplaceWith = 'lolol'; // Must match length of target, or use spaces
- // Cursor coordinates
- const cx = Number(cursor.x);
- const cy = Number(cursor.y);
- // --- EXECUTION ---
- if (!IS_WORD_MODE) {
- // === SINGLE CHARACTER MODE ===
- for (let x = cx - RADIUS; x <= cx + RADIUS; x++) {
- for (let y = cy - RADIUS; y <= cy + RADIUS; y++) {
- const dx = x - cx;
- const dy = y - cy;
- if (dx * dx + dy * dy <= RADIUS * RADIUS) {
- const info = getCharInfoXY(x, y);
- if (charsToFind.includes(info.char) && !info.deco.bold) {
- writeCharAt(
- charToReplaceWith,
- prsFmt({ color: info.color, bold: false }),
- x,
- y
- );
- }
- }
- }
- }
- } else {
- // === WORD MODE ===
- // Scans line-by-line within the vertical radius bound
- for (let y = cy - RADIUS; y <= cy + RADIUS; y++) {
- // Reconstruct the text line across the horizontal radius bound
- let lineText = '';
- const startX = cx - RADIUS;
- const endX = cx + RADIUS;
- for (let x = startX; x <= endX; x++) {
- const dx = x - cx;
- const dy = y - cy;
- // Check if coordinate is within radius
- if (dx * dx + dy * dy <= RADIUS * RADIUS) {
- const info = getCharInfoXY(x, y);
- lineText += info.char || ' ';
- } else {
- lineText += ' '; // Placeholder for coordinates outside radius
- }
- }
- // Check for matching words in the reconstructed line
- wordsToFind.forEach((word) => {
- const lowerLine = lineText.toLowerCase();
- const lowerWord = word.toLowerCase();
- let matchIdx = lowerLine.indexOf(lowerWord);
- while (matchIdx !== -1) {
- // Replace each character of the found word
- for (let i = 0; i < word.length; i++) {
- const targetX = startX + matchIdx + i;
- const dx = targetX - cx;
- const dy = y - cy;
- // Ensure the character is within radius and not bold before replacing
- if (dx * dx + dy * dy <= RADIUS * RADIUS) {
- const info = getCharInfoXY(targetX, y);
- if (!info.deco.bold) {
- const replacementChar = wordToReplaceWith[i] || ' ';
- writeCharAt(
- replacementChar,
- prsFmt({ color: info.color, bold: false }),
- targetX,
- y
- );
- }
- }
- }
- // Check for next occurrence on the same line
- matchIdx = lowerLine.indexOf(lowerWord, matchIdx + 1);
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment