Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async () => {
- // --- Typing helpers ---
- // With 25ms cooldown per char (for status messages)
- async function typeStringSlow(str) {
- for (let i = 0; i < str.length; i++) {
- await w.typeChar(str[i], 1);
- await new Promise(r => setTimeout(r, 25));
- }
- }
- // No cooldown (for val number output)
- async function typeStringFast(str) {
- for (let i = 0; i < str.length; i++) {
- await w.typeChar(str[i], 1);
- }
- }
- // --- MODE & SOURCES ---
- let mode = 1; // 1 = Break Infinity (default), 2 = Break Eternity
- const sources = {
- 1: [
- "https://unpkg.com/[email protected]/dist/break_infinity.min.js",
- "https://cdn.jsdelivr.net/npm/break_infinity.js/dist/break_infinity.min.js",
- "https://unpkg.com/[email protected]/dist/break_infinity.min.js"
- ],
- 2: [
- "https://unpkg.com/[email protected]/dist/break_eternity.min.js",
- "https://cdn.jsdelivr.net/npm/break_eternity.js/dist/break_eternity.min.js"
- ]
- };
- // Fallback Decimal
- function createFallbackDecimal() {
- class FallbackDecimal {
- constructor(value) {
- if (value instanceof FallbackDecimal) {
- this.value = value.value;
- } else {
- const n = Number(value);
- if (!Number.isFinite(n)) throw new Error("Invalid Decimal value");
- this.value = n;
- }
- }
- times(other) {
- const o = other instanceof FallbackDecimal ? other.value : Number(other);
- return new FallbackDecimal(this.value * o);
- }
- lte(other) {
- const o = other instanceof FallbackDecimal ? other.value : Number(other);
- return this.value <= o;
- }
- lt(other) {
- const o = other instanceof FallbackDecimal ? other.value : Number(other);
- return this.value < o;
- }
- toString() {
- return String(this.value);
- }
- get e() {
- if (this.value === 0) return 0;
- return Math.floor(Math.log10(Math.abs(this.value)));
- }
- get mantissa() {
- if (this.value === 0) return 0;
- return this.value / Math.pow(10, this.e);
- }
- }
- return FallbackDecimal;
- }
- // flag used to pause the main loop while status messages print
- let statusBusy = false;
- async function printStatus(msg, x, y, width = 80) {
- statusBusy = true;
- await w.tp(x, y);
- await typeStringSlow(" ".repeat(width));
- await w.tp(x, y);
- await typeStringSlow(msg);
- statusBusy = false;
- }
- async function ensureDecimalForMode(currentMode) {
- const statusX = -99;
- const statusY = 3;
- if (typeof Decimal !== "undefined") return true;
- const list = sources[currentMode] || [];
- for (let i = 0; i < list.length; i++) {
- const src = list[i];
- await printStatus(`Loading: ${src}`, statusX, statusY);
- try {
- await new Promise((resolve, reject) => {
- const s = document.createElement("script");
- s.src = src;
- s.async = true;
- s.onload = () => resolve();
- s.onerror = () => reject(new Error("Failed: " + src));
- document.head.appendChild(s);
- });
- if (typeof Decimal !== "undefined") {
- w.chat.send(`Loaded from: ${src}`);
- return true;
- } else {
- console.warn("Script loaded but Decimal is undefined for", src);
- await printStatus("Link load failure, trying next one", statusX, statusY);
- }
- } catch (e) {
- console.warn(e);
- await printStatus("Link load failure, trying next one", statusX, statusY);
- }
- }
- if (typeof Decimal === "undefined") {
- await printStatus("All links failure, using fallback.", statusX, statusY);
- console.warn("All links failed. Using fallback Decimal.");
- window.Decimal = createFallbackDecimal();
- return true;
- }
- return false;
- }
- const initialOk = await ensureDecimalForMode(mode);
- if (!initialOk) {
- w.chat.send("Initial library load failure; using fallback.");
- }
- // --- CONFIG ---
- const startX = -99;
- const startY = 4;
- const endX = -81;
- const START_VAL_NUM = 2;
- // --- STATE ---
- let val = new Decimal(START_VAL_NUM);
- let multiplier = new Decimal(1.2); // effective multiplier used by loop
- let baseMultiplier = new Decimal(1.2); // base multiplier (set via setM)
- let exMode = false; // setEX toggle: if ON, multiply by 1.5 each print
- let intervalMs = 450;
- let lastSendValTime = 0;
- let loopStarted = false;
- let ended = false;
- const sleep = ms => new Promise(r => setTimeout(r, ms));
- function parseFiniteNumber(input, contextName, paramName) {
- const n = Number(input);
- if (!Number.isFinite(n)) {
- console.error(
- `${contextName} error: ${paramName} must be a finite number (not Infinity, -Infinity, NaN, or invalid).`
- );
- return null;
- }
- return n;
- }
- // Custom formatting (unchanged logic)
- function formatVal(d) {
- if (d.lte(999999)) return d.toString();
- const e = d.e;
- const threshold1Exp = 999999;
- const threshold2ExpApprox = 1e7;
- if (e <= threshold1Exp) {
- const m = d.mantissa;
- return `${m.toFixed(2)} * 10^${e}`;
- }
- if (e > threshold1Exp && e <= threshold2ExpApprox) {
- const m = d.mantissa;
- const eStr = String(e);
- const splitIndex = Math.max(1, Math.floor(eStr.length / 2));
- const part1 = Number(eStr.slice(0, splitIndex));
- const part2 = Number(eStr.slice(splitIndex));
- const Y = isNaN(part1) ? e : part1;
- const Z = isNaN(part2) ? 0 : part2;
- return `${m.toFixed(2)} * 10^${Y.toFixed(2)} * 10^${Z}`;
- }
- let heightEstimate;
- try {
- const log10 = d.log10 ? d.log10() : new Decimal(Math.log10(Number(d.toString())));
- const log10_2 = log10.log10 ? log10.log10() : new Decimal(Math.log10(Number(log10.toString())));
- heightEstimate = Number(log10_2.toString());
- } catch {
- heightEstimate = 10;
- }
- return `10^^${heightEstimate.toFixed(2)}`;
- }
- async function printVal() {
- await w.tp(startX, startY);
- const spacesCount = Math.max(0, endX - startX);
- await typeStringFast(" ".repeat(spacesCount)); // clear fast
- await w.tp(startX, startY);
- const text = formatVal(val);
- await typeStringFast(text); // print val fast (no cooldown)
- }
- async function loop() {
- if (loopStarted) return;
- loopStarted = true;
- while (!ended) {
- // Wait if a status message is printing
- while (statusBusy && !ended) {
- await sleep(25);
- }
- if (ended) break;
- // main update
- val = val.times(multiplier);
- await printVal();
- // multi2 behavior: if exMode is ON, multiply multiplier by 1.5
- if (exMode) {
- multiplier = multiplier.times(new Decimal(1.5));
- }
- await sleep(intervalMs);
- }
- }
- await w.tp(startX, startY);
- await printVal();
- loop();
- w.chat.send("Number multiplier script started (mode 1: Break Infinity / fallback).");
- // --- Console commands ---
- // restart: reset value only
- window.restart = () => {
- try {
- val = new Decimal(START_VAL_NUM);
- console.log("Value restarted to:", val.toString());
- } catch (e) {
- console.error("restart error: could not set starting value.", e);
- }
- };
- // end: stop main loop
- window.end = () => {
- ended = true;
- console.log("Script ended (loop stopped).");
- };
- // setM(number, exponent?)
- window.setM = (number, exponent) => {
- const n = parseFiniteNumber(number, "setM", "number");
- if (n === null) return;
- try {
- let dec = new Decimal(n);
- if (typeof exponent !== "undefined") {
- const eNum = parseFiniteNumber(exponent, "setM", "exponent");
- if (eNum === null) return;
- const pow = new Decimal(10).pow(new Decimal(eNum)); // avoid JS Infinity
- dec = dec.times(pow);
- }
- if (dec.lte(0)) {
- console.error("setM error: multiplier must be > 0.");
- return;
- }
- baseMultiplier = dec;
- multiplier = new Decimal(baseMultiplier); // reset effective to base (multi2 will grow it)
- console.log("Base multiplier set to:", baseMultiplier.toString(), "| Effective:", multiplier.toString());
- } catch (e) {
- console.error("setM error: could not create Decimal.", e);
- }
- };
- // setV(number, exponent?)
- window.setV = (number, exponent) => {
- const n = parseFiniteNumber(number, "setV", "number");
- if (n === null) return;
- try {
- let dec = new Decimal(n);
- if (typeof exponent !== "undefined") {
- const eNum = parseFiniteNumber(exponent, "setV", "exponent");
- if (eNum === null) return;
- const pow = new Decimal(10).pow(new Decimal(eNum)); // avoid JS Infinity
- dec = dec.times(pow);
- }
- if (dec.lt(0)) {
- console.error("setV error: value must be >= 0.");
- return;
- }
- val = dec;
- console.log("Value set to:", val.toString());
- } catch (e) {
- console.error("setV error: could not create Decimal.", e);
- }
- };
- // setEX: toggle multi2 behavior
- // if true: multiplier multiplied by 1.5 after each val print
- // if false: multiplier stays as-is (no extra growth)
- window.setEX = on => {
- exMode = Boolean(on);
- console.log(
- `setEX: ${exMode ? "ON (multiplier grows x1.5 each print)" : "OFF (multiplier stays constant)"}`,
- "| Current effective multiplier:", multiplier.toString()
- );
- };
- // sendval: send current value to chat (450ms cooldown)
- window.sendval = () => {
- const now = Date.now();
- if (now - lastSendValTime < 450) {
- console.warn("sendval is on cooldown (450ms).");
- return;
- }
- lastSendValTime = now;
- w.chat.send(`Current val: ${formatVal(val)}`);
- };
- // setMode: switch between Break Infinity and Break Eternity
- window.setMode = async newMode => {
- const n = Number(newMode);
- if (n !== 1 && n !== 2) {
- console.error("setMode error: mode must be 1 (Break Infinity) or 2 (Break Eternity).");
- return;
- }
- const modeName = n === 1 ? "Break Infinity" : "Break Eternity";
- w.chat.send(`Switching to ${modeName}...`);
- try {
- delete window.Decimal;
- const ok = await ensureDecimalForMode(n);
- if (ok && typeof Decimal !== "undefined") {
- mode = n;
- w.chat.send("Switched successfully.");
- } else {
- w.chat.send("Failure.");
- }
- } catch (e) {
- console.error("setMode error:", e);
- w.chat.send("Failure.");
- }
- };
- // help: list commands
- window.help = () => {
- console.log("Available commands:");
- console.log(" restart() - set val back to 2 (starting number)");
- console.log(" end() - stop the script (no more updates)");
- console.log(" setM(n[, e]) - set base multiplier to n * 10^e (if e given) or n");
- console.log(" setV(n[, e]) - set val to n * 10^e (if e given) or n");
- console.log(" setEX(true/false) - toggle multi2: multiplier *= 1.5 after each print");
- console.log(" sendval() - send current val to chat (450ms cooldown)");
- console.log(" setMode(1 | 2) - 1: Break Infinity (default), 2: Break Eternity");
- console.log(" help() - show this command list");
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment