Gaining/Losing Item Script Call Help

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Hello.

I am trying to force the player to enter battle with a limited number of items.

1) I use the Select Item command and then the script call: 
$gameParty.loseItem($dataItems[$gameVariables.value(28)], 1);

To save 1 selected item.

2) I then switch the party inventories using another plugin and use another script call:
$gameParty.gainItem($dataItems[$gameVariables.value(28)], 1);

To regain the selected items, thus by repeating this method the player would have only the selected items in battle. This worked.

3) However, the script call only loses/gains one item. If the player had 4 potions, for example, I would like all 4 potions to be lost/gained in one go.
Thus, I checked if a particular item was selected from the initial Select Item command and set another variable to count the possession count of this item.

4) So for example: If Item ID#2 selected, this other variable = possession count of item ID#2 

I then changed the script call to:
$gameParty.loseItem($dataItems[$gameVariables.value(28)], [$gameVariables.value(25)]);  

5) Now, I am able to lose the exact amount of the item I select. However:
$gameParty.gainItem($dataItems[$gameVariables.value(28)], [$gameVariables.value(25)]);  

Does not regain the same amount of the selected item. Instead I get an error: 
undefined is not a function

What am I doing wrong?
How can I regain the same amount of the item selected?
Is there a more efficient method to do step 4 instead of having a conditional branch check for every item (If I have to do this, I'd run it via a common event)

I have included images of my code. The inventory switch script call is not the problem as I've removed it and still obtained the same error message.


H1.PNG


H2.PNG
 
Last edited by a moderator:

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,867
Messages
1,017,062
Members
137,575
Latest member
akekaphol101
Top