jerry2810

AutoColor

Nov 3rd, 2015
753
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // AutoColor.js
  3. //=============================================================================
  4.  
  5. /*:
  6.  * @plugindesc Auto colors key names that you define.
  7.  * @author Jeremy Cannady
  8.  *
  9.  *
  10.  * @help This script does not have any parameters to define you must go into
  11.     the script and make your own list of key names and colors.
  12.     My profile:http://forums.rpgmakerweb.com/index.php?/user/72458-jeremy-cannady/
  13.     Please message for questions.
  14.  *
  15.  *
  16. */
  17.  
  18. (function(){
  19. //This where we define what our key names will be and their color  
  20. var lTBC = {
  21.     //The name is case sensitive, please follow the format correctly
  22.     //the commas after each entry is required
  23.     //  'entry':15,
  24.     //  'entry2':20,
  25.     'pine':3,
  26.     'apple':10
  27.    
  28. };
  29.  
  30. //Please don't touch below this as your game will explode.
  31. Window_Base.prototype.convertEscapeCharacters = function(text) {
  32.     //Begin
  33.     //Go through the text and see if we have a match to our list
  34.     Object.keys(lTBC).forEach(function (key){
  35.         //Define a new RegExp to detect our list
  36.         var replacee = new RegExp('\\b' + key + '\\b', 'g');
  37.         //Define what we want to replace it with
  38.         var replacer = '\\c'+'['+lTBC[key]+']' + key + '\\c' +'['+0+']';
  39.         //Replace the text
  40.         text = text.replace(replacee,replacer);
  41.     });
  42.     //End
  43.     text = text.replace(/\\/g, '\x1b');
  44.     text = text.replace(/\x1b\x1b/g, '\\');
  45.  
  46.     text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
  47.         return $gameVariables.value(parseInt(arguments[1]));
  48.     }.bind(this));
  49.     text = text.replace(/\x1bV\[(\d+)\]/gi, function() {
  50.         return $gameVariables.value(parseInt(arguments[1]));
  51.     }.bind(this));
  52.     text = text.replace(/\x1bN\[(\d+)\]/gi, function() {
  53.         return this.actorName(parseInt(arguments[1]));
  54.     }.bind(this));
  55.     text = text.replace(/\x1bP\[(\d+)\]/gi, function() {
  56.         return this.partyMemberName(parseInt(arguments[1]));
  57.     }.bind(this));
  58.     text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
  59.     return text;
  60.    
  61.    
  62. };
  63. })();
Advertisement
Add Comment
Please, Sign In to add comment