Jump to content

Find the amount of free inventory spaces


Beefy Kasplant

Recommended Posts

Ever made an event where you give multiple items? Ever thought about how it would break horribly if the person has free inventory spaces, but not enough to receive all items?

 

Well, do I have the SOLUTION for you! Just check how many free inventory spaces the guy has bro! 

 

First, create an invisible item: InvCheck (Can be any name of course)

 

Player Variables: 

FreeSpaces

InvCheckItemHeld

 

Common Event:

 

Set PV FreeSpaces to 0 
Set PV InvCheckItemHeld to 0 -> These two first lines are to reset the system

Label: StartLoop  -> This is the start of the loop to check how many free spaces the person has

Give Item: InvCheck

SUCCESS: 

Add PV FreeSpaces +1

Add PV InvCheckItemHeld +1

Go to label: StartLoop -> If it succeeds, this means there is a free inventory slot, it goes to the start of the loop to try again until it fails.

FAIL:

Show text: You have \pv {FreeSpaces} free inventory slots 

Label: TakeInvCheckItem -> This is the loop to take the inventory checker items until they are all gone.

Take Item: InvCheck

SUCCESS:

Go to label: TakeInvCheckItem -> This will keep going until all InvCheck items are gone

 

 

You can put this common event before any event that gives multiple items, and just add a conditional branch in which you check if PV FreeSpaces is high enough to continue giving the actual items.

 

 

NOTE ALERT NOTE ALERT: I did this without an editor and without checking, so please let me know if there are ways to improve or bugs in this event! 

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...