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
232
Reaction score
130
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,976
Reaction score
2,299
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
232
Reaction score
130
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,976
Reaction score
2,299
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
232
Reaction score
130
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,115
Reaction score
5,968
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

I'm just so close to replacing LUK with a different stat, maybe DEX but we'll see.
Slapped together a title screen and working on some dungeon clutter + portraits for Dubhghaill and Einar. Usual CW for minor body horror wrt Einar
QVLJIgD.png

OaPcYUy.png

r55FiUJ.png

EIgO94y.png
cT1V4nb.png
>studying for months for an exam
>does exam
>waits 3 months for the results to come out
>me trying to login, incorrect password
>I get recovery password
>me trying to login, incorrect password

What the heck. As a son of a Karen, I'm going to file a few complaints.

Forum statistics

Threads
117,145
Messages
1,104,938
Members
153,214
Latest member
jzu1999
Top