Show certain variable window on map

Discussion in 'JS Plugin Requests' started by metronome, Dec 22, 2015.

  1. metronome

    metronome Veteran Veteran

    Messages:
    347
    Likes Received:
    140
    First Language:
    English (Sure!)
    So far I have been using Yanfly's Map Gold Window plugin. You can basically show a window with the number of gold you have during gameplay with certain icon and certain icon on your game screen.

    Now, instead of gold, I would like to be able to show certain variable in that window...., and I don't think Yanfly has anytime available to do that.

    I don't know if there is plugin similar to this already available somewhere else so here I am making this request.

    Thanks for at least reading!~~
     
    #1
  2. Jeremy Cannady

    Jeremy Cannady Coldfire Veteran

    Messages:
    449
    Likes Received:
    260
    Location:
    Texas
    First Language:
    English
    If you have a screenshot I could make one real quick.
     
    #2
  3. metronome

    metronome Veteran Veteran

    Messages:
    347
    Likes Received:
    140
    First Language:
    English (Sure!)
    #3
  4. Jeremy Cannady

    Jeremy Cannady Coldfire Veteran

    Messages:
    449
    Likes Received:
    260
    Location:
    Texas
    First Language:
    English
    I have modified Yanfly's script to accept variables:

    //=============================================================================// Yanfly Engine Plugins - Map Gold Window// YEP_MapGoldWindow.js//============================================================================= var Imported = Imported || {};Imported.YEP_MapGoldWindow = true; var Yanfly = Yanfly || {};Yanfly.MGW = Yanfly.MGW || {}; //============================================================================= /*: * @plugindesc v1.00 Allows you to display the gold window on your map. * @author Yanfly Engine Plugins * * @param Automatic Open * @desc Automatically open the map window by default? * NO - false YES - true * @default true * * @param Default Position * @desc The default position of the gold window. * Refer to the numbers on the NumPad for screen position. * @default 9 * * @param Opacity * @desc The opacity value used for the gold window. * Default: 255 * @default 255 * * @param VariableID * @desc Varible ID to display. * @default 1 * * @param Variable Name * @desc Varible name to display. * @default Variable 1 * * @help * ============================================================================ * Introduction * ============================================================================ * * Ever wanted to display the gold window and leave it on the map screen for a * bit? This plugin will allow you to do that with just a few plugin commands. * * ============================================================================ * Plugin Commands * ============================================================================ * * Use the following plugin commands to control the gold window. * * Plugin Command: * * OpenMapGoldWindow * Opens the map gold window. * * CloseMapGoldWindow * Closes the map gold window. * * MapGoldWindowPosition x * Changes the screen position of the map gold window to x. Refer to the * NumPad for the screen position like below: * * 7 8 9 * 4 5 6 * 1 2 3 * * If you set the value to 0, it will maintain its current position but will * automatically move itself to a different location if it intrudes on the * message window. *///============================================================================= //=============================================================================// Parameter Variables//=============================================================================Yanfly.Parameters = PluginManager.parameters('VariableDisplay');Yanfly.Param = Yanfly.Param || {}; Yanfly.Param.MGWAutomatic = eval(String(Yanfly.Parameters['Automatic Open']));Yanfly.Param.MGWPosition = Number(Yanfly.Parameters['Default Position']);Yanfly.Param.MGWOpacity = Number(Yanfly.Parameters['Opacity']);Yanfly.Param.MGWVariableID = Number(Yanfly.Parameters['VariableID']);Yanfly.Param.MGWVariableName = Yanfly.Parameters['Variable Name'];//=============================================================================// Game_System//============================================================================= Yanfly.MGW.Game_System_initialize = Game_System.prototype.initialize;Game_System.prototype.initialize = function() { Yanfly.MGW.Game_System_initialize.call(this); this.initMapGoldWindow();}; Game_System.prototype.initMapGoldWindow = function() { this._mapGoldWindowAutoOpen = Yanfly.Param.MGWAutomatic; this._mapGoldWindowPosition = Yanfly.Param.MGWPosition;}; Game_System.prototype.setMapGoldWindowAutoOpen = function(value) { this._mapGoldWindowAutoOpen = value;}; Game_System.prototype.isMapGoldWindowAutoOpen = function() { if (this._mapGoldWindowAutoOpen === undefined) this.initMapGoldWindow(); return this._mapGoldWindowAutoOpen;}; Game_System.prototype.setMapGoldWindowPosition = function(value) { this._mapGoldWindowPosition = parseInt(value);}; Game_System.prototype.getMapGoldWindowPosition = function() { if (this._mapGoldWindowPosition === undefined) this.initMapGoldWindow(); return this._mapGoldWindowPosition;}; //=============================================================================// Game_Interpreter//============================================================================= Yanfly.MGW.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;Game_Interpreter.prototype.pluginCommand = function(command, args) { Yanfly.MGW.Game_Interpreter_pluginCommand.call(this, command, args) if (command === 'OpenMapGoldWindow') { $gameSystem.setMapGoldWindowAutoOpen(true); } if (command === 'CloseMapGoldWindow') { $gameSystem.setMapGoldWindowAutoOpen(false); } if (command === 'MapGoldWindowPosition') { $gameSystem.setMapGoldWindowPosition(args[0]); }}; //=============================================================================// Scene_Map//============================================================================= Yanfly.MGW.Scene_Map_update = Scene_Map.prototype.update;Scene_Map.prototype.update = function() { Yanfly.MGW.Scene_Map_update.call(this); this.updateGoldWindow();}; Scene_Map.prototype.updateGoldWindow = function() { if (!this._messageWindow) return; if (!this._messageWindow._goldWindow) return; this.updateGoldWindowOpenness(); this.updateGoldWindowPosition(); this.updateGoldWindowOpacity();}; Scene_Map.prototype.updateGoldWindowOpenness = function() { var win = this._messageWindow._goldWindow; if (SceneManager.isSceneChanging() && !win.isClosing()) { win.openness = 0; } else if (this.checkOpenMapGoldWindow()) { if (win.isOpening() || win.isOpen()) { this.updateGoldRefresh(); } else { win.open(); } } else { win.close(); }}; Scene_Map.prototype.checkOpenMapGoldWindow = function() { if ($gameSystem.isMapGoldWindowAutoOpen()) return true; if (this._messageWindow._goldWindowOpened) return true; return false;}; Scene_Map.prototype.updateGoldRefresh = function() { this._messageWindow._goldWindow.value=(function(){ return $gameVariables.value(Yanfly.Param.MGWVariableID); }); this._messageWindow._goldWindow.currencyUnit = function() { return Yanfly.Param.MGWVariableName; } this._messageWindow._goldWindow.refresh();}; Scene_Map.prototype.updateGoldWindowPosition = function() { var win = this._messageWindow._goldWindow; var pos = $gameSystem.getMapGoldWindowPosition(); switch (pos) { case 1: win.x = 0; win.y = Graphics.boxHeight - win.height; break; case 2: win.x = (Graphics.boxWidth - win.width) / 2; win.y = Graphics.boxHeight - win.height; break; case 3: win.x = Graphics.boxWidth - win.width; win.y = Graphics.boxHeight - win.height; break; case 4: win.x = 0; win.y = (Graphics.boxHeight - win.height) / 2; break; case 5: win.x = (Graphics.boxWidth - win.width) / 2; win.y = (Graphics.boxHeight - win.height) / 2; break; case 6: win.x = Graphics.boxWidth - win.width; win.y = (Graphics.boxHeight - win.height) / 2; break; case 7: win.x = 0; win.y = 0; break; case 8: win.x = (Graphics.boxWidth - win.width) / 2; win.y = 0; break; case 9: win.x = Graphics.boxWidth - win.width; win.y = 0; break; }}; Scene_Map.prototype.updateGoldWindowOpacity = function() { this._messageWindow._goldWindow.opacity = Yanfly.Param.MGWOpacity;}; //=============================================================================// Window_Message//============================================================================= Yanfly.MGW.Window_Message_processNewPage = Window_Message.prototype.processNewPage;Window_Message.prototype.processNewPage = function(textState) { Yanfly.MGW.Window_Message_processNewPage.call(this, textState); this._goldWindowOpened = false;}; Yanfly.MGW.Window_Message_pEC = Window_Message.prototype.processEscapeCharacter;Window_Message.prototype.processEscapeCharacter = function(code, textState) { if (code === '$') { this._goldWindow.open(); this._goldWindowOpened = true; } else { Yanfly.MGW.Window_Message_pEC.call(this, code, textState); }}; Yanfly.MGW.Window_Message_terminateMessage = Window_Message.prototype.terminateMessage;Window_Message.prototype.terminateMessage = function() { Yanfly.MGW.Window_Message_terminateMessage.call(this); if ($gameSystem.isMapGoldWindowAutoOpen()) { this._goldWindow.open(); } this._goldWindowOpened = false;}; //=============================================================================// End of File//============================================================================ 
    Name the file VariableDisplay.js
     
    #4
    metronome likes this.
  5. metronome

    metronome Veteran Veteran

    Messages:
    347
    Likes Received:
    140
    First Language:
    English (Sure!)
    Name the file VariableDisplay.js
    This works~~!

    But I find out that you just can't put this together with Yanfly's Map Gold Window plugin. (RangeError: Maximum call stack size exceeded). You will have to choose one between this plugin or yanfly's plugin.

    So basically you can only show one window in one map huh?~~

    Thanks for the answer,

    I am pretty sure that will help others who look for way to display variable (that's not gold) permanently in their game~~
     
    #5
  6. Jeremy Cannady

    Jeremy Cannady Coldfire Veteran

    Messages:
    449
    Likes Received:
    260
    Location:
    Texas
    First Language:
    English
    Well if I would make an official script you could have both windows.

    I also thought Orange Hud script can do this too. I am not sure though.
     
    #6

Share This Page