Sakurra

I want a brownie.
Veteran
Joined
Sep 1, 2015
Messages
663
Reaction score
588
First Language
English
Primarily Uses
RMMV
I'm testing an idea I had for an item storage system. (I know they are a lot of work, I haven't fully committed to this idea yet lol)
So far it's working but I've run into one problem. If the player has 90 cookies and over 100 in storage, how do I withdraw only 9 cookies?

Same in reverse. If I decide the player can only store 999 cookies, how do I deposit cookies and stop at 999? The player loses cookies in the process.

I figure this is maybe script related.
Thanks for reading.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,544
Reaction score
14,852
First Language
English
Primarily Uses
RMMV
Withdraw:
Set variable A to the number of cookies the player could possibly hold (99).
Subtract from variable A the number of cookies the player is actually holding (90).
Leaves you with 9 - the number of cookies the player can take from storage.
Set variable B to the number of cookies IN storage.
If A is less than B, then the player can take A cookies (9).
If B is less than A, then the player can take B cookies.

Deposit:
Set variable A to the number of cookies that can be stored (999).
Subtract from variable A the number of cookies that are actually in storage.
Set variable B to the number of cookies the player currently has.
If A is less than B, then the player can put A cookies into storage.
If B is less than A, then the player can put B cookies into storage.


In both cases, it's all done with Control Variables and Conditional Branches.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
596
Reaction score
267
First Language
PT-BR
Primarily Uses
RM2k3
Hello!
The storage of cookies may end up expiring, try to create an Object or Array within the game's own variables:
JavaScript:
$gameVariables.itemStorage = [];

The order of each array will be equivalent to the item ID, thus being able to separate, similar to the classic monetary bank made with Events.

I don't know how to explain a lot why I don't know how you are actually doing this system.
But in this example, the item limit you can take out of storage is calculated using what you have with the party:
JavaScript:
var item_lmt = 99 - $gameParty._items[selected];
("selected" is an example of a menu variable or any method you used to create this system.)

Good luck
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,544
Reaction score
14,852
First Language
English
Primarily Uses
RMMV
I assumed "cookies" just referred to an item in the game, not the internet-type cookies you get from browsers.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
596
Reaction score
267
First Language
PT-BR
Primarily Uses
RM2k3
@Shaz But you're right, I got it wrong.
Sorry, I couldn't stand it, I spent about 2 minutes laughing at my misinterpretation.
 
Last edited:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,544
Reaction score
14,852
First Language
English
Primarily Uses
RMMV
Just to confirm - are you doing this all via eventing, or are you using an item storage plugin? If you're using a plugin, my suggestion will still be close, but you'll need to do something slightly different to get the number currently in storage and the maximum storage capacity.
 

Sakurra

I want a brownie.
Veteran
Joined
Sep 1, 2015
Messages
663
Reaction score
588
First Language
English
Primarily Uses
RMMV
Just to confirm - are you doing this all via eventing, or are you using an item storage plugin? If you're using a plugin, my suggestion will still be close, but you'll need to do something slightly different to get the number currently in storage and the maximum storage capacity.

I'm trying to do this via eventing to see what it's like. I was using the command
◆Change Items:Cookie + {99max var A}

but I haven't succeeded in making the event work and didn't want to bother anyone anymore till I re read what you posted and kept play testing. (Because the odds are I'm doing something wrong)

So I'll just keep at it. If I still have problems, I'll post up a screenshot and if I finally put the event together correctly, I will update the post to let everyone know I got it working.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,544
Reaction score
14,852
First Language
English
Primarily Uses
RMMV
What is {99max var A}? Did you actually put that into the script box? That is not Javascript syntax so will not work.

You would need to do it via variables as I showed you anyway, because you will have to add a variable number of cookies to the player's inventory, and deduct the same variable number of cookies from storage, so it's going to take 2 commands.
 

Sakurra

I want a brownie.
Veteran
Joined
Sep 1, 2015
Messages
663
Reaction score
588
First Language
English
Primarily Uses
RMMV
What is {99max var A}? Did you actually put that into the script box? That is not Javascript syntax so will not work.

You would need to do it via variables as I showed you anyway, because you will have to add a variable number of cookies to the player's inventory, and deduct the same variable number of cookies from storage, so it's going to take 2 commands.

It is when I copied as text using Rpg Maker. (And then pasted here) The 99max var A is the name of the variable. I guess when you copy and paste code from RPG maker MV they add syntax? You can right click copy as text in Rpg Maker.

I was using the command to change items based on variable. (And I named it var A so I could have a visual...^^)

I've been busy and have not gotten back to this. I think it's one of those errors that should be obvious that's misguiding me. Your post looks great so it's obviously an error on my end. When I have the time I'll look over my event again.

I'm not using script or javascript. Just trying to do what you posted. Thanks btw! When I get it working I will update this post.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,544
Reaction score
14,852
First Language
English
Primarily Uses
RMMV
Can you post a screenshot of your event?
 

Sakurra

I want a brownie.
Veteran
Joined
Sep 1, 2015
Messages
663
Reaction score
588
First Language
English
Primarily Uses
RMMV
I think I understand the concept but I'm having trouble wrapping my brain around how it is actually done.

Also is there an easier way to get screenshots from Rpg Maker MV?

Thank you for taking a look.
 

Attachments

  • cookiestorage.png
    cookiestorage.png
    126.1 KB · Views: 3

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,544
Reaction score
14,852
First Language
English
Primarily Uses
RMMV
Apparently you can select the event commands and right-click, and there is a copy to text option. Then you can just come here and paste.

It's a bit hard to tell what your variables are, and whether you're using the same variable in multiple places. Would you like to zip up your Map###.json file and your System.json file and send them to me? That will let me look at the event and the variables. If you like (and it would be easier for me) you can create a brand new map and just copy this event onto it.
 

Sakurra

I want a brownie.
Veteran
Joined
Sep 1, 2015
Messages
663
Reaction score
588
First Language
English
Primarily Uses
RMMV
I know how to zip a file but can that even be uploaded here? I feel like I'm causing you too much trouble than it should. It's my fault I'm having trouble understanding.

Would it also be easier if you just redid your post here?
Withdraw:
Set variable A to the number of cookies the player could possibly hold (99).
Subtract from variable A the number of cookies the player is actually holding (90).
Leaves you with 9 - the number of cookies the player can take from storage.
Set variable B to the number of cookies IN storage.
If A is less than B, then the player can take A cookies (9).
If B is less than A, then the player can take B cookies.

Deposit:
Set variable A to the number of cookies that can be stored (999).
Subtract from variable A the number of cookies that are actually in storage.
Set variable B to the number of cookies the player currently has.
If A is less than B, then the player can put A cookies into storage.
If B is less than A, then the player can put B cookies into storage.


In both cases, it's all done with Control Variables and Conditional Branches.

I think it would help me if Variables A and B had names. For a visual. It looks like four variables are used for this kind of event.

1. The number of cookies held
2. The number of cookies in storage
3. A number to ensure you don't go over the max of 99 or 999
4. What number the player inputted

but I don't see where would Change item based on the variable would go? I thought variables would help determine how much items are deposited or withdrawn with a conditional branch that checks for certain conditions.
 

Latest Threads

Latest Posts

Latest Profile Posts

When there's a will, there's a lifehack. :ninja:

Before i mess with battle UI further, does it look decent enough? :hswt:
Free MZ? That's good. I should go try it out then.
Let's see if I can make it in time xD
Knipsel.PNG

Forum statistics

Threads
112,522
Messages
1,068,892
Members
146,201
Latest member
squirrelears
Top