I need the function that adds item to the player

Aura_Gamer

Villager
Member
Joined
Jun 24, 2018
Messages
18
Reaction score
2
First Language
English
Primarily Uses
RMMV
Hello I'm trying to create a script(which is currently empty) which displays the message: found item name!
:MV3:
I tried finding the function which is called when player receives an item but no luck ;_;;_;:kaocry:

Can someone tell me how to do it?
Thanks in advance!!!!!!!!!! :kaojoy:
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
search the forum - there is a pinned topic listing all script equivalents of all event commands, that is where you'll find it.
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
163
Reaction score
243
First Language
French, German
Primarily Uses
RMMZ
It's in rpg_objects.js, starting with the Game_Interpreter at line 9597:
Code:
// Change Items
Game_Interpreter.prototype.command126 = function() {
    var value = this.operateValue(this._params[1], this._params[2], this._params[3]);
    $gameParty.gainItem($dataItems[this._params[0]], value);
    return true;
};
You now know what code the event calls.
The function is defined at line 4991:
Code:
Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
    var container = this.itemContainer(item);
    if (container) {
        var lastNumber = this.numItems(item);
        var newNumber = lastNumber + amount;
        container[item.id] = newNumber.clamp(0, this.maxItems(item));
        if (container[item.id] === 0) {
            delete container[item.id];
        }
        if (includeEquip && newNumber < 0) {
            this.discardMembersEquip(item, -newNumber);
        }
        $gameMap.requestRefresh();
    }
};
 

Aura_Gamer

Villager
Member
Joined
Jun 24, 2018
Messages
18
Reaction score
2
First Language
English
Primarily Uses
RMMV
Nice but can someone tell me how can I know the item id of the item added???
 

OmnislashXX

Veteran
Veteran
Joined
Mar 30, 2012
Messages
599
Reaction score
3,686
First Language
English
Primarily Uses
RMMV
Actually, I put together a system that sets the variable of an item, then call the variable of the item and then goes to a common event that displays the value of the Item. Quite useful.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,674
First Language
German
Primarily Uses
RMMV
Nice but can someone tell me how can I know the item id of the item added???
you are the one who decides what item the player should get, so you set the ID of the item to be added and include that in the function call
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
163
Reaction score
243
First Language
French, German
Primarily Uses
RMMZ
Nice but can someone tell me how can I know the item id of the item added???
It's easier to help if we know what you're doing and what you're trying to do. For example, show us the code you're currently using and tell us what part isn't working.

Right now, I'm assuming you're writing a plugin that overrides Game_Party.prototype.gainItem(item, amount, includeEquip) and want to know the Id of the item that's been added.
In that case, simply use item.id
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top