设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 83|回复: 0

[转载发布] Expression Spy

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    5778

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    25563
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    32235

    灌水之王

    发表于 昨天 10:54 | 显示全部楼层 |阅读模式
    Expression Spy 1.1
            Drykul
    Introduction
            While developing I thought it would be useful to be able to view variables, switches, and other custom expressions, variables, arrays, etc in real time as opposed to needing to pause gameplay through the console. Thus I set out to create a plug-in to do just this.

    Features


            A dedicated window will open and keep you informed of what the monitored values are. Add as many as you'd like separated by commas in the plug-in parameters.



    Screenshots




    How to Use


            Simply set the built in game variables you'd like to monitor separated by commas. The same with game switches. And lastly, enter any expression you'd like to monitor as well.

    Demo
            No demo. If requested I will upload one.

    Script
             

    Spoiler//=============================================================================
    // ExpressionSpy.js v1.1
    //=============================================================================

    /*:
    * @plugindesc Updates selected expressions in real time in a separate window.
    * <id:Expression Spy>
    * @author Drykul
    *
    * @param Game Variables
    * @desc The $gameVariables to be monitored.                          Ex: 1, 2, 5, 15
    * @default
    *
    * @param Game Switches
    * @desc The $gameSwitches to be monitored.                           Ex: 1, 2, 5, 15
    * @default
    *
    * @param Custom Expressions
    * @desc Custom expressions to be monitored.                          Ex: $gameActors.actor(1).hp, myCustomVar, 1 + 2
    * @default
    *
    * @help
    * The custom expression field can be literally any expression you'd like to
    * monitor, including any calculations. Entries such as
    * $gameActors.actor(1).hp + $gameVariables.value(1)
    * will be accepted and evaluated.
    *
    * If you have any bugs to report, requests, or questions you can contact me
    * at drykul(at)cloud9studios.net. I'm also on www.rpgmakerweb.com and
    * www.rpgmakervxace.net as shaynec1981 as well as www.rpgmakermv.co as drykul.
    *
    * No credit is necessary for use of this script in either free
    * or commercial projects. Just shoot me a line and let me know if it was
    * worth your time!

    *
    * /~~CHANGE LOG~~/
    * 3-23-16: 1.1 release - changed update to Game_Screen
    *                      - fixed multiple expression spy windows being open at once
    *                      - expression spy window now won't open if no variables,
    *                        switches, or expressions are specified
    *
    * 3-22-16: 1.0 release
    */

    ////// Main function
    function expressionSpy() {
        if (typeof Scene_Map.prototype.expressionSpyWindow != 'undefined' && typeof Scene_Map.prototype.expressionSpyWindow.document != 'undefined') {
            Scene_Map.prototype.expressionSpyWindow.document.open();
            if (esVariablesArray[0] != "") {
                for (i = 0; i < esVariablesArray.length; i++) {
                    Scene_Map.prototype.expressionSpyWindow.document.write("$gameVariables[" + esVariablesArray + "] = " + $gameVariables.value(esVariablesArray) + "<br>");
                };
                Scene_Map.prototype.expressionSpyWindow.document.write("---------------------------------------------------------------" + "<br>");
            };
            if (esSwitchesArray[0] != "") {
                for (i = 0; i < esSwitchesArray.length; i++) {
                    Scene_Map.prototype.expressionSpyWindow.document.write("$gameSwitches[" + esSwitchesArray + "] = " + $gameSwitches.value(esSwitchesArray) + "<br>");
                };
                Scene_Map.prototype.expressionSpyWindow.document.write("---------------------------------------------------------------" + "<br>");
            };
            if (esExpressionsArray[0] != "") {
                for (i = 0; i < esExpressionsArray.length; i++) {

                    try {
                        Scene_Map.prototype.expressionSpyWindow.document.write(esExpressionsArray + " = " + eval(esExpressionsArray) + "<br>");
                    } catch (err) {
                        Scene_Map.prototype.expressionSpyWindow.document.write("Watched expression " + esExpressionsArray + " does not exist!" + "<br>");
                    };
                };
            };
        };
    };

    ////// Create variables and Expression Spy window
    var alis_SM_initialize = Scene_Map.prototype.initialize;
    Scene_Map.prototype.initialize = function () {

        var scriptParameters = $plugins.filter(function (p) {
            return p.description.contains("<id:Expression Spy>")
        })[0].parameters;

        esVariablesArray = scriptParameters['Game Variables'].split(",");
        for (i = 0; i < esVariablesArray.length; i++) {
            esVariablesArray = esVariablesArray.trim();
        };
        esVariablesArray = uniq(esVariablesArray);

        esSwitchesArray = scriptParameters['Game Switches'].split(",");
        for (i = 0; i < esSwitchesArray.length; i++) {
            esSwitchesArray = esSwitchesArray.trim();
        };
        esSwitchesArray = uniq(esSwitchesArray);

        esExpressionsArray = scriptParameters['Custom Expressions'].split(",");
        esExpressionsArray = uniq(esExpressionsArray);

        alis_SM_initialize.call(this);
        if (typeof Scene_Map.prototype.expressionSpyWindow != 'undefined') {
            Scene_Map.prototype.expressionSpyWindow.close();
        };
        if (scriptParameters['Game Variables'] != "" || scriptParameters['Game Switches'] != "" || scriptParameters['Custom Expressions'] != "") {
            Scene_Map.prototype.expressionSpyWindow = window.open();
            Scene_Map.prototype.expressionSpyWindow.resizeTo(800, 400);
            Scene_Map.prototype.expressionSpyWindow.moveTo(0, 300);
            require('nw.gui').Window.get().focus();
        };
    };


    ////// Call ExpressionSpy every update frame from Game_Screen
    var alias_GS_Update = Game_Screen.prototype.update;
    Game_Screen.prototype.update = function () {
        alias_GS_Update.call(this);
        expressionSpy();
    };


    ////// Remove duplicate entries from an array
    function uniq(a) {
        var seen = {};
        return a.filter(function (item) {
            return seen.hasOwnProperty(item) ? false : (seen[item] = true);
        });
    };








    FAQNone yet.Credit and Thanks- Drykul


    - Shadowarc82



    本贴来自国际rpgmaker官方论坛作者:shaynec1981处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/expression-spy.59127/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-26 03:55 , Processed in 0.067252 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表