Plugin case changer (Test tool)

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,213
Reaction score
1,266
First Language
English
Primarily Uses
RMXP
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.

//=============================================================================// 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

Copyright (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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Managed to find a way to hang a bed cover over my window. So no more being toasted alive in the afternoon!:kaoswt2:
So, uh, has anyone tried buying any resources from KokoroReflections? Because I've been looking for a 'buy' button on the site for like 10 minutes now and can't find one.
Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Forum statistics

Threads
97,980
Messages
948,325
Members
129,245
Latest member
Tanoukun
Top