Additional Menu Windows

Discussion in 'JS Plugin Requests' started by KinoCornell, Mar 28, 2017.

  1. KinoCornell

    KinoCornell Villager Member

    Messages:
    9
    Likes Received:
    0
    Location:
    Lake Los Angeles, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm attempting to set up a menu using a flipped layout plugin from a very helpful YouTube tutorial video. The layout I'm using is in this very simple script here (I didn't create it):

    /*:
    * @plugindesc alt menu
    * @author SumRndmDde
    * @Help
    */

    Scene_Menu.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this.createCommandWindow();
    this.createGoldWindow();
    this.createStatusWindow();
    /*
    this._commandWindow
    this._goldWindow
    this._statusWindow
    */

    this._statusWindow.x = 0;

    this._commandWindow.x = this._statusWindow.width;

    this._goldWindow.x = this._statusWindow.width;
    this._goldWindow.y = this._commandWindow.height;

    };

    What I'm needing to do here is add a new window below the Command Window and above the Gold Window. That additional Window needs to have 3 lines of information:

    1.) A dynamic string of text based on a value in one of my game variables.
    2.) The display name of the current map.
    3.) The current save file's playtime.

    I know this probably seems super simple to most of you, but I am not very adept in JS. I've combed through several videos and posts trying to figure out how to do this myself (at least the second and third item to start with), but I cannot make it work.

    The first item I'm not sure if I would have to do just a long series of "if..else" statements within the JS itself or if you can run a common event from the menu's JS to determine the string (to maybe streamline it?). But I have no idea how in the JS to reference an in-game variable and then display it as text.

    Any help would be greatly appreciated. Thank you.
     
    #1
  2. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    570
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    I just learned how to do this, tinkering around with that script you shown.
    [​IMG]
    PHP:
    Scene_Menu.prototype.create = function() {
        
    Scene_MenuBase.prototype.create.call(this);
        
    this.createCommandWindow();
        
    this.createGoldWindow();
        
    this.createStatusWindow();
       
        
    // begin custom window
        
    this._myCustomWindow = new Window_Help(4); // height is 4 lines
        
    this._myCustomWindow.0;
        
    this._myCustomWindow.Graphics.boxHeight this._myCustomWindow.height this._goldWindow.height;
        
    this._myCustomWindow.width this._goldWindow.width;
        
    this._myCustomWindow.visible true;
        
    this._myCustomWindow.setText(
           
    "Attribute:"+
           
    "\n" +
           [
               
    "Message 0"// notice these messages
               
    "Message 1",
               
    "Message 2",
               
    "Message 3"
           
    ][
               
    $gameVariables.value(19// notice this game variable
           
    ] +
           
    "\n" +
           
    $dataMapInfos[$gameMap._mapId].name +
           
    // $dataMap.displayName + // or maybe you want display name?
           
    "\n" +
           
    $gameSystem.playtimeText()
        );
        
    this.addWindow(this._myCustomWindow);
    };
     
    #2
  3. KinoCornell

    KinoCornell Villager Member

    Messages:
    9
    Likes Received:
    0
    Location:
    Lake Los Angeles, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    Oh awesome! Thank you so much! One thing I'm trying to figure out, and I just tried throwing in some "if..else" statements but I can't get it to show up...

    This is specific to the "Attribute" and "Message" part. I want this to show a rank based on how many in-game quests have been completed (stored in a specific variable).

    I will ultimately replace the word "Attribute" with the word "Rank".
    Then, where "Message 0" is, I want it to recognize when $gameVariables.value(5) is less than 10 and output the phrase "Amateur Mercenary."
    Then when $gameVariables.value(5) is greater than 9 and less than 20 I want it to output "Novice Mercenary."
    So and and so forth for each different "Rank" I have planned at specific quest completion.

    I tried to modify your code like this:

    // begin custom window
    this._myCustomWindow = new Window_Help(4); // height is 4 lines
    this._myCustomWindow.x = 0;
    this._myCustomWindow.y = Graphics.boxHeight - this._myCustomWindow.height -

    this._goldWindow.height;
    this._myCustomWindow.width = this._goldWindow.width;
    this._myCustomWindow.visible = true;
    this._myCustomWindow.setText(
    "Rank:"+
    "\n" +
    [
    $gameVariables.value(5) // notice this game variable
    ]
    [
    if $gameVariables.value(5) < 10
    "Amateur Mercenary";
    else if $gameVariables.value(5) > 9 & < 20
    "Novice Mercenary";
    end;
    ] +
    "\n" +
    $dataMapInfos[$gameMap._mapId].name +
    // $dataMap.displayName + // or maybe you want display name?
    "\n" +
    $gameSystem.playtimeText()
    );
    this.addWindow(this._myCustomWindow);
    };

    But I didn't do something right, and the entire window won't show up when it's like that. How can I fix it?
     
    #3
  4. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    570
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Where everything greater than 20 is Rank 4 and so forth...
    PHP:
    var index $gameVariables.value(5) < 5  :
                
    $gameVariables.value(5) < 10 :
                
    $gameVariables.value(5) < 15 :
                
    $gameVariables.value(5) < 20 4;
    this._myCustomWindow.setText(
       
    "Rank:"+
       
    "\n" +
       [
          
    "Rank 0",
          
    "Rank 1",
          
    "Rank 2",
          
    "Rank 3",
          
    "Rank 4"
       
    ][index] +
       
    "\n" +
       
    $dataMapInfos[$gameMap._mapId].name +
       
    // $dataMap.displayName + // or maybe you want display name?
       
    "\n" +
       
    $gameSystem.playtimeText()
    );
     
    #4
  5. KinoCornell

    KinoCornell Villager Member

    Messages:
    9
    Likes Received:
    0
    Location:
    Lake Los Angeles, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    So if I'm sticking it in the right place, the final result should look like this?:

    Scene_Menu.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this.createCommandWindow();
    this.createGoldWindow();
    this.createStatusWindow();

    // begin custom window
    this._myCustomWindow = new Window_Help(4); // height is 4 lines
    this._myCustomWindow.x = 0;
    this._myCustomWindow.y = Graphics.boxHeight - this._myCustomWindow.height - this._goldWindow.height;
    this._myCustomWindow.width = this._goldWindow.width;
    this._myCustomWindow.visible = true;
    var index = $gameVariables.value(5) < 5 ? 0 :
    $gameVariables.value(5) < 10 ? 1 :
    $gameVariables.value(5) < 15 ? 2 :
    $gameVariables.value(5) < 20 ? 3 : 4;
    this._myCustomWindow.setText(
    "Attribute:"+
    "\n" +
    [
    "Rank 0",
    "Rank 1",
    "Rank 2",
    "Rank 3",
    "Rank 4"
    ][index] +
    "\n" +
    $dataMapInfos[$gameMap._mapId].name +
    // $dataMap.displayName + // or maybe you want display name?
    "\n" +
    $gameSystem.playtimeText()
    );

    Correct? I put it in there like this but the window just doesn't appear.
     
    #5
  6. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    570
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    If that is the whole plugin, it has an unexpected end of input error.
    It's missing addWindow and an END which in javascript is a curly brace }.
    Code:
    this.addWindow(this._myCustomWindow);
    };
    
     
    #6
  7. KinoCornell

    KinoCornell Villager Member

    Messages:
    9
    Likes Received:
    0
    Location:
    Lake Los Angeles, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    That worked! I was able to get all of the different variable quantities and their corresponding output set up. I've tested it in-game and it all works perfectly! Thank you so much!!
     
    #7
  8. mogwai

    mogwai 1984 Veteran

    Messages:
    876
    Likes Received:
    570
    Location:
    Bassett Nebraska
    First Language:
    English
    Primarily Uses:
    RMMV
    Don't thank me. Thank @SumRndmDde
    I only tinkered with that thing you posted.
     
    #8

Share This Page