Help me streamline my potion-brewing event

Hello, folks. I'm working on my first full RPG Maker game right now, A Forest of Smoke. The central mechanic is that the player will find Key Items in the form of ingredients, then mix them together to form potions that allow access to new areas. I've got a basic script for making a test potion from two ingredients together - see the images attached, and download the no-RTP file from the link in my signature to see it in action.

This WORKS, which I'm pretty proud of given how little I know of scripting in general. I ultimately intend the player to be able to make about a half dozen different potions, however, and I'm hoping to make them have a variable number of ingredients, all from this one cauldron interface event. I've got a feeling it's gonna get really messy really quickly. I don't want to have to deal with an incredibly long list of nested conditional branches, and I have a feeling I'm going to run out of self switches really quick. Does anyone have any advice on how I can streamline and organize this event, or general good-practice advice for organizing long scripts?

Thanks in advance!

CauldronInterfacePageOne.JPG CauldronInterfacePageThree.JPG CauldronInterfacePageTwo.JPG
First off, I just want to clarify that this is not a script. This is just an event that uses switches, conditionals, etc. Calling this a script could get confusing to some people.

Now about this event, what I can decipher from it is that you activate the "Cauldron". It checks how many of the "Test Potion Variable" you have in your inventory. If it is equal to 2, then that is Ingredient A, and if it is equal to 3 then that is Ingredient B. Is this right so far?

Next it seems kind of broken to me, so I'm not sure how it works. But it seems that if it checks and finds that the variable is equal to 3, then it activates Self Switch B and goes to page two. Then it checks if the same variable is equal to 2. If it is, it grants the item "Test Potion". However, I do not see where the variable is decreased, so once it finds that the Variable is equal to 3, it should switch to page two but then it should find the variable still is equal to 3.

Sorry, I'm just trying to wrap my head around exactly what it does. Also, I noticed it says "manifique" and I think you mean "magnifique".


EDIT: Okay, downloaded your game and checked it out. I see how it works a bit better now. I'm going to mess around a bit and see if I can't figure out something more streamlined.
Apologies for the confusion, I assumed "script" could be a generic term for "the pages of stuff that happen during an event" instead of just referring to custom scripts. Also the dialogue is all goofy test text, pay it no mind.

What happens here is the player gets a key item selection screen when interacting with the event. If they select item 002, "Ingredient A," then self switch A turns on. Interacting again goes to a different event page where they can select a key item again. If the item is 003, "Ingredient B," then
it gives the player item 001, "Test potion." Either way the switch is then reset. And then I have a second self switch and third page for if the player selects Ingredient B first.

The problem is this gets exponentially more complicated as more possible "recipes" become added, some of which need more than two ingredients. I'm trying to figure out a better way to write this event, or at least a better way to organize it.
Okay, got a fix for ya. But I need to know your potion system. I need to know:
a) how many different potions are going to be able to make
b) the number of ingredients each potion will use
c) how many different ingredients are going to be in the game
The problem is this gets exponentially more complicated as more possible "recipes" become added, some of which need more than two ingredients. I'm trying to figure out a better way to write this event, or at least a better way to organize it.
There is a reason why there are crafting scripts, because nothing can prevent that complexity if you're going by events.

However, there is a better structure - and if you have more recipes, you need to get rid of the self-switches anyway.

1) start with a question of how many ingredients the player wants to use. Depending on answer, call a common event written for that number.

2) in the common event, have a series of select item commands using different variables to set the ingredients.
If the player wants to use two components, the common event needs two variables and two select item commands, three if three components and so on.

3) after the ingredients are set (and substracted from inventory), check the allowed combinations for the variables. If the combination is found, give the potion and exit event processing. If it is not found, the last command is the "failed" message (which is why you need exit event processing if the combination is allowed.
Okay, got a fix for ya. But I need to know your potion system. I need to know:
a) how many different potions are going to be able to make
b) the number of ingredients each potion will use
c) how many different ingredients are going to be in the game

I'll say for the time being, the finished game will have 7 different potions, with 18 ingredients, and for the sake of simplicity potions will always use 3 ingredients. Does this work?

@Andar that makes sense. I figured I'd have to learn more about how variables work eventually. For the sake of completeness, do you have a recommendation for a crafting script?

Original thread: https://forums.rpgmakerweb.com/threads/help-me-streamline-my-potion-brewing-event.76875/