Foure4

TextSpeed

Dec 18th, 2016
1,380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*=============================================================================
  2.  * TextSpeed
  3.  *=============================================================================*/
  4.  
  5.  var Imported = Imported || {};
  6.  Imported.Krimer_TextSpeed = true;
  7.  
  8. /*:
  9. * @plugindesc 1.0 Text speed control, available speed - 0.5x, 1x, 2x, instant.
  10. * <TextSpeed>
  11. * @author Krimer
  12. *
  13. * @param Variable id
  14. * @desc Variable id for text speed control. Left 0 to disable. Default: 0
  15. * @default 0
  16. *
  17. * @param Default text speed
  18. * @desc Default value of text speed variable. 0 = 0.5x, 1 = 1x, 2 = 2x, 3 = instant. Default: 1
  19. * @default 1
  20. *
  21. * @help
  22. * --------------------------------------------------------------------------------
  23. * Free for use.
  24. * Version 1.0
  25. * --------------------------------------------------------------------------------
  26. * To change text speed in show text command, set text speed variable to
  27. * proper value.
  28. * Available variable values:
  29. * 0 = 0.5x text speed
  30. * 1 = 1x normal text speed
  31. * 2 = 2x text speed
  32. * 3 = instant text speed
  33. */
  34.  
  35. (function() {
  36.     var parameters = $plugins.filter(function(p) { return p.description.contains('<TextSpeed>'); })[0].parameters;
  37.  
  38.     var paramVariableId = Number(parameters['Variable id'] || 0);
  39.     var paramDefaultValue = Number(parameters['Default text speed'] || 1);
  40.    
  41.     /* Alias */
  42.     var textSpeed_Alias_DataManager_setupNewGame = DataManager.setupNewGame;
  43.     DataManager.setupNewGame = function() {
  44.         textSpeed_Alias_DataManager_setupNewGame.call(this)
  45.         if (paramVariableId !== 0){
  46.             $gameVariables[paramVariableId] = paramDefaultValue;
  47.         }
  48.     };
  49.    
  50.     /* OVERWRITE */
  51.     Window_Message.prototype.updateMessage = function() {
  52.         if (this._textState) {
  53.             while (!this.isEndOfText(this._textState)) {
  54.                 if (this.needsNewPage(this._textState)) {
  55.                     this.newPage(this._textState);
  56.                 }
  57.                 this.updateShowFast();
  58.                 if (paramVariableId !== 0){
  59.                     switch ($gameVariables[paramVariableId]) {
  60.                         case 0:
  61.                           this.startWait(1);
  62.                           break
  63.                         case 1:
  64.                           break
  65.                         case 2:              
  66.                           this.processCharacter(this._textState);
  67.                           break
  68.                         case 3:
  69.                           this._showFast = true;
  70.                           break
  71.                         default:
  72.                           break
  73.                     }
  74.                 }
  75.                 this.processCharacter(this._textState);
  76.                 if (!this._showFast && !this._lineShowFast) {
  77.                     break;
  78.                 }
  79.                 if (this.pause || this._waitCount > 0) {
  80.                     break;
  81.                 }
  82.             }
  83.             if (this.isEndOfText(this._textState)) {
  84.                 this.onEndOfText();
  85.             }
  86.             return true;
  87.         } else {
  88.             return false;
  89.         }
  90.     };
  91. })();
Advertisement
Add Comment
Please, Sign In to add comment