累计送礼: 0 个 累计收礼: 1 个 TA的每日心情 开心 2026-7-12 04:10
签到天数: 209 天
连续签到: 2 天
[LV.7]常住居民III
管理员
VIP
7
卡币
29925
OK点
16
推广点
0
同能卷
50
积分 38778
Simple and light plugin for MV to let the user take screenshots from the game.
This is a regular screenshot picture where everything on screen will be saved on the image. Different from OrangeMapShot that will only save the map.
Assign your desired screenshot key in the parameters and decide if you want to see a notification on screen or not when the screenshot is saved.
Screenshots will be saved in the screenshots folder at the root of the game directory. The folder will be created automatically.
By default the plugin stops working and display a warning when there are 999 images in the screenshots folder.
Name the file 808PrintScreen.js
Spoiler: Code
JavaScript: //============================================================================== // 808PrintScreen //============================================================================== // File: 808PrintScreen.js // v1.0 // 7th Sep 2024 //============================================================================== /*: * @plugindesc v1.0 Allows taking screenshots by pressing a specified key and saving them to the 'screenshots' folder. Optionally displays a notification on screen. * @author mugen808 * @param Screenshot Key * @desc The key to press for taking a screenshot. Default: F7 * @default F7 * @param Screenshot Notification * @type boolean * @desc Whether to display a screenshot notification on screen. Default: true * @default true * @help *============================================================================== * 808PrintScreen *============================================================================== * * This plugin enables taking screenshots of the game by pressing a specified * key. Screenshots are saved in a 'screenshots' folder in the game directory. * * -Available keys: * F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, A, B, C, D, E, F, G, H, * I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, * 7, 8, 9, Shift, Ctrl, Alt, Space, Enter, Escape, Left, Up, Right, Down, * PrintScreen. * * * By default, a notification will be displayed on the screen when a screenshot * is taken. This can be deactivate in the plugin parameters. * * The screenshot will still be logged in the console regardless of the * notification setting. * * -Parameters: * Screenshot Key: The key to press for taking a screenshot (default: F7). * * Screenshot Notification: Whether to display a notification on the screen * (default: true). * * *============================================================================== * Terms *============================================================================== * * Free to use. Redistribution not permitted. * *.............................................................................. */ (function() { const fs = require('fs'); const path = require('path'); const parameters = PluginManager.parameters('808PrintScreen'); const screenshotKey = parameters['Screenshot Key'] || 'F7'; const screenshotNotification = String(parameters['Screenshot Notification'] || 'false').toLowerCase() === 'true'; function getKeyCode(keyName) { const keyCodes = { 'F1': 112, 'F2': 113, 'F3': 114, 'F4': 115, 'F5': 116, 'F6': 117, 'F7': 118, 'F8': 119, 'F9': 120, 'F10': 121, 'F11': 122, 'F12': 123, 'A': 65, 'B': 66, 'C': 67, 'D': 68, 'E': 69, 'F': 70, 'G': 71, 'H': 72, 'I': 73, 'J': 74, 'K': 75, 'L': 76, 'M': 77, 'N': 78, 'O': 79, 'P': 80, 'Q': 81, 'R': 82, 'S': 83, 'T': 84, 'U': 85, 'V': 86, 'W': 87, 'X': 88, 'Y': 89, 'Z': 90, '0': 48, '1': 49, '2': 50, '3': 51, '4': 52, '5': 53, '6': 54, '7': 55, '8': 56, '9': 57, 'Shift': 16, 'Ctrl': 17, 'Alt': 18, 'Space': 32, 'Enter': 13, 'Escape': 27, 'Left': 37, 'Up': 38, 'Right': 39, 'Down': 40, 'PrintScreen': 44 }; return keyCodes[keyName] || null; } const keyCode = getKeyCode(screenshotKey); if (keyCode === null) { throw new Error(`Invalid key: ${screenshotKey}`); } Input.keyMapper[keyCode] = 'screenshot'; let screenshotQueue = []; let screenshotTimeout = null; function getNextFileName(dirPath) { for (let i = 1; i <= 999; i++) { // limit of screenshot files in the folder const fileName = `img${String(i).padStart(3, '0')}.png`; const filePath = path.join(dirPath, fileName); if (!fs.existsSync(filePath)) { return fileName; } } return null; // No available file names } function takeScreenshot() { const dirPath = path.join(process.cwd(), 'screenshots'); if (!fs.existsSync(dirPath)) { fs.mkdirSync(dirPath); } const fileName = getNextFileName(dirPath); if (!fileName) { console.error('Screenshot limit reached. Please delete some screenshots and try again.'); if (screenshotNotification) { displayScreenshotText('Screenshot limit reached. Please delete some screenshots and try again.'); } return; } const filePath = path.join(dirPath, fileName); const bitmap = Graphics._canvas.toDataURL('image/png').replace(/^data:image\/png;base64,/, ""); fs.writeFile(filePath, bitmap, 'base64', function(err) { if (err) { console.error('Failed to save screenshot:', err); } else { console.log('Screenshot saved as', fileName); if (screenshotNotification) { displayScreenshotText(fileName); } } }); } function displayScreenshotText(message) { const text = new PIXI.Text(`Screenshot ${message}`, { fontFamily: 'Arial', fontSize: 12, fill: 'white' }); text.x = Graphics.width - text.width - 10; text.y = 10 + screenshotQueue.length * 20; SceneManager._scene.addChild(text); screenshotQueue.push(text); setTimeout(() => { SceneManager._scene.removeChild(text); screenshotQueue.shift(); updateScreenshotQueue(); }, 2150); } function updateScreenshotQueue() { screenshotQueue.forEach((text, index) => { text.y = 10 + index * 20; }); } const alias_SceneManager_update = SceneManager.update; SceneManager.update = function() { alias_SceneManager_update.call(this); if (Input.isTriggered('screenshot')) { if (!screenshotTimeout) { takeScreenshot(); screenshotTimeout = setTimeout(() => { screenshotTimeout = null; }, 200); } } }; })(); 复制代码
本贴来自国际rpgmaker官方论坛作者:mugen808处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/808printscreen-mv.171735/
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x