Turn switch on when opening the menu for the first time

_Soysauce_

Villager
Member
Joined
Sep 12, 2018
Messages
19
Reaction score
5
First Language
English
Primarily Uses
RMMV
Well, this has to be (hopefully) the simplest request ever, but I couldn't find any solution through either google and forum searches.

I plan for my game to check when the player opens the inventory for the first time. In the grand scheme of things, it's just a small way to double-check if they have opened the inventory prior to a specific point, to which if they have not they are informed through dialogue what the key to press is.

Right now, I've got a parallel event that checks for the player to press "Cancel", and if they do a switch turns on.
Unfortunately, it's not quite enough, as players are free to press cancel during cutscenes or dialogues and the game will then believe they have opened the menu.

I'm assuming this is a fairly simple affair of checking the first time time the inventory screen has been opened (instead of checking for the button prompt itself) and turning a switch on - but as I'm totally ignorant when it comes to javascript, I hope someone can answer me back on this.

Thanks for the time!
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
942
Reaction score
500
First Language
Javascript
Primarily Uses
RMMZ
Last edited:

_Soysauce_

Villager
Member
Joined
Sep 12, 2018
Messages
19
Reaction score
5
First Language
English
Primarily Uses
RMMV
Whoa, thanks ct_bolt - that was quick!

I didn't know if I needed to bring this out right away (as I'm unaware of the ins and outs of javascript and Rpg Maker itself), but in my very specific case I'm only using the key item menu for my game, aided by NonCombatMenu_ItemOnly by mjshi and Astfgl Item menu (of which I cannot find any source anywhere anymore, and since it's quite short I'll just leave it below).

JavaScript:
//===================================================================================
// Astfgl Item menu
// Date 20/10/2017
// Free to use both commercialyy and non commercially, repost and
// edit, as long as the final product is kept under the same terms of use.
// Credits required, any of Astfgl, Astgfl (Pierre MATEO), Pierre MATEO
//====================================================================================

/*:
 * @plugindesc Item Menu
 * @author Astfgl
 * @help All parameters are evaled, meaning you can use a formula, or in game variables.
 * For example you can put $gameVariables.value(1) in the columns parameter field.
 * Then, each time you open the menu, the number of columns will be what's
 * inside variable 1.
 *
 * @param x
 * @desc The x coordinate of the item window
 * @default Graphics.boxWidth / 2 - SceneManager._scene._itemWindow.width / 2
 *
 * @param y
 * @desc The y coordinate of the item window
 * @default Graphics.boxHeight / 2 - SceneManager._scene._itemWindow.height / 2
 *
 * @param width
 * @desc The width coordinate of the item window
 * @default 300
 *
 * @param height
 * @desc The height coordinate of the item window
 * @default 500
 *
 * @param columns
 * @desc The number of columns
 * @default 1
 *
 *
 * @param category
 * @desc The starting category of the item list window. 'item','weapon','armor','keyItem'.
 * @default 'keyItem'
*/

(function(){
    var params = PluginManager.parameters("AstfglIM");
    
    var _Astfgl_newSIC = Scene_Item.prototype.create
    Scene_Item.prototype.create = function() {
        _Astfgl_newSIC.call(this);
        this._helpWindow.hide();
        this._categoryWindow.hide();
        this._categoryWindow.deactivate();
        this._categoryWindow.selectSymbol(eval(params.category));
        this.onCategoryOk();
        this._itemWindow.setHandler('cancel', this.popScene.bind(this));
        this._itemWindow.width = eval(params.width) || 0;
        this._itemWindow.height = eval(params.height) || 0;
        this._itemWindow.x = eval(params.x) || 0;
        this._itemWindow.y = eval(params.y) || 0;
    }
    
    Window_ItemList.prototype.maxCols = function() {
        return eval(params.columns);
    };
    
})()

As you said the switch is triggered by selecting the item command on the menu, it doesn't quite work in my case, right?
 

Piratepoots

aka Sir Onion Knight
Member
Joined
Feb 28, 2016
Messages
14
Reaction score
17
First Language
English
Primarily Uses
RMMV
Might not be the optimal way to do it (might not work too since I haven't tested and I'm a javascript noob) but I'd personally just put this under the Scene_Item.prototype.create line.
JavaScript:
$gameSwitches.setValue[x] == true
Just change x to the number for the switch you're setting.
 
Last edited:

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
942
Reaction score
500
First Language
Javascript
Primarily Uses
RMMZ
Whoa, thanks ct_bolt - that was quick!
I didn't know if I needed to bring this out right away (as I'm unaware of the ins and outs of javascript and Rpg Maker itself), but in my very specific case I'm only using the key item menu for my game, aided by NonCombatMenu_ItemOnly by mjshi and Astfgl Item menu
As you said the switch is triggered by selecting the item command on the menu, it doesn't quite work in my case, right?
Edited my file slightly, working great now ;)
Place below NonCombatMenu and Astfgl Item Menu (original thread: click to view)
1588468581773.png

PS.
Yes indeed please always give plugins used if there are any used as that will usually modify or impact the way the original code works.
 
Last edited:

_Soysauce_

Villager
Member
Joined
Sep 12, 2018
Messages
19
Reaction score
5
First Language
English
Primarily Uses
RMMV
Thanks, I tested it and it works like a charm!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

12 done, 4-5 started. Now that the weekend is over, things will sloooowwwww down again proabably.
when you're completely done with someone's crap lol...
Ami
--- Survival For RPGist Part 3 ---

F.Healer: Here it is,I made the Simple Sandwich
Survivalist
: it's so Delicious!
Chef: Here you Go! My Gourmet Steak.
Survivalist: It's Super Delicious,Too!
F.Mage: I Made it for you!
F.Healer: Uhh...Charcoal?
F.Mage No,It's a Toast!
Chef: Did you Let it in 10 Minutes?
F.Mage: Maybe?

Forum statistics

Threads
103,033
Messages
996,817
Members
134,507
Latest member
juegostudios
Top