Laser Shooter Mod

Allows the player to shoot lasers with a time limit

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Laser Shooter Mod
// @description  Allows the player to shoot lasers with a time limit
// @match        *://*/*
// @version 0.0.1.20230814222938
// @namespace https://greasyfork.org/users/1151605
// ==/UserScript==

(function() {
    'use strict';

    const TIME_LIMIT = 60; // Time limit in seconds
    let remainingTime = TIME_LIMIT;
    let isShooting = false;

    console.log("Hold 'O' to shoot lasers!");

    function startShootingLasersOnHold() {
        document.addEventListener('keydown', function(event) {
            if (event.key === 'o' || event.key === 'O') {
                isShooting = true;
                console.log("Shooting lasers!");
            }
        });

        document.addEventListener('keyup', function(event) {
            if (event.key === 'o' || event.key === 'O') {
                isShooting = false;
                console.log("Stopped shooting lasers!");
            }
        });
    }

    function stopShootingLasers() {
        console.log("Time's up! Stop shooting lasers!");
        isShooting = false;
    }

    // Call this function when the player dies
    function playerDied() {
        console.log("Player died! Cannot shoot lasers anymore.");
    }

    // Start shooting lasers when holding 'O'
    startShootingLasersOnHold();

    // Run the game for the specified time limit
    setTimeout(function() {
        stopShootingLasers();
    }, TIME_LIMIT * 1000);

})();