Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: Gaining/Losing Item Script Call Help
- Original author: Rink27
- Original date: July 18, 2016
- Source thread: https://forums.rpgmakerweb.com/threads/gaining-losing-item-script-call-help.65509/
- Source forum path: Game Development Engines > Legacy Engine Support > RPG Maker MV Support
Summary
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);
Archived First Post
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.
Protected download
Protected download
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.
Protected download
Protected download
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadReferenced Images / Attachments
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...

