[RMMV] How to pass information to various windows

● ARCHIVED · READ-ONLY
Started by Sai Hikawa 9 posts View original ↗
  1. Hi,
    I am at loss as to how to do this. Basically, what I want to accomplish is to have the second window display the item chosen from the first window. Aside from that, enable the user to go back to the first window if he press cancelled on the second window.
    What's happening here is that the second help window is not displaying the item selected from the first window. I used a global variable to take note of the item selected on the first window, but it doesn't update for the second help window...

    I've attached my code for reference (sorry for the amount of console logs and comments).
  2. PLEASE TURN OFF YOUR CAPS LOCK NEXT TIME WHEN WRITING A TITLE, WE CAN READ IT WELL EVEN WITHOUT IT. THANK YOU.

    Anyway, your second window is missing a method called createContents. This will create an array of items, where item is data.
    For example in a normal buy window an item consists of this data:
    item name, item price. Possibly item quantity owned.
    This then gets drawn inside a Window_Selectable prototype.

    I can hardly help you more, because I am kinda lost in your plugin.
  3. Sorry about the title, I've edited it now. Also with the plugin, I copied and modified the functions already existing, and I had some help with the construction of the entire thing (mostly on the window displaying the party members), so I haven't really had the time to clean it up. My primary concern is to have it working first, then slowly clean up the code as I go. :D

    This is what happens, basically:
    fusion1.png
    So on the second screen (the one on the right), there's a small window at the top that says "select the second demon: " and there should be a string after that (the selected item's class, name, and level). So while the window at the bottom (with the RESULT!!!!!) can process the item selected from the previous screen, the small screen at the top can't. T_T
  4. A general tip to accomplish this is to add your "child" window as a property of the "parent" window. I'm using quotes because they aren't truly a parent/child relationship, but for the sake of passing information it is convenient to think of it this way.

    Code:
    Scene_Something.prototype.createSomeWindowsYo = function() {
        this._selectionWindow = new Window_Awesome_Selections();
        this.addWindow(this._selectionWindow);
        this._helperWindow = new Window_Awesome_Helper_Stuff();
        this.addWindow(this._helperWindow);
        // This is the key line below
        this._selectionWindow._helperWindow = this._helperWindow;
    };
    Obviously I'm paraphrasing, and you'll have to change it to fit your plugin. But the key point here is that the selection window now has access to the helper window. With that, you can maintain the state of whatever was chosen in the selection window and just pass that to the helper window.
    Code:
    Window_Awesome_Selections.prototype.drawOnHelper = function() {
        if (this._helperWindow) {
            // Now we can directly draw from one window to another
            this._helperWindow.drawText('It works!', 0, 0);
    
            // Or we can pass data and call refresh, where the refresh method uses that data
            this._helperWindow.demonSelection = 'Shiva';
            this._helperWindow.refresh();
        }
    };
    I briefly looked at your code, it seems like you have two different selection windows and two different help windows. If this works for you, then by all means, continue with it. Personally, I would have just done 1 selection window and 1 help window.
    1. Player makes a choice on the selection window of the "first demon"
    2. Save their choice as a property of the selection window
    3. Refresh the selection window with new options for the "second demon"
    4. Pass the first choice to the helper window to draw
  5. Thanks for the suggestion! It worked wonderfully. The remaining concern that I have for this script (aside from the actual fusion computation process I'm dreading to work on) is that the 'cancel' process is not working and the 'ok' process keeps them shifting windows.
    For example, I'm at window 1, then I pressed ok, I'll proceed to window 2. After pressing OK, I'll go back to window 1... which shouldn't really be the case. The actual fusion result would be shown after pressing OK on window 2 (provided that the fusion is valid), if invalid it will not push through (the actual fusion result would be the third window, which is a work in progress at this point. So I was hoping that the entire thing would close once I press OK on window 2).
    I'm planning to make the code simpler, but for now I'll work on this as soon as I got everything running as expected (so at least I have a working copy), then I'll slowly go and make the codes much simpler.
    Here's the updated code that I have.
  6. The advice I have for you there is that everything must be handled explicitly. It always helps to make yourself a flow chart - what window becomes active when the player selects a choice, what window becomes active when the player presses 'esc', and so on. Each possibility on the flow chart has to be handled by your code.

    Specifically here, you can look at the window that the player uses in the Select Item event command (I don't remember what that window is called but you should be able to find it). That window is the closest to what you're doing with choices while on the map scene. It should have handlers for 'ok' and 'cancel' that are defined, so you could do something similar in order to control what happens on 'ok' and 'cancel'.
  7. Alright, thanks I'll experiment on that later. For now, I'll put this for a short rest and sleep (it's 1 AM). I'll continue this later. Thank you!
  8. With a bit of experimentation, I managed to make everything flow as intended... I was even able to add the result of the fusion (Yay!)
    This is the hard part, I guess, which is opening a new window that displays the status of the result (only for those that are valid. If not, then buzzer will play). This window would also have the option that asks the player if he wants to proceed with the fusion or not. If not, he goes back to the previous screen (Window 2). If yes, then proceed fusion (add in the new member to party, remove the two ingredients from current party).
    I'm having trouble disabling selection for invalid entries, as well as making a new window (I tried copying the window_status menu, but it doesn't have the option asking the user to select yes or no on it).
  9. I cleaned up the code a bit to reduce the number of windows from 4 to 2... but now, the help window isn't updating, and the game crashes if I try to select the result...

    EDIT:
    I did a small workaround by temporarily adding the result as a party member so we can display the result... I found out why the game crashes...
    The issue now is that the results window remains to be open unless I opened the game menu and exit it. Aside from that, I do not know how to proceed adding in the option window on the results window (an option that asks the player 'yes' or 'no'. Yes would mean that the result is permanently added to the party. No, means player goes back to the previous screen).