inventory limit

Good afternoon, I am programming my videogame and I was programming an engine of capacity of objects in the inventory, in which you can only take 6 and when you find one you get a message that you can not collect it.

I made a mechanism in which when picking up an object a variable would add a value of +1 and when it reaches 6 that message would appear, and the adjustment according to the amount of a certain object will be automatic, but in the same way it allows me to collect more inventories and the variable returns to 1 ....


n3jQIU1


I'm not sure exactly why it's doing what it's doing, but you want to make it so that it's either less than or equal to 5; else if it's equal to 6. That's it, you don't need a third thing. Maybe you're just confusing it, I dunno, but there should be no way for it to go over 6, so saying if it's greater than or equal to 6 doesn't make sense, nor does it make sense to have it twice (because you already have equal to 6 covered by "greater than or equal to" but you don't actually need the "greater than" part). And it should be less than or equal to 5, otherwise you're giving two different commands for what to do if it's equal to 6.
I'm not sure exactly why it's doing what it's doing, but you want to make it so that it's either less than or equal to 5; else if it's equal to 6. That's it, you don't need a third thing. Maybe you're just confusing it, I dunno, but there should be no way for it to go over 6, so saying if it's greater than or equal to 6 doesn't make sense, nor does it make sense to have it twice (because you already have equal to 6 covered by "greater than or equal to" but you don't actually need the "greater than" part). And it should be less than or equal to 5, otherwise you're giving two different commands for what to do if it's equal to 6.



for the same, when collecting an object the variable adds 1 then if you have 6 objects it should be equal to 6 and your bag should be full
No I know what you're trying to do. What I mean is, I'm not sure what all your event is actually doing, partly bc it's in a language I can't read. But let me again go over what you should be doing in this event:

You have the big main IF statement up top, right? No idea what that is checking BUT below that you have three If/Else statements. The first one is "IF inventory is equal to or greater than 6." You do NOT need this check at all, period.

Next one is "IF inventory is equal to or less than 6." This SHOULD be "IF inventory is equal to or less than 5." Why? Because when it's "equal to" 5, it will add one to the inventory variable, making it 6. In your set up, you would give the player 7 instead of 6. The other issue is that both this statement and the one above it are checking whether it's equal to 6, and telling it to do two different things. That doesn't work.

Last one is "IF inventory is equal to 6." Leave this one alone. This one works. Realize that with this one, you'll never have to worry about it being "greater than 6." It can't go past 6 so long as you have this statement!
No I know what you're trying to do. What I mean is, I'm not sure what all your event is actually doing, partly bc it's in a language I can't read. But let me again go over what you should be doing in this event:

You have the big main IF statement up top, right? No idea what that is checking BUT below that you have three If/Else statements. The first one is "IF inventory is equal to or greater than 6." You do NOT need this check at all, period.

Next one is "IF inventory is equal to or less than 6." This SHOULD be "IF inventory is equal to or less than 5." Why? Because when it's "equal to" 5, it will add one to the inventory variable, making it 6. In your set up, you would give the player 7 instead of 6. The other issue is that both this statement and the one above it are checking whether it's equal to 6, and telling it to do two different things. That doesn't work.

Last one is "IF inventory is equal to 6." Leave this one alone. This one works. Realize that with this one, you'll never have to worry about it being "greater than 6." It can't go past 6 so long as you have this statement!



Sorry I speak Spanish by seo do not understand the haha language, let me see if I understand you xD ... you say that the solution is to eliminate the first conditional derivation ... the second one I put 5 instead of 6 and the third one also change for a 5?
The third one you leave alone. Think of it like this: if you made all of the If/Else statements into equals it would look like this:

1) If variable = 0, give player an item, add 1 to variable - so this is how the variable starts out. It starts at 0. So this is the first interaction the player would have, when he has no items at all. So you have increased his items by 1 and increased the variable by 1.
2) if variable = 1, give player an item, add 1 to variable - now he has two items, and the variable is set to 2 at the end.
3) if variable = 2, give player an item, add 1 to variable - now he has three items, and the variable is set to 3.
4) if variable = 3, give player an item, add 1 to variable - now he has four items, and the variable is set to 4.
5) if variable = 4, give player an item, add 1 to variable - now he has five items, and the variable is set to 5.
6) if variable = 5, give player an item, add 1 to variable - now he has six items, and the variable is set to 6.

so that's why you only want it to be equal to or less than 5, instead of 6. you don't want the player to get 7 items, only 6.

The last If/Else should be if the variable = 6, tell the player his inventory is full. There's no way to go above 6 so long as you have this statement, so there's no reason to add greater than 6 to it. The variable will never be greater than 6 if you cut it off at 6.
All you really need is

♦ Si: Inventario ≥ 6
♦ Texto
: Otro
♦ Control de las variables
♦ Cambiar articulos
etc.

Because then it gives you one more if you have less than 6. You don't need more than one conditional for this :--)
This is all true, though I would still set it up like this instead:

If Inventory is < (less than) or = (equal to) 5
- give item
- add one to inventory variable
- turn on self switch B

Else
- display text "your inventory is full"

That's probably just a personal preference, though.

The other thing I noticed is that you are doing a control variable "inventory" = something in Spanish (I think it has to do with the items in the database?) "El numero de llave del jardin" I don't think you need this. You're just using a number for this, so this might also be confusing the program.

One other thing: if you plan on giving usable items (like a healing item, for instance), you can set up a common event to subtract 1 from your inventory variable, and then set the item to call that common event in the "effects" section of the item tab in your database.
This is all true, though I would still set it up like this instead:

If Inventory is < (less than) or = (equal to) 5
- give item
- add one to inventory variable
- turn on self switch B

Else
- display text "your inventory is full"

That's probably just a personal preference, though.

The other thing I noticed is that you are doing a control variable "inventory" = something in Spanish (I think it has to do with the items in the database?) "El numero de llave del jardin" I don't think you need this. You're just using a number for this, so this might also be confusing the program.

One other thing: if you plan on giving usable items (like a healing item, for instance), you can set up a common event to subtract 1 from your inventory variable, and then set the item to call that common event in the "effects" section of the item tab in your database.



El numero de llave del jardin this Number of Item (Llave del jardin in english its Garden Key xD)
I could solve the problem literally basic, now the advanced is missing ... I use a combination plugin of yanfly Craflyng syntesys I think it is called and good when combining objects 2 for example I should delete the variable .. I imagine it would be by means of a script command or something advanced but no idea .. excuse my thousands of questions, my strength is the composition of music xD
I also use the PH_Warehouse plugin from Primerhover, which should change the variable when depositing an object by using some command
Yeah I recognized number and garden so I was a bit confused. XD If you're using a plugin that changes the variable then... never mind what I said about common events. I wasn't sure of what kinds of systems your game would have in it.
no, your solution was the correct hahaha, only that as I also use those complements I should do something more in the case when depositing an object or combining, I imagine that through a common event it would not work? ......
Yeah I recognized number and garden so I was a bit confused. XD If you're using a plugin that changes the variable then... never mind what I said about common events. I wasn't sure of what kinds of systems your game would have in it.

Original thread: https://forums.rpgmakerweb.com/threads/inventory-limit.103852/