Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async function() {
- const startX = -20;
- const startY = -10;
- const endX = 19;
- const endY = 9;
- const areaWidth = endX - startX + 1;
- const typingCooldown = 10;
- let isRunning = true;
- let safetyEnabled = true;
- let chatText = '';
- let chatX = 0;
- let chatY = 0;
- let chatTimeout = null;
- let cloudAnimationInterval = null;
- let dayNightInterval = null;
- // Day/Night cycle
- let isDay = true;
- const dayColor = 10;
- const nightColor = 12;
- const dayChar = '▒';
- const nightChar = '▒';
- const dayNightCycleDuration = 60000;
- // Correct chars list for version and coords
- let correctChars = [];
- // World position of square
- let squareWorldX = 0;
- let squareWorldY = 0;
- // Camera position
- let cameraWorldX = startX;
- // Terrain Y levels
- const grassY = 1;
- const dirtStartY = 2;
- const dirtEndY = 3;
- const stoneStartY = 4;
- const cloudEndY = -7;
- // Characters
- const grassChar = ',';
- const dirtChar = '.';
- const stoneChar = '#';
- const cloudChar = '~';
- // Colors
- const cloudColor = 0;
- const grassColor = 9;
- const dirtColor = 22;
- const stoneColor = 1;
- const defaultColor = 25;
- // Get current sky color and char based on day/night
- function getSkyColor() {
- return isDay ? dayColor : nightColor;
- }
- function getSkyChar() {
- return isDay ? dayChar : nightChar;
- }
- // Cloud data structure
- let clouds = [];
- // World border
- const worldBorderMinX = -500000;
- const worldBorderMaxX = 500000;
- // Input values for movement
- const inputx = 1;
- const inputy = 1;
- // Coordinate display position
- const coordDisplayX = startX;
- const coordDisplayY = startY;
- const versionDisplayY = startY + 1;
- const versionText = 'Square Area Testing 1.0.9';
- // Previous coordinate text
- let prevCoordText = '';
- let prevCoordTextLength = 0;
- // Helper function for cooldown
- function wait(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- // Build correct chars list for version text
- function buildVersionCorrectList() {
- for (let i = 0; i < versionText.length; i++) {
- let key = (coordDisplayX + i) + ',' + versionDisplayY;
- correctChars[key] = { char: versionText[i], color: defaultColor };
- }
- }
- // Build/update correct chars list for coord text
- function buildCoordCorrectList() {
- let coordText = 'square is at ' + squareWorldX + ', ' + (-squareWorldY);
- // Clear old coord entries first
- if (prevCoordTextLength > 0) {
- for (let i = 0; i < prevCoordTextLength; i++) {
- let key = (coordDisplayX + i) + ',' + coordDisplayY;
- delete correctChars[key];
- }
- }
- // Add new coord entries
- for (let i = 0; i < coordText.length; i++) {
- let key = (coordDisplayX + i) + ',' + coordDisplayY;
- correctChars[key] = { char: coordText[i], color: defaultColor };
- }
- prevCoordText = coordText;
- prevCoordTextLength = coordText.length;
- }
- // Check if position is in correct chars list
- function getCorrectChar(x, y) {
- let key = x + ',' + y;
- return correctChars[key] || null;
- }
- // Simple seeded random for consistent cloud generation
- function seededRandom(seed) {
- let x = Math.sin(seed * 12.9898 + 78.233) * 43758.5453;
- return x - Math.floor(x);
- }
- // Generate random clouds
- function generateClouds() {
- clouds = [];
- for (let y = startY; y <= cloudEndY; y++) {
- let x = startX;
- let seed = y * 1000 + currentCloudPattern * 100;
- while (x <= endX) {
- let rand = seededRandom(seed + x);
- if (rand < 0.35) {
- let length = Math.floor(seededRandom(seed + x + 1) * 4) + 3;
- if (x + length > endX + 1) {
- length = endX - x + 1;
- }
- if (length >= 3) {
- clouds.push({ x: x, y: y, length: length });
- }
- x += length + Math.floor(seededRandom(seed + x + 2) * 4) + 2;
- } else {
- x += 1;
- }
- }
- }
- }
- let currentCloudPattern = 0;
- // Get screen X from world X
- function worldToScreenX(worldX) {
- return worldX - cameraWorldX + startX;
- }
- // Get world X from screen X
- function screenToWorldX(screenX) {
- return screenX - startX + cameraWorldX;
- }
- // Get square screen position
- function getSquareScreenX() {
- return worldToScreenX(squareWorldX);
- }
- // Update camera to follow square
- function updateCamera() {
- let screenX = getSquareScreenX();
- let margin = 8;
- if (screenX < startX + margin) {
- cameraWorldX = squareWorldX - margin;
- } else if (screenX > endX - margin - 1) {
- cameraWorldX = squareWorldX - (areaWidth - margin - 2);
- }
- }
- // Terrain type checks
- function isCloudPosition(y) {
- return y >= startY && y <= cloudEndY;
- }
- function isGrassPosition(y) {
- return y === grassY;
- }
- function isDirtPosition(y) {
- return y >= dirtStartY && y <= dirtEndY;
- }
- function isStonePosition(y) {
- return y >= stoneStartY && y <= endY;
- }
- function isSkyPosition(y) {
- return y > cloudEndY && y < grassY;
- }
- // Check if screen position has a cloud
- function hasCloudAt(screenX, screenY) {
- for (let i = 0; i < clouds.length; i++) {
- let cloud = clouds[i];
- if (cloud.y === screenY && screenX >= cloud.x && screenX < cloud.x + cloud.length) {
- return true;
- }
- }
- return false;
- }
- // Get terrain info for a screen position
- function getTerrainInfo(screenX, y) {
- if (isCloudPosition(y)) {
- if (hasCloudAt(screenX, y)) {
- return { char: cloudChar, color: cloudColor, isSky: false };
- } else {
- return { char: getSkyChar(), color: getSkyColor(), isSky: true };
- }
- } else if (isSkyPosition(y)) {
- return { char: getSkyChar(), color: getSkyColor(), isSky: true };
- } else if (isGrassPosition(y)) {
- return { char: grassChar, color: grassColor, isSky: false };
- } else if (isDirtPosition(y)) {
- return { char: dirtChar, color: dirtColor, isSky: false };
- } else if (isStonePosition(y)) {
- return { char: stoneChar, color: stoneColor, isSky: false };
- } else {
- return { char: getSkyChar(), color: getSkyColor(), isSky: true };
- }
- }
- // Function to draw text at position
- async function drawText(x, y, text) {
- await w.changeColor(defaultColor);
- for (let i = 0; i < text.length; i++) {
- await w.tp(x + i, y);
- await w.typeChar(text[i], 1);
- await wait(typingCooldown);
- }
- }
- // Function to clear text at position with terrain
- async function clearTextWithTerrain(x, y, length) {
- for (let i = 0; i < length; i++) {
- let terrain = getTerrainInfo(x + i, y);
- await w.changeColor(terrain.color);
- await w.tp(x + i, y);
- await w.typeChar(terrain.char, 1);
- await wait(typingCooldown);
- }
- }
- // Function to draw sky with day/night
- async function drawSky() {
- let skyColor = getSkyColor();
- let skyChar = getSkyChar();
- let squareScreenX = getSquareScreenX();
- // Draw sky in cloud area
- for (let y = startY; y <= cloudEndY; y++) {
- for (let x = startX; x <= endX; x++) {
- // Skip UI elements
- if (getCorrectChar(x, y)) {
- continue;
- }
- if (y === squareWorldY && (x === squareScreenX || x === squareScreenX + 1)) {
- continue;
- }
- if (chatText.length > 0 && y === chatY && x >= chatX && x < chatX + chatText.length) {
- continue;
- }
- if (hasCloudAt(x, y)) {
- await w.changeColor(cloudColor);
- await w.tp(x, y);
- await w.typeChar(cloudChar, 1);
- } else {
- await w.changeColor(skyColor);
- await w.tp(x, y);
- await w.typeChar(skyChar, 1);
- }
- await wait(typingCooldown);
- }
- }
- // Draw air between clouds and grass
- for (let y = cloudEndY + 1; y < grassY; y++) {
- for (let x = startX; x <= endX; x++) {
- if (y === squareWorldY && (x === squareScreenX || x === squareScreenX + 1)) {
- continue;
- }
- if (chatText.length > 0 && y === chatY && x >= chatX && x < chatX + chatText.length) {
- continue;
- }
- await w.changeColor(skyColor);
- await w.tp(x, y);
- await w.typeChar(skyChar, 1);
- await wait(typingCooldown);
- }
- }
- await w.changeColor(defaultColor);
- }
- // Function to draw all clouds
- async function drawClouds() {
- generateClouds();
- await drawSky();
- }
- // Function to draw grass line
- async function drawGrass() {
- await w.changeColor(grassColor);
- let squareScreenX = getSquareScreenX();
- for (let x = startX; x <= endX; x++) {
- if (squareWorldY === grassY && (x === squareScreenX || x === squareScreenX + 1)) {
- continue;
- }
- await w.tp(x, grassY);
- await w.typeChar(grassChar, 1);
- await wait(typingCooldown);
- }
- await w.changeColor(defaultColor);
- }
- // Function to draw dirt
- async function drawDirt() {
- await w.changeColor(dirtColor);
- let squareScreenX = getSquareScreenX();
- for (let y = dirtStartY; y <= dirtEndY; y++) {
- for (let x = startX; x <= endX; x++) {
- if (squareWorldY === y && (x === squareScreenX || x === squareScreenX + 1)) {
- continue;
- }
- await w.tp(x, y);
- await w.typeChar(dirtChar, 1);
- await wait(typingCooldown);
- }
- }
- await w.changeColor(defaultColor);
- }
- // Function to draw stone
- async function drawStone() {
- await w.changeColor(stoneColor);
- let squareScreenX = getSquareScreenX();
- for (let y = stoneStartY; y <= endY; y++) {
- for (let x = startX; x <= endX; x++) {
- if (squareWorldY === y && (x === squareScreenX || x === squareScreenX + 1)) {
- continue;
- }
- await w.tp(x, y);
- await w.typeChar(stoneChar, 1);
- await wait(typingCooldown);
- }
- }
- await w.changeColor(defaultColor);
- }
- // Function to draw all terrain
- async function drawAllTerrain() {
- await drawClouds();
- await drawGrass();
- await drawDirt();
- await drawStone();
- }
- // Function to update coordinate display
- async function updateCoordDisplay() {
- let coordText = 'square is at ' + squareWorldX + ', ' + (-squareWorldY);
- // Clear old text with terrain if longer
- if (prevCoordTextLength > coordText.length) {
- await clearTextWithTerrain(coordDisplayX + coordText.length, coordDisplayY, prevCoordTextLength - coordText.length);
- }
- // Update correct list before drawing
- buildCoordCorrectList();
- await drawText(coordDisplayX, coordDisplayY, coordText);
- }
- // Function to draw version text
- async function drawVersionText() {
- buildVersionCorrectList();
- await drawText(coordDisplayX, versionDisplayY, versionText);
- }
- // Function to draw the square
- async function drawSquare() {
- let screenX = getSquareScreenX();
- await w.changeColor(defaultColor);
- await w.tp(screenX, squareWorldY);
- await w.typeChar('[', 1);
- await wait(typingCooldown);
- await w.typeChar(']', 1);
- await wait(typingCooldown);
- }
- // Function to clear the square
- async function clearSquare() {
- let screenX = getSquareScreenX();
- let y = squareWorldY;
- let terrain1 = getTerrainInfo(screenX, y);
- let terrain2 = getTerrainInfo(screenX + 1, y);
- await w.changeColor(terrain1.color);
- await w.tp(screenX, y);
- await w.typeChar(terrain1.char, 1);
- await wait(typingCooldown);
- await w.changeColor(terrain2.color);
- await w.tp(screenX + 1, y);
- await w.typeChar(terrain2.char, 1);
- await wait(typingCooldown);
- await w.changeColor(defaultColor);
- }
- // Function to clear chat text
- async function clearChatText() {
- if (chatText.length > 0) {
- let oldChatText = chatText;
- let oldChatX = chatX;
- let oldChatY = chatY;
- chatText = '';
- for (let i = 0; i < oldChatText.length; i++) {
- let currentX = oldChatX + i;
- let terrain = getTerrainInfo(currentX, oldChatY);
- await w.changeColor(terrain.color);
- await w.tp(currentX, oldChatY);
- await w.typeChar(terrain.char, 1);
- await wait(typingCooldown);
- }
- await w.changeColor(defaultColor);
- }
- }
- // Function to draw chat text
- async function drawChatText() {
- if (chatText.length > 0) {
- let screenX = getSquareScreenX();
- let squareMiddle = screenX + 0.5;
- let textHalfLength = Math.floor(chatText.length / 2);
- chatX = Math.round(squareMiddle - textHalfLength);
- chatY = squareWorldY - 1;
- await w.changeColor(defaultColor);
- for (let i = 0; i < chatText.length; i++) {
- await w.tp(chatX + i, chatY);
- await w.typeChar(chatText[i], 1);
- await wait(typingCooldown);
- }
- }
- }
- // Check if position is part of UI elements
- function isUIPosition(x, y) {
- let screenX = getSquareScreenX();
- if (y === squareWorldY && (x === screenX || x === screenX + 1)) {
- return true;
- }
- if (chatText.length > 0 && y === chatY && x >= chatX && x < chatX + chatText.length) {
- return true;
- }
- if (getCorrectChar(x, y)) {
- return true;
- }
- return false;
- }
- // Check if square brackets are missing or miscolored
- async function checkSquare() {
- if (!isRunning || !safetyEnabled) return;
- try {
- let screenX = getSquareScreenX();
- let leftBracket = await getCharInfoXY(screenX, squareWorldY);
- let rightBracket = await getCharInfoXY(screenX + 1, squareWorldY);
- let needRedraw = false;
- if (!leftBracket || leftBracket.char !== '[' || leftBracket.color !== defaultColor) {
- needRedraw = true;
- }
- if (!rightBracket || rightBracket.char !== ']' || rightBracket.color !== defaultColor) {
- needRedraw = true;
- }
- if (needRedraw) {
- await drawSquare();
- console.log('Square restored at (' + squareWorldX + ', ' + (-squareWorldY) + ')');
- }
- } catch (e) {
- console.log('checkSquare error:', e);
- }
- }
- // Check version and coord text using correct list
- async function checkCorrectChars() {
- if (!isRunning || !safetyEnabled) return;
- try {
- for (let key in correctChars) {
- if (!isRunning || !safetyEnabled) return;
- let parts = key.split(',');
- let x = parseInt(parts[0]);
- let y = parseInt(parts[1]);
- let expected = correctChars[key];
- let charInfo = await getCharInfoXY(x, y);
- if (!charInfo || charInfo.char !== expected.char || charInfo.color !== expected.color) {
- await w.changeColor(expected.color);
- await w.tp(x, y);
- await w.typeChar(expected.char, 1);
- await wait(typingCooldown);
- }
- }
- } catch (e) {
- console.log('checkCorrectChars error:', e);
- }
- }
- // Check terrain char and color
- async function checkTerrain() {
- if (!isRunning || !safetyEnabled) return;
- try {
- for (let y = startY; y <= endY; y++) {
- for (let x = startX; x <= endX; x++) {
- if (!isRunning || !safetyEnabled) return;
- // Skip UI elements
- if (isUIPosition(x, y)) {
- continue;
- }
- let terrain = getTerrainInfo(x, y);
- let charInfo = await getCharInfoXY(x, y);
- if (!charInfo) {
- await w.changeColor(terrain.color);
- await w.tp(x, y);
- await w.typeChar(terrain.char, 1);
- await wait(typingCooldown);
- continue;
- }
- // Check both char and color
- if (charInfo.char !== terrain.char || charInfo.color !== terrain.color) {
- await w.changeColor(terrain.color);
- await w.tp(x, y);
- await w.typeChar(terrain.char, 1);
- await wait(typingCooldown);
- }
- }
- }
- await w.changeColor(defaultColor);
- } catch (e) {
- console.log('checkTerrain error:', e);
- }
- }
- // Check chat text
- async function checkChatText() {
- if (!isRunning || !safetyEnabled) return;
- if (chatText.length === 0) return;
- try {
- for (let i = 0; i < chatText.length; i++) {
- if (!isRunning || !safetyEnabled) return;
- let charInfo = await getCharInfoXY(chatX + i, chatY);
- if (!charInfo || charInfo.char !== chatText[i] || charInfo.color !== defaultColor) {
- await w.changeColor(defaultColor);
- await w.tp(chatX + i, chatY);
- await w.typeChar(chatText[i], 1);
- await wait(typingCooldown);
- }
- }
- } catch (e) {
- console.log('checkChatText error:', e);
- }
- }
- // Animate clouds
- async function animateClouds() {
- if (!isRunning) return;
- currentCloudPattern = (currentCloudPattern + 1) % 1000;
- generateClouds();
- await drawSky();
- // Redraw UI on top
- await drawVersionText();
- await updateCoordDisplay();
- await drawSquare();
- if (chatText.length > 0) {
- await drawChatText();
- }
- console.log('Clouds animated');
- }
- // Day/Night cycle transition
- async function transitionDayNight() {
- if (!isRunning) return;
- isDay = !isDay;
- let timeOfDay = isDay ? 'Day' : 'Night';
- console.log('Time changed to: ' + timeOfDay);
- // Redraw sky with new color and char
- await drawSky();
- // Redraw UI on top
- await drawVersionText();
- await updateCoordDisplay();
- await drawSquare();
- if (chatText.length > 0) {
- await drawChatText();
- }
- }
- // Clear entire area with space detection
- async function clearArea() {
- await w.changeColor(defaultColor);
- for (let y = startY; y <= endY; y++) {
- for (let x = startX; x <= endX; x++) {
- try {
- let charInfo = await getCharInfoXY(x, y);
- if (charInfo && charInfo.char === ' ') {
- continue;
- }
- } catch (e) {}
- await w.tp(x, y);
- await w.typeChar(' ', 1);
- await wait(typingCooldown);
- }
- }
- }
- // Redraw entire view
- async function redrawView() {
- await drawAllTerrain();
- await drawVersionText();
- await updateCoordDisplay();
- await drawSquare();
- if (chatText.length > 0) {
- await drawChatText();
- }
- }
- // Initial area clear
- console.log('Clearing area...');
- await w.changeColor(defaultColor);
- for (let y = startY; y <= endY; y++) {
- for (let x = startX; x <= endX; x++) {
- try {
- let charInfo = await getCharInfoXY(x, y);
- if (charInfo && charInfo.char === ' ') {
- continue;
- }
- } catch (e) {}
- await w.tp(x, y);
- await w.typeChar(' ', 1);
- await wait(typingCooldown);
- }
- }
- console.log('Area cleared!');
- // Generate initial clouds
- generateClouds();
- // Draw clouds
- console.log('Drawing sky and clouds...');
- await drawClouds();
- console.log('Sky and clouds drawn!');
- // Draw grass line
- console.log('Drawing grass...');
- await drawGrass();
- console.log('Grass drawn!');
- // Draw dirt
- console.log('Drawing dirt...');
- await drawDirt();
- console.log('Dirt drawn!');
- // Draw stone
- console.log('Drawing stone...');
- await drawStone();
- console.log('Stone drawn!');
- // Draw version text
- await drawVersionText();
- console.log('Version text drawn!');
- // Initial coordinate display
- await updateCoordDisplay();
- console.log('Coord display drawn!');
- // Initial draw
- await drawSquare();
- console.log('Square drawn!');
- // Start monitoring loop
- async function monitorLoop() {
- while (isRunning) {
- if (safetyEnabled) {
- await checkSquare();
- await checkCorrectChars();
- await checkChatText();
- await checkTerrain();
- }
- await wait(500);
- }
- }
- // Start monitor in background
- setTimeout(function() {
- monitorLoop();
- }, 100);
- // Start cloud animation (every 25 seconds)
- cloudAnimationInterval = setInterval(function() {
- if (isRunning) {
- animateClouds();
- }
- }, 25000);
- // Start day/night cycle
- dayNightInterval = setInterval(function() {
- if (isRunning) {
- transitionDayNight();
- }
- }, dayNightCycleDuration);
- // Move right (d)
- window.moved = async function(amount) {
- if (!isRunning) return;
- let moveAmount = (typeof amount === 'number') ? amount : inputx;
- let oldCameraX = cameraWorldX;
- await clearChatText();
- await clearSquare();
- squareWorldX += moveAmount;
- if (squareWorldX > worldBorderMaxX - 1) {
- squareWorldX = worldBorderMaxX - 1;
- console.log('Hit world border at X = ' + worldBorderMaxX);
- }
- updateCamera();
- buildCoordCorrectList();
- if (cameraWorldX !== oldCameraX) {
- await redrawView();
- } else {
- await drawSquare();
- await drawChatText();
- await updateCoordDisplay();
- }
- console.log('Square position: (' + squareWorldX + ', ' + (-squareWorldY) + ')');
- };
- // Move left (a)
- window.movea = async function(amount) {
- if (!isRunning) return;
- let moveAmount = (typeof amount === 'number') ? amount : inputx;
- let oldCameraX = cameraWorldX;
- await clearChatText();
- await clearSquare();
- squareWorldX -= moveAmount;
- if (squareWorldX < worldBorderMinX) {
- squareWorldX = worldBorderMinX;
- console.log('Hit world border at X = ' + worldBorderMinX);
- }
- updateCamera();
- buildCoordCorrectList();
- if (cameraWorldX !== oldCameraX) {
- await redrawView();
- } else {
- await drawSquare();
- await drawChatText();
- await updateCoordDisplay();
- }
- console.log('Square position: (' + squareWorldX + ', ' + (-squareWorldY) + ')');
- };
- // Move up (w)
- window.movew = async function(amount) {
- if (!isRunning) return;
- let moveAmount = (typeof amount === 'number') ? amount : inputy;
- await clearChatText();
- await clearSquare();
- squareWorldY -= moveAmount;
- if (squareWorldY < startY) squareWorldY = startY;
- buildCoordCorrectList();
- await drawSquare();
- await drawChatText();
- await updateCoordDisplay();
- console.log('Square position: (' + squareWorldX + ', ' + (-squareWorldY) + ')');
- };
- // Move down (s)
- window.moves = async function(amount) {
- if (!isRunning) return;
- let moveAmount = (typeof amount === 'number') ? amount : inputy;
- await clearChatText();
- await clearSquare();
- squareWorldY += moveAmount;
- if (squareWorldY > endY) squareWorldY = endY;
- buildCoordCorrectList();
- await drawSquare();
- await drawChatText();
- await updateCoordDisplay();
- console.log('Square position: (' + squareWorldX + ', ' + (-squareWorldY) + ')');
- };
- // Teleport square to specific world coordinates
- window.squaretake = async function(worldX, worldY) {
- if (!isRunning) return;
- if (typeof worldX !== 'number' || typeof worldY !== 'number') {
- console.log('Usage: squaretake(worldX, worldY)');
- return;
- }
- await clearChatText();
- await clearSquare();
- squareWorldX = worldX;
- squareWorldY = -worldY;
- if (squareWorldX < worldBorderMinX) {
- squareWorldX = worldBorderMinX;
- console.log('Clamped to world border at X = ' + worldBorderMinX);
- }
- if (squareWorldX > worldBorderMaxX - 1) {
- squareWorldX = worldBorderMaxX - 1;
- console.log('Clamped to world border at X = ' + worldBorderMaxX);
- }
- if (squareWorldY < startY) {
- squareWorldY = startY;
- console.log('Clamped to Y boundary');
- }
- if (squareWorldY > endY) {
- squareWorldY = endY;
- console.log('Clamped to Y boundary');
- }
- updateCamera();
- buildCoordCorrectList();
- await redrawView();
- console.log('Square teleported to (' + squareWorldX + ', ' + (-squareWorldY) + ')');
- };
- // Chat function
- window.chat = async function(text) {
- if (!isRunning) return;
- if (chatTimeout) {
- clearTimeout(chatTimeout);
- chatTimeout = null;
- }
- await clearChatText();
- chatText = text || '';
- if (chatText.length > 0) {
- await drawChatText();
- console.log('Chat: "' + chatText + '" at (' + chatX + ', ' + (-chatY) + ')');
- chatTimeout = setTimeout(async function() {
- if (isRunning) {
- await clearChatText();
- console.log('Chat cleared (timeout)');
- }
- }, 6000);
- } else {
- console.log('Chat cleared');
- }
- };
- // Disable safety function
- window.disablesafety = async function() {
- safetyEnabled = false;
- await w.chat.send('Safety DISABLED - char detection OFF');
- console.log('Safety disabled - char detection is now OFF');
- };
- // Enable safety function
- window.enablesafety = async function() {
- safetyEnabled = true;
- await w.chat.send('Safety ENABLED - char detection ON');
- console.log('Safety enabled - char detection is now ON');
- };
- // Quit function
- window.quit = async function() {
- isRunning = false;
- if (chatTimeout) {
- clearTimeout(chatTimeout);
- chatTimeout = null;
- }
- if (cloudAnimationInterval) {
- clearInterval(cloudAnimationInterval);
- cloudAnimationInterval = null;
- }
- if (dayNightInterval) {
- clearInterval(dayNightInterval);
- dayNightInterval = null;
- }
- console.log('Clearing area for shutdown...');
- await clearArea();
- let shutdownText = 'SCRIPT SHUTDOWN.';
- let centerX = Math.floor((startX + endX) / 2) - Math.floor(shutdownText.length / 2);
- let centerY = Math.floor((startY + endY) / 2);
- await w.changeColor(defaultColor);
- for (let i = 0; i < shutdownText.length; i++) {
- await w.tp(centerX + i, centerY);
- await w.typeChar(shutdownText[i], 1);
- await wait(typingCooldown);
- }
- await w.chat.send('Script Shutdown');
- console.log('Script Shutdown');
- delete window.movew;
- delete window.movea;
- delete window.moves;
- delete window.moved;
- delete window.chat;
- delete window.quit;
- delete window.disablesafety;
- delete window.enablesafety;
- delete window.squaretake;
- };
- console.log('Controls ready!');
- console.log('Use: movew(n), movea(n), moves(n), moved(n) - n is optional move amount');
- console.log('Use: squaretake(worldX, worldY) - teleport square to world coordinates');
- console.log('Use: chat("your message") - displays text above square for 6 seconds');
- console.log('Use: disablesafety() - disables char detection');
- console.log('Use: enablesafety() - enables char detection');
- console.log('Use: quit() - clears area and stops script');
- console.log('World border: X = ' + worldBorderMinX + ' to ' + worldBorderMaxX);
- console.log('Day/Night cycle: ' + (dayNightCycleDuration / 1000) + ' seconds per cycle');
- console.log('Square starts at (' + squareWorldX + ', ' + (-squareWorldY) + ')');
- })();
Advertisement
Add Comment
Please, Sign In to add comment