RMMV Help with changing Menu Picture Display from Item Scene to Equip Scene

Momma_Robotnik

Villager
Member
Joined
Jul 2, 2021
Messages
17
Reaction score
7
First Language
Romanian
Primarily Uses
RMMV
Hey everyone, I've been using MV for a while now and decided to add a new window in the equip menu with preview pictures for the weapons you find. I found some code made by user caethyrll but it only appears for the item menu, while i want it to appear on the equip menu:
Here's said code:

/*:
* @plugindesc Shows item pictures when browsing your inventory!
* @Author
* @plugindesc Put a <name:text> icon on items to assign them a picture.
* Replace "text" with the picture's name, e.g. "item1" for "item1.png".
* All pictures are loaded from img/pictures.
*
* @noteParam name
* @noteRequire 1
* @noteDir img/pictures/
* @noteType file
* @noteData items
*/
// ^ See Help > Documentation > [Exclude unused files] Plugin Configuration //

(function() {
'use strict';

// ===== (NEW) Window_ItemPictures ===== //

/** @constructor */
window.Window_ItemPictures = function() { this.initialize.apply(this, arguments); };

Window_ItemPictures.prototype = Object.create(Window_Base.prototype);
Window_ItemPictures.prototype.constructor = Window_ItemPictures;

// Called on construction
Window_ItemPictures.prototype.initialize = function(x, y) {
var w = 100, h = 100;
Window_Base.prototype.initialize.call(this, x, y, w, h);
this._image = new Sprite();
this.addChild(this._image);
};

// Update image bitmap appropriately
Window_ItemPictures.prototype.refresh = function() {
let bmp = new Bitmap();
if (this._imageName) bmp = ImageManager.loadPicture(this._imageName);
this._image.bitmap = bmp;
};

// Returns the value of the specified item's "name" notetag
Window_ItemPictures.prototype.readTag = function(item) {
if (item) {
let tag = item.meta.name;
if (tag && tag !== true) return tag.trim();
}
return '';
};

// Update image name
Window_ItemPictures.prototype.setItem = function(item) {
this._imageName = this.readTag(item);
this.refresh();
};

// ===== (ADD) Extensions for existing scenes and windows ===== //

// Add new window to item scene (inventory)
(function(alias) {
Scene_Item.prototype.create = function() {
alias.call(this);
this._itemPicsWindow = new Window_ItemPictures();
this.addWindow(this._itemPicsWindow);
this._itemWindow._itemPicsWindow = this._itemPicsWindow;
};
})(Scene_Item.prototype.create);

// Refresh item picture window when selected item changes
(function(alias) {
Window_ItemList.prototype.select = function(index) {
alias.apply(this, arguments);
this.refreshWindowItemPics(this.item());
};
})(Window_ItemList.prototype.select);

// New method: update the associated item picture window
Window_ItemList.prototype.refreshWindowItemPics = function(item) {
if (this._itemPicsWindow) this._itemPicsWindow.setItem(item);
};

})();


I was wondering if i can just change some values to make it work, i tried changing all the instances of the word "item" to "weapon" but no luck. Any help would he very appreciated, thank you.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,902
Reaction score
2,963
First Language
EN
Primarily Uses
RMMZ
Here's the code quoted directly from that thread:
JavaScript:
/*:
 * @plugindesc Shows item pictures when browsing your inventory!
 * @author
 * @plugindesc Put a <name:text> icon on items to assign them a picture.
 * Replace "text" with the picture's name, e.g. "item1" for "item1.png".
 * All pictures are loaded from img/pictures.
 * 
 * @noteParam name
 * @noteRequire 1
 * @noteDir img/pictures/
 * @noteType file
 * @noteData items
 */
// ^ See Help > Documentation > [Exclude unused files] Plugin Configuration //

(function() {
'use strict';

// ===== (NEW) Window_ItemPictures ===== //

    /** @constructor */
    window.Window_ItemPictures = function() { this.initialize.apply(this, arguments); };

    Window_ItemPictures.prototype = Object.create(Window_Base.prototype);
    Window_ItemPictures.prototype.constructor = Window_ItemPictures;

    // Called on construction
    Window_ItemPictures.prototype.initialize = function(x, y) {
        var w = 100, h = 100;
        Window_Base.prototype.initialize.call(this, x, y, w, h);
        this._image = new Sprite();
        this.addChild(this._image);
    };

    // Update image bitmap appropriately
    Window_ItemPictures.prototype.refresh = function() {
        let bmp = new Bitmap();
        if (this._imageName) bmp = ImageManager.loadPicture(this._imageName);
        this._image.bitmap = bmp;
    };

    // Returns the value of the specified item's "name" notetag
    Window_ItemPictures.prototype.readTag = function(item) {
        if (item) {
            let tag = item.meta.name;
            if (tag && tag !== true) return tag.trim();
        }
        return '';
    };

    // Update image name
    Window_ItemPictures.prototype.setItem = function(item) {
        this._imageName = this.readTag(item);
        this.refresh();
    };

// ===== (ADD) Extensions for existing scenes and windows ===== //

    // Add new window to item scene (inventory)
    (function(alias) {
        Scene_Item.prototype.create = function() {
            alias.call(this);
            this._itemPicsWindow = new Window_ItemPictures();
            this.addWindow(this._itemPicsWindow);
            this._itemWindow._itemPicsWindow = this._itemPicsWindow;
        };
    })(Scene_Item.prototype.create);

    // Refresh item picture window when selected item changes
    (function(alias) {
        Window_ItemList.prototype.select = function(index) {
            alias.apply(this, arguments);
            this.refreshWindowItemPics(this.item());
        };
    })(Window_ItemList.prototype.select);

    // New method: update the associated item picture window
    Window_ItemList.prototype.refreshWindowItemPics = function(item) {
        if (this._itemPicsWindow) this._itemPicsWindow.setItem(item);
    };

})();
(On this site you can format text as code using the </> formatting button.)

You'd need to change things specifically for the equip scene, which means checking how that scene is coded. For example, the default equip scene (Scene_Equip, rpg_scenes.js) has two windows where you can select items: current equips (Window_EquipSlot) and inventory (Window_EquipItem).
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,993
Reaction score
2,280
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
Since you posted it on learning javascript, I guess your first steps would be understanding how the Scene Equips works as caethyril said.

First, you need to find a way to attach the pictures to specific equipment data. I suggest a meta note tag like <MyPicture: PictureName>

Then, you need to extend the select functions of the Window_EquipSlot and/or the Window_EquipItem to check if there is a piece of equipment selected, and if it has, show the picture attached to that equipment.

The picture needs to be a sprite, so you also have to understand how to add a sprite to the scene.

But if you are not looking for a wat on "how to do this", but instead, just want a solution for your problem, tell here that I can suggest some plugins.
 

Momma_Robotnik

Villager
Member
Joined
Jul 2, 2021
Messages
17
Reaction score
7
First Language
Romanian
Primarily Uses
RMMV
Thank you very much to both of you. I think i get the basic gist of it now, i truly appreciate it. Everything works nice now!
 

Latest Threads

Latest Posts

Latest Profile Posts


Clarn Hold
(No storylines)
There was a tutorial on how to draw anime eyes. Just draw Among Us. So I tried.
Screenshot_107.jpg
DamageActor3_7.png added!
index.php

Making a "characters first appearance" drawing for my game. Now I just have to finish the sprite art animation for her grand entrance.​
ScreenShot_9_24_2022_7_56_24.png
New area being started today. It leads to one of the games 2 optional bosses.

Forum statistics

Threads
125,540
Messages
1,171,817
Members
164,613
Latest member
dulichvungtaudl3m
Top