GeoFS Mod Menu -cool-

Mod Menu for GeoFS flight model variables using console-modifiable input fields

目前為 2025-08-02 提交的版本,檢視 最新版本

// ==UserScript==
// @name         GeoFS Mod Menu -cool-
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Mod Menu for GeoFS flight model variables using console-modifiable input fields
// @author       Jasp
// @match        https://www.geo-fs.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const categories = {
        "Engine": ["MAXrpm", "minRPM", "starterRPM", "idleThrottle", "fuelFlow", "enginePower", "brakeRPM"],
        "Aerodynamics": ["wingArea", "dragFactor", "liftFactor", "CD0", "CLmax", "elevatorFactor", "rudderFactor", "aileronFactor"],
        "Flight Model": ["mass", "emptyWeight", "maxWeight", "inertia", "pitchMoment", "yawMoment", "rollMoment"],
        "Landing Gear": ["gearDrag", "gearCompression", "gearLength"],
    };

    const menuStyle = `
        #geofsModMenu {
            position: fixed;
            top: 50px;
            right: 20px;
            background: rgba(0,0,0,0.85);
            color: white;
            padding: 15px;
            border-radius: 10px;
            z-index: 9999;
            max-height: 90vh;
            overflow-y: auto;
            font-family: sans-serif;
            font-size: 14px;
            display: none;
        }
        #geofsModMenu h2 {
            font-size: 16px;
            margin-top: 10px;
            border-bottom: 1px solid #ccc;
        }
        #geofsModMenu input {
            width: 80px;
            margin: 2px 0 10px 0;
            background: #222;
            color: white;
            border: 1px solid #555;
            padding: 3px;
        }
    `;

    const styleTag = document.createElement("style");
    styleTag.innerHTML = menuStyle;
    document.head.appendChild(styleTag);

    const menu = document.createElement("div");
    menu.id = "geofsModMenu";

    for (const [category, vars] of Object.entries(categories)) {
        const header = document.createElement("h2");
        header.textContent = category;
        menu.appendChild(header);

        vars.forEach(variable => {
            const label = document.createElement("label");
            label.textContent = variable + ": ";
            const input = document.createElement("input");
            input.type = "number";
            input.step = "any";
            input.placeholder = variable;
            input.onchange = function () {
                try {
                    if (geofs && geofs.aircraft && geofs.aircraft.instance && geofs.aircraft.instance.flightModel) {
                        const model = geofs.aircraft.instance.flightModel;
                        if (variable in model) {
                            model[variable] = parseFloat(this.value);
                            console.log(`[MOD MENU] Set ${variable} to ${this.value}`);
                        } else {
                            console.warn(`[MOD MENU] ${variable} not found in flightModel.`);
                        }
                    }
                } catch (err) {
                    console.error("GeoFS mod menu error:", err);
                }
            };
            label.appendChild(input);
            menu.appendChild(label);
            menu.appendChild(document.createElement("br"));
        });
    }

    document.body.appendChild(menu);

    // Toggle menu with '#'
    document.addEventListener("keydown", function (e) {
        if (e.key === "#") {
            menu.style.display = (menu.style.display === "none") ? "block" : "none";
        }
    });

    console.log("[GeoFS Mod Menu] Loaded. Press '#' to toggle.");
})();