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

[转载发布] Plugin case changer (Test tool)

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    慵懒
    3 天前
  • 签到天数: 207 天

    连续签到: 1 天

    [LV.7]常住居民III

    3646

    主题

    862

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 4 天前 | 显示全部楼层 |阅读模式
    Plugin case changer (Test tool)¨

    Changes the casing of plugin commands

    Introduction

    This little plugin is to help scripters being aware of and making conscious choices about case-sensitivity and test during plugin development. It also helps plugin users bug scripters about such issues, and hopefully help establish a best practice rule: Plugin commands comparison should be case-insensitive by default except where the sensitivity has a functional meaning.

    Download

    You can download the script from my MediaFire account or copy it from the code block in the spoiler.

    Spoiler//=============================================================================// Plugin Case Changer// Zeriab_PluginCaseChanger.js// Last Updated: 2015.08.23//=============================================================================var Imported = Imported || {};Imported.Zeriab_PluginCaseChanger = true;var Zeriab = Zeriab || {};/*: * @plugindesc Changes the casing of plug-in commands * @author Zeriab * * @param Command text * @desc Change the casing of the command text? * @default false * * @param First argument * @desc Change the casing of the first argument? (Typically set/add/create, i.e. an action specification for the plugin) * @default true * * @param Additional arguments * @desc Change the casing of all additional arguments? * @default false * * @param Case type * @desc 1: lowercase, 2: UPPERCASE, 3: Captilize * @default 1 * * @help * * Use this plug-in to help nudge scripters and programmers into making the use of Plugin Commands * case-insensitive except where needed. * * For example for Yanfly's scripts there is no reason why "MessageRows 6" should be treated  * differently from "Messagerows 6". In some instances preserving casing can be necessary. When * Displaying text for example. */(function () {    Zeriab.Casing = Zeriab.Casing || {};    Zeriab.Casing.Parameters = PluginManager.parameters('Zeriab_PluginCaseChanger');    _ChangeCommandText = ('true' === Zeriab.Casing.Parameters["Command text"].toLowerCase()) ? true : false;    _ChangeActionArgument = ('false' === Zeriab.Casing.Parameters["First argument"].toLowerCase()) ? false : true;    _ChangeAdditionalArguments = ('true' === Zeriab.Casing.Parameters["Additional arguments"].toLowerCase()) ? true : false;    _CaseType = Zeriab.Casing.Parameters["Case type"].trim();    // Plugin Command override    Game_Interpreter.prototype.command356 = function () {        var args = this._params[0].split(" ");        var command = args.shift();        // Inserted code to alter command and argument casing        // >>CommandText<< [FirstArg [SecondArg ThirdArg ...]]        if (_ChangeCommandText) {            command = Zeriab.Casing.Change(command, _CaseType);        }        // CommandText [>>FirstArg<< [SecondArg ThirdArg ...]]        if (_ChangeActionArgument) {            if (args && args[0]) {                args[0] = Zeriab.Casing.Change(args[0], _CaseType);            }        }        // CommandText [FirstArg [>>SecondArg ThirdArg ...<<]]        if (_ChangeAdditionalArguments) {            if (args && args.length > 1) {                for (i = 1; i < args.length; i++) {                    args = Zeriab.Casing.Change(args, _CaseType);                }            }        }        // Standard code from here        command.toLowerCase();        command.toUpperCase();        this.pluginCommand(command, args);        return true;    };    /**     * Makes a number string with leading zeros.     *     * @method Zeriab.Casing.Change     * @param {String} s The string to alter casing     * @param {String} type The type of casing request     * @return {String} A string with casing corresponting to the type     */    Zeriab.Casing.Change = function (s, type) {        switch (type.toLowerCase()) {            case '3':            case 'capitalize':                s_first = s.substring(0, 1);                s_rest = s.substr(1);                s = s_first.toUpperCase() + s_rest.toLowerCase();                break;            case '2':            case 'uppercase':                s = s.toUpperCase();                break;            case '1':            case 'lowercase':            default:                s = s.toLowerCase();                break;        }        return s;    };})();



    Terms of Use

    SpoilerCopyright (C) 2015   ZeriabThis software is provided 'as-is', without any express or implied warranty.In no event will the authors be held liable for any damages arising fromthe use of this software.Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute itfreely, subject to the following restrictions:1. The origin of this software must not be misrepresented; you must not   claim that you wrote the original software. If you use this software   in a product, an acknowledgment in the product documentation is not    required.2. Altered source versions must be plainly marked as such, and must not   be misrepresented as being the original software.



    Instruction

    Use this plug-in to help nudge scripters and programmers into making the use of Plugin Commands case-insensitive except where needed. For example for Yanfly's scripts there is no reason why "MessageRows 6" should be treated differently from "Messagerows 6". In some instances preserving casing can be necessary. When displaying text for example.

    Plugin parameter options


    • Command text ~ Change the casing of the command text?
    • First argument ~ Change the casing of the first argument? (Typically set/add/create, i.e. an action specification for the plugin)
    • Additional arguments ~ Change the casing of all additional arguments?
    • Case type ~ Choose between following case conversions1 - lowercase
    • 2 - UPPERCASE
    • 3 - Captilize
    As an example let's look at my Extra Maps script.My plugin follows the convention on plugin commands PluginIdentifier action arg1, arg2, ... with only 1 argument, so we can have plugin commands such as ExtraMaps set church. What happens if someone accidentally use extramaps set church or ExtraMaps Set church? Silent failure, nothing happens. Map folder is not changed.

    The casing doesn't really matter for neither the plugin identifier nor the action. The church is a folder name. As the folder name is case sensitive on some systems preserving the casing is important. For testing my plugin I therefore chose to change the casing of the command text and the first argument, but not the additional arguments. What about the Case type? I ran my test demo once per case type, found an error and fixed it. Unfortunately I forgot to give it to Archeia, so the plugin in the release package is the old one. Sorry! ;A;

    Yes, yes, I know it's a small thing. But we might as well be nice to the game devs who end up using our plugins, right? ^^

    *hugs*

    - Zeriab



    本贴来自国际rpgmaker官方论坛作者:Zeriab处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/plugin-case-changer-test-tool.46559/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-10 04:21 , Processed in 0.142678 second(s), 57 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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