VsConvertEscapeCharacters + 1.1.0
VsRpgDev
VsRpgDev
Introduction
This plugin allows you to register custom escape characters, which lets you, for example, access custom values from your plugin, trigger methods, draw images, etc., when a text message is displayed.
Additionally, you can use convertEscapeCharacters from anywhere in the code through the static class VsConvertEscapeCharacters.
Readme
Features
- registerEscapeCharacter
registers a new escaped character
- registerProcessEscapeCharacter
register a new escaped character (gets handled later then registerEscapeCharacter)
- convertEscapeCharacters
converts escaped characters in a text
How to Use
registerEscapeCharacter
JavaScript:
// arrow functions -------------
VsConvertEscapeCharacters.registerEscapeCharacter("X",(text)=> {
return "your text was "+text;
});
// old style -------------------
function ReplaceText(text)
{
return "your text was "+text;
}
VsConvertEscapeCharacters.registerEscapeCharacter("X",ReplaceText);
registerProcessEscapeCharacter
JavaScript:
// arrow functions -------------
VsConvertEscapeCharacters.registerProcessEscapeCharacter("X",(currentWindow, textState, param)=> {
//do whatever you like
//example draw icon
currentWindow.processDrawIcon(param, textState);
});
// old style -------------------
function CustomMethod(currentWindow, textState, param)
{
return "your text was "+text;
//do whatever you like
//example draw icon
currentWindow.processDrawIcon(param, textState);
}
VsConvertEscapeCharacters.registerProcessEscapeCharacter("X",CustomMethod);
convertEscapeCharacters - get escaped character from wherever you want
JavaScript:
finalText = VsConvertEscapeCharacters.convertEscapeCharacters(text);
Plugin Commands / Script Calls
JavaScript:
declare class VsConvertEscapeCharacters
{
static convertEscapeCharacters(text: string) : string;
static actorName(n: string) : string;
static partyMemberName (n:string) : string;
/**
* register a new escape character
* @param char escape character to use
* @param method callback method which gets the paramter from within the brackets [] and should return the replacement text
*/
static registerEscapeCharacter(char : string, method: (string)=>string) : string;
/**
* retursn all registered escape characters
*/
static get CustomEscapeCharacters() : { [id: string]:(string)=>string; };
/**
* register process escape character, these get processed character by character when the textbox draws the message text
* @param char scape character to use
* @param method callback method which gets the the current windows, the textstate and paramter from within the brackets [] and should return the replacement text
*/
static registerProcessEscapeCharacter(char : string, method: (windowBase:Window_Base, state: TextState, param: string)=>void) : string;
static get ProcessEscapeCharacter() : { [id: string]: (windowBase:Window_Base, state: TextState, param: string)=>void; };
}
Changes to the core script
- rmmz_windows.js
- Window_Base
- [M] convertEscapeCharacters: overrides,original gets called after
- [M] processEscapeCharacter: overrides,original gets called after
- Window_Base
Demo
demo.js
Download
VsConvertEscapeCharacters.js (Plugin)
Github Repository
Terms and Credits
VsConvertEscapeCharacters is marked with CC0 1.0 Universal. To view a copy of this license, visit https://creativecommons.org/publicdomain/zero/1.0/
This plugin can be used in any project, commercial or otherwise. no credit needed.