Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async function() {
- w.chat.send("WordiBot v1.1.5 online!, head to 10000, 5000 for to see Wordle game.");
- let gameAnswer = "";
- let gameAttempts = 0;
- let wordLength = 0;
- const startX = 10000;
- const startY = -5000;
- let guessBarPositions = [];
- let gameActive = false;
- let attemptsCurrent = 0;
- let startTime = Date.now();
- let isChecking = false;
- let timerInterval = null;
- const delay = () => new Promise(r => setTimeout(r, 10));
- const tpDelay = () => new Promise(r => setTimeout(r, 250));
- const initDelay = () => new Promise(r => setTimeout(r, 1500));
- const safeGetCharInfo = (x, y) => {
- try {
- if (typeof getCharInfoXY === 'function') {
- let info = getCharInfoXY(x, y);
- if (info && typeof info === 'object') return info;
- }
- } catch (e) {}
- return null;
- };
- const getAttemptsColor = (left) => {
- if (left >= 7) return 20;
- if (left === 6) return 12;
- if (left === 5) return 11;
- if (left === 4) return 9;
- if (left === 3) return 7;
- if (left === 2) return 5;
- if (left === 1) return 1;
- return 30;
- };
- const getElapsed = () => {
- let diff = Date.now() - startTime;
- let ms = diff % 1000;
- let s = Math.floor(diff / 1000) % 60;
- let m = Math.floor(diff / 60000);
- return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}.${String(ms).padStart(3, '0')}`;
- };
- const typeText = async (text) => {
- for (let i = 0; i < text.length; i++) {
- w.typeChar(text[i], 1);
- await delay();
- }
- };
- const clearLine = async (len) => {
- for (let i = 0; i < len; i++) {
- w.typeChar(' ', 1);
- await delay();
- }
- };
- const updateAttemptsDisplay = async () => {
- let displayX = startX + wordLength + 3;
- let left = gameAttempts - attemptsCurrent;
- w.tp(displayX, startY);
- await tpDelay();
- w.changeColor(getAttemptsColor(left));
- await delay();
- await clearLine(30);
- w.tp(displayX, startY);
- await tpDelay();
- await typeText(`⚡ Attempts: ${attemptsCurrent}/${gameAttempts} (${left} left)`);
- };
- const updateTimeDisplay = async () => {
- let displayX = startX + wordLength + 3;
- w.tp(displayX, startY + 2);
- await tpDelay();
- w.changeColor(2);
- await delay();
- await clearLine(30);
- w.tp(displayX, startY + 2);
- await tpDelay();
- await typeText(`⏱ ${getElapsed()}`);
- };
- const startTimer = () => {
- if (timerInterval) clearInterval(timerInterval);
- timerInterval = setInterval(async () => {
- if (gameActive && !isChecking) {
- await updateTimeDisplay();
- }
- }, 500);
- };
- const stopTimer = () => {
- if (timerInterval) {
- clearInterval(timerInterval);
- timerInterval = null;
- }
- };
- window.clear = async function() {
- if (!gameActive) throw new Error("No active game to clear!");
- for (let row = 0; row < guessBarPositions.length; row++) {
- let pos = guessBarPositions[row];
- w.tp(pos.x, pos.y);
- await tpDelay();
- w.changeColor(1);
- await delay();
- for (let col = 0; col < wordLength; col++) {
- w.typeChar('_', 1);
- await delay();
- }
- }
- attemptsCurrent = 0;
- startTime = Date.now();
- await updateAttemptsDisplay();
- await updateTimeDisplay();
- w.tp(startX, startY);
- await tpDelay();
- };
- window.wordi = async function(answer, attempts) {
- if (answer === undefined || attempts === undefined) {
- throw new Error("Both 'answer' and 'attempts' parameters are required!");
- }
- stopTimer();
- gameAnswer = String(answer).toUpperCase();
- gameAttempts = Number(attempts);
- wordLength = gameAnswer.length;
- guessBarPositions = [];
- gameActive = true;
- attemptsCurrent = 0;
- startTime = Date.now();
- w.tp(startX, startY);
- await initDelay();
- w.tp(startX, startY - 2);
- await tpDelay();
- w.changeColor(9);
- await delay();
- await typeText(`✦ W O R D L E ✦`);
- w.tp(startX, startY - 1);
- await tpDelay();
- w.changeColor(7);
- await delay();
- await typeText(`═`.repeat(wordLength));
- let currentY = startY;
- for (let row = 0; row < gameAttempts; row++) {
- guessBarPositions.push({ x: startX, y: currentY });
- w.tp(startX, currentY);
- await tpDelay();
- w.changeColor(1);
- await delay();
- for (let col = 0; col < wordLength; col++) {
- w.typeChar('_', 1);
- await delay();
- }
- currentY += 2;
- }
- w.tp(startX, startY + gameAttempts * 2);
- await tpDelay();
- w.changeColor(7);
- await delay();
- await typeText(`═`.repeat(wordLength));
- await updateAttemptsDisplay();
- await updateTimeDisplay();
- startTimer();
- w.tp(startX, startY);
- await tpDelay();
- console.log("=== Game Board Ready ===");
- console.log(`Word: ${wordLength} letters | Attempts: ${gameAttempts}`);
- };
- window.check = async function() {
- if (!gameActive) throw new Error("No active game! Use wordi('answer', attempts) to start.");
- isChecking = true;
- let gameWon = false;
- attemptsCurrent = 0;
- for (let attempt = 0; attempt < gameAttempts; attempt++) {
- let pos = guessBarPositions[attempt];
- if (!pos) continue;
- let guess = "";
- for (let i = 0; i < wordLength; i++) {
- let charInfo = safeGetCharInfo(pos.x + i, pos.y);
- if (!charInfo || charInfo.char === ' ') { guess += '_'; continue; }
- guess += (charInfo.char && charInfo.char !== '_') ? String(charInfo.char).toUpperCase() : '_';
- }
- if (guess.includes('_') || guess.length !== wordLength) continue;
- attemptsCurrent++;
- let allCorrect = true;
- w.tp(pos.x, pos.y);
- await tpDelay();
- for (let i = 0; i < wordLength; i++) {
- let guessChar = guess[i];
- let answerChar = gameAnswer[i];
- if (!guessChar) continue;
- if (guessChar === answerChar) {
- w.changeColor(9);
- } else if (gameAnswer.includes(guessChar)) {
- w.changeColor(7);
- allCorrect = false;
- } else {
- w.changeColor(1);
- allCorrect = false;
- }
- await delay();
- w.typeChar(guessChar, 1);
- await delay();
- }
- await updateAttemptsDisplay();
- if (allCorrect) { gameWon = true; break; }
- }
- if (gameWon) {
- w.chat.send("You found the answer");
- gameActive = false;
- stopTimer();
- } else if (attemptsCurrent >= gameAttempts) {
- w.chat.send("You lost! (answer is " + gameAnswer + ")");
- gameActive = false;
- stopTimer();
- } else {
- console.log(`${attemptsCurrent}/${gameAttempts} attempts used.`);
- }
- isChecking = false;
- };
- console.log("=== WordiBot v1.1.5 Loaded ===");
- console.log("wordi('answer', attempts) | check() | clear()");
- })();
Advertisement
Add Comment
Please, Sign In to add comment