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
219
Reaction score
119
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,957
Reaction score
2,292
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
219
Reaction score
119
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,957
Reaction score
2,292
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
219
Reaction score
119
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,112
Reaction score
5,963
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

Folks, if anyone sends you a message inviting you to add their API to your game, please report them. We don't want people spamming our members asking them to add stuff to their games for their own (or others') benefit.
I'm listening to iiluminaughtii talking about the secrets behind shady businesses and scams. Meanwhile I'm writing a fanfic about Sephiroth from FF7, one specifically for my stepmom. I'll get to give it to her, too, because my boss said I could take the holidays off! Dec. 22-27 I will be in Orlando, and maybe Fort Myers too, visiting my dad and stepmom!
Of course, I bought a handful of games on the Steam Black Friday sale. Will I try them? Will I complete any? Who knows...
I don't really have any neat updates today about how I screwed up programming... But if you want to observe the intensenes of me programming, then you can check out my stream :)
New Weapons.gif
No more spam from me today, I promise! Just wanted to upload this, people have been giving me feedback that my weapon sprites (which were RTP) clashed badly with my battlers for ages, so today I finally took the plunge and updated them! Really happy with how they came out :D :D

Forum statistics

Threads
117,010
Messages
1,103,787
Members
152,906
Latest member
Heru_
Top