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 Profile Posts

"Yeah. It's been a rough road lately. But that's the thing about the Rangers. It doesn't matter how hard it gets, or how many of them fall. They never stop fighting. The Rangers NEVER stop fighting".

Angela Deth, you are a hero of mine. Sorry for my first run of Wasteland 3.
We must press on. For all those we couldn't save. For all those we might yet save.
FirestormNeos wrote on DarkPlasmaBall's profile.
asking this here instead of the thread in question to avoid derailing it, but I'm curious; is there a particular reason you'd include a "Terms of Use" for an RPG Maker game? Like, are there multiplayer features for the game you're working on?
The holidays are upon us! Everyone search for safety from the grocery store music!
I don't understand people sometime. Walking to work today came across someone walking the opposite way in a nice suit, I politely move to the side into the shrubbery so he doesn't have to get his suit dirty and say "good morning" as he passes me, he turns around glaring daggers and asks "why are you talking to me?" like he's bloody offended by me wishing him a good morning or something. Just, why?

Forum statistics

Threads
117,136
Messages
1,104,886
Members
153,201
Latest member
OpalWysty
Top