RMMV How to get the "selected item" object into a Window object? (SOLVED)

Status
Not open for further replies.

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
243
Reaction score
137
First Language
Swedish
Primarily Uses
N/A
Been trying to figure this out now for some time, and so far I've been sliding along on stealing the this._item from other windows to make it work. But I really feel I am missing something important... I've gone over both Shop and Equip scene and I don't find anything that seems to get the selected item from the window list. There's some things like W.setItem(item). But then you need to put in an item as an argument, and these functions seem to set the item for other functions.

Thanks for all help! :)

Was unclear in my last question, so sleepy and brain is exhausted from seeing nothing but code for 15 hours :p But I hope these pictures, from the console, explains what I want.
**************************************
1634859221754.png
**************************************
1634859249903.png
**************************************
So just like in the shop(Scene)'s statusWindow I want the equipScene's statusWindow to have the _item object as well :/

Best regards,
Bishiba
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,986
Reaction score
2,304
First Language
EN
Primarily Uses
RMMZ
When a scene creates a selectable window, it typically assigns handlers for various responses, e.g.
JavaScript:
Scene_Equip.prototype.createItemWindow = function() {
// ...
    this._itemWindow = new Window_EquipItem(wx, wy, ww, wh);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setStatusWindow(this._statusWindow);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
// ...
};
Since the responses are methods of the scene, this makes it easy to access other windows, e.g.
JavaScript:
Scene_Equip.prototype.onItemOk = function() {
    SoundManager.playEquip();
    this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
// ...
};
Basically, windows handle their own stuff, and the scene handles interactions between them.

(Usually, anyway.)
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
243
Reaction score
137
First Language
Swedish
Primarily Uses
N/A
When a scene creates a selectable window, it typically assigns handlers for various responses, e.g.
JavaScript:
Scene_Equip.prototype.createItemWindow = function() {
// ...
    this._itemWindow = new Window_EquipItem(wx, wy, ww, wh);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setStatusWindow(this._statusWindow);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
// ...
};
Since the responses are methods of the scene, this makes it easy to access other windows, e.g.
JavaScript:
Scene_Equip.prototype.onItemOk = function() {
    SoundManager.playEquip();
    this.actor().changeEquip(this._slotWindow.index(), this._itemWindow.item());
// ...
};
Basically, windows handle their own stuff, and the scene handles interactions between them.

(Usually, anyway.)
Trying to send the currently selected item in the itemlist of the equipmenu to the status menu. So That is what I am trying to do right now :/
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,986
Reaction score
2,304
First Language
EN
Primarily Uses
RMMZ
Notice this line from my previous post, in the first block of code I quoted:
JavaScript:
    this._itemWindow.setStatusWindow(this._statusWindow);
This gives the item window a reference to the corresponding status window:
JavaScript:
Window_EquipItem.prototype.setStatusWindow = function(statusWindow) {
    this._statusWindow = statusWindow;
    this.callUpdateHelp();
};
The item window can then use this reference to send data to the status window:
JavaScript:
Window_EquipItem.prototype.updateHelp = function() {
    Window_ItemList.prototype.updateHelp.call(this);
    if (this._actor && this._statusWindow) {
        var actor = JsonEx.makeDeepCopy(this._actor);
        actor.forceChangeEquip(this._slotId, this.item());
        this._statusWindow.setTempActor(actor);
    }
};
In this case it's a "temporary actor", used to determine the change in stats that would result from equipping the selected item. :kaohi:
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
243
Reaction score
137
First Language
Swedish
Primarily Uses
N/A
Notice this line from my previous post, in the first block of code I quoted:
JavaScript:
    this._itemWindow.setStatusWindow(this._statusWindow);
This gives the item window a reference to the corresponding status window:
JavaScript:
Window_EquipItem.prototype.setStatusWindow = function(statusWindow) {
    this._statusWindow = statusWindow;
    this.callUpdateHelp();
};
The item window can then use this reference to send data to the status window:
JavaScript:
Window_EquipItem.prototype.updateHelp = function() {
    Window_ItemList.prototype.updateHelp.call(this);
    if (this._actor && this._statusWindow) {
        var actor = JsonEx.makeDeepCopy(this._actor);
        actor.forceChangeEquip(this._slotId, this.item());
        this._statusWindow.setTempActor(actor);
    }
};
In this case it's a "temporary actor", used to determine the change in stats that would result from equipping the selected item. :kaohi:
Yes, as you've noticed I did just comment on that post. Then I saw this. Alright, I shall look into this a bit more. This might be the better way to do it rather than my answer on the other thread. These two threads should've probably been the same to be honest.

Been going over it and I understand it now! :D
 
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,116
Reaction score
5,971
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

aww man, color hex code #C4C4C4 doesn't work for the tint value in this scene I need something darker, which stinks just because I liked that one it was my favorite plastic explosive three times...#696969 (nice) should work better (WHY IS MY BRAIN LIKE THIS)
Tell it to me straight, doc. If I've been trying to piece together a "shorter" game to learn stuff outside of game jams... am I just running away from my WIP? :v
Well, I've got a party tomorrow, and my friends are coming over. I wanted to work a bit on the Fandom Scouts assets so I can be ready when that update arrives... in other news, Pizza Time Horror is getting a second teaser, and it shows Cabaret Helen's last performance before the location closed.
Also who used to be scared of Chuck E as a kid? I was! Now I love him!
The new cards and what they do:

(I am clearly not a youtuber... Haha)

Forum statistics

Threads
117,275
Messages
1,106,055
Members
153,450
Latest member
BRCMuller
Top